Вопрос

I want to animate the div#w_xxx and the div#w_xxx img at the same time.

They should get bigger and after this they should get to their old width and height.

The problem is, mootools plays all animations at the same time so I cant see the animation and I tried some .chainfunction from mootools but I didnt get it working.

My code looks like this:

$("w_"+current_item+"").set('morph', {
            duration: 1000,
            transition: Fx.Transitions.Bounce.easeOut
        });
        $("w_"+current_item+"").morph({
                    'opacity': '1',
                    'width': 366,
                    'height': 240,
                    'z-index': '100'
        });

        $$("div#w_"+current_item+" img").set('morph', {
            duration: 1000,
            transition: Fx.Transitions.Bounce.easeOut
        });
        $$("div#w_"+current_item+" img").morph({
                    'opacity': '1',
                    'width': 366,
                    'height': 240,
                    'z-index': '100'
        });

        $("w_"+current_item+"").set('morph', {
            duration: 1000,
            transition: Fx.Transitions.Bounce.easeOut
        });
        $("w_"+current_item+"").morph({
                    'opacity': '1',
                    'width': 183,
                    'height': 120,
                    'z-index': '100'
        });

        $$("div#w_"+current_item+" img").set('morph', {
            duration: 1000,
            transition: Fx.Transitions.Bounce.easeOut
        });
        $$("div#w_"+current_item+" img").morph({
                    'opacity': '1',
                    'width': 183,
                    'height': 120,
                    'z-index': '100'
        });
Это было полезно?

Решение

You should look at Fx.Elements from MooTools-more: http://mootools.net/docs/more/Fx/Fx.Elements, which has been designed to run multiple animations on a unified timer.

http://jsfiddle.net/dimitar/tC4V4/

// mock your current_item... 
var current_item = 1;

var w = document.id("w_" + current_item);
new Fx.Elements($$(w, w.getElement("img")), {
    onComplete: function() {
        console.log("done");
    },
    duration: 4000,
    transition: Fx.Transitions.Bounce.easeOut,
    link: "chain"
}).start({
    0: {
        'opacity': '1',
        'width': 366,
        'height': 240,
        'z-index': '100'
    },
    1: {
        'opacity': '1',
        'width': 183,
        'height': 120,
        'z-index': '100'

    }   
}).start({
    0: {
        opacity: 0
    }  

});

By the same token, it supports link: chain so you can chain things or wait etc.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top