[ 10 posts ]

Edi

  • Username: mediafreakch
  • Joined: Thu Nov 24, 2011 7:06 am
  • Posts: 9
  • Twitter: mediafreakch
  • Offline
  • Profile

Callback of Transition doesn't work

Post Posted: Thu Dec 01, 2011 7:34 am
+0-
Hi,

Would appreciate any help on this example: http://jsfiddle.net/zT7nu/2/

Can't get the callback to work... It doesn't fire so I think something with the transition goes wrong?

Code:
YUI().use('node', 'transition', 'event', function(Y) {
    Y.one('#node2').on('click', function() {
        Y.one('#node').transition({
            display: 'none'
        }, function() {
            Y.one('#node').transition({
                display: 'block'
            }, function() {
                alert('foo');
            });
        });
    });
});

Juan Ignacio Dopazo

YUI Contributor

  • Username: jdopazo
  • Joined: Fri Oct 02, 2009 5:39 am
  • Posts: 620
  • Location: Buenos Aires, Argentina
  • Twitter: juandopazo
  • GitHub: juandopazo
  • Gists: juandopazo
  • Online
  • Profile
Tags:

Re: Callback of Transition doesn't work

Post Posted: Thu Dec 01, 2011 4:42 pm
+0-
I'm pretty sure you need to transition properties that have a numeric value like opacity, width, etc. I don't think Transition is expected to work with boolean styles.

Edi

  • Username: mediafreakch
  • Joined: Thu Nov 24, 2011 7:06 am
  • Posts: 9
  • Twitter: mediafreakch
  • Offline
  • Profile
Tags:

Re: Callback of Transition doesn't work

Post Posted: Fri Dec 02, 2011 3:02 am
+0-
Yes that was the problem. Using 'opacity' : 'value' instead solves the problem. See: http://jsfiddle.net/zT7nu/3/ for a working example

Edi

  • Username: mediafreakch
  • Joined: Thu Nov 24, 2011 7:06 am
  • Posts: 9
  • Twitter: mediafreakch
  • Offline
  • Profile

Re: Callback of Transition doesn't work

Post Posted: Fri Dec 02, 2011 4:28 am
+0-
But it seems that it is not possible to do a fade in transition on a node that is hidden with 'display' : 'none'.

In jQuery there is a function called fadeIn() and works also if a node is hidden with display:none. Can this be achieved as easy as with jQuery using the YUI3 Transition module?

Juan Ignacio Dopazo

YUI Contributor

  • Username: jdopazo
  • Joined: Fri Oct 02, 2009 5:39 am
  • Posts: 620
  • Location: Buenos Aires, Argentina
  • Twitter: juandopazo
  • GitHub: juandopazo
  • Gists: juandopazo
  • Online
  • Profile

Re: Callback of Transition doesn't work

Post Posted: Fri Dec 02, 2011 4:47 am
+0-
I believe that's something YUI should emulate. I think there was a ticket asking for this, but I don't know what became of it.

Simon Gilligan

  • Username: sgilligan
  • Joined: Wed Jun 16, 2010 4:35 pm
  • Posts: 76
  • Location: Victoria, Australia
  • Offline
  • Profile

Re: Callback of Transition doesn't work

Post Posted: Fri Dec 02, 2011 4:54 am
+0-
This may be what you're after:

http://yuilibrary.com/yui/docs/transition/transition-view.html

paolo nesti poggi

YUI Contributor

  • Username: paolo
  • Joined: Sat Mar 14, 2009 9:53 am
  • Posts: 77
  • Location: Roskilde DK
  • GitHub: tribis
  • Gists: tribis
  • Offline
  • Profile

Re: Callback of Transition doesn't work

Post Posted: Fri Dec 02, 2011 4:55 am
+0-
yes, I was thinking about the same.
The fiddle becomes something like: http://jsfiddle.net/zT7nu/4/

Edi

  • Username: mediafreakch
  • Joined: Thu Nov 24, 2011 7:06 am
  • Posts: 9
  • Twitter: mediafreakch
  • Offline
  • Profile

Re: Callback of Transition doesn't work

Post Posted: Fri Dec 02, 2011 5:32 am
+0-
The function show() is exactly what I've been looking for. It also accepts config parameters for the transition and a callback function. But however fading in a node does not work if CSS style of a node is set to display:none.

Could be related to this ticket:
http://yuilibrary.com/projects/yui3/ticket/2531489

See updated jsFiddle: http://jsfiddle.net/zT7nu/6/ (Callback is fired, but node does not appear)

paolo nesti poggi

YUI Contributor

  • Username: paolo
  • Joined: Sat Mar 14, 2009 9:53 am
  • Posts: 77
  • Location: Roskilde DK
  • GitHub: tribis
  • Gists: tribis
  • Offline
  • Profile

Re: Callback of Transition doesn't work

Post Posted: Fri Dec 02, 2011 6:40 am
+0-
Yes I think too it is related to the ticket you quote.
The function assumes that the start state is a visible one and show() (or _show()), restores that initial condition removing any style added by Node itself.

Code:

    /**
     * The implementation for showing nodes.
     * Default is to toggle the style.display property.
     * @method _show
     * @protected
     * @chainable
     */
    _show: function() {
        this.setStyle('display', '');

    },


As things stand now I think the only workaround (if your start state is display:none) is to bake your own method around this, however it would be good if the maintainer could chime in with some suggestions

Edi

  • Username: mediafreakch
  • Joined: Thu Nov 24, 2011 7:06 am
  • Posts: 9
  • Twitter: mediafreakch
  • Offline
  • Profile

Re: Callback of Transition doesn't work

Post Posted: Fri Dec 02, 2011 6:45 am
+0-
Found a working solution. However this is little bit of an overkill to just fadein a node:

Code:
 Y.one('#node').setStyles({'display' : 'block', 'opacity' : 0}).transition({
               opacity : 1
           });


See http://jsfiddle.net/zT7nu/9/
  [ 10 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum