JQuery transit animation and .stop () fx queue

Firstly, jQuery Transit rock. If you haven’t seen him, check out http://ricostacruz.com/jquery.transit/ and be amazed!

One problem is that although he claims to be using a jQuery effects queue and apparently, for the most part, I can't use the jQuery method .stop()to work with it.

I wrote a fiddle here: http://jsfiddle.net/nicholasstephan/sTpa7/

If you click the animation button, standard jQuery is used to slowly move the window to the right .animate(). Stopping the stop will, as you would expect, stopping the animation. Pressing reset will also stop the animation and return the field to where it was started.

If you press the transition, it should do the same ... but it doesn’t ...

What's going on here? Does anyone know a workaround for this?

Thank.

+5
source share
2 answers

Here is a solution that might work.

try creating a new transition function that queues an additional callback. This callback can be cleared after the animation is canceled by stopping. Cleaning and skipping instructions However, stops from the old function are not accepted. But for this we can create a new stop function. It is simply printed in a browser and not fully verified.

(function($){
    $.fn.stopableTransition = function (...){
        var skip = false
        var clear = false
        this.handle("stopTransition", function(doclear, doskip){
            skip = doskip; clear = doclear;
        })
        this.transition(...)
        this.queue(function(){
            if(skip){
               //todo: ensure animation is removed from css
               //todo: move object to where the animation would have finished
            } 
            else
            {
               //todo: ensure animation is removed from css
               //todo: make sure object stays at its current position
            }

            if(clear){
                skip = false
                clear = false
                $(this).clearQueue()
            }  
            else 
            { 
                skip = false
                clear = false
                $(this).dequeue()
            }

        })
    }
    $.fn.stopTransition = function (clear, skip){
        clear = (typeof(clear) === 'undefined') ? false : clear;
        skip = (typeof(skip) === 'undefined') ? false : skip;
        this.triggerHandler("stopTransition", [clear, skip])
        this.dequeue();
    }
})(jQuery)
+4
source

@Jason More, , , fork transitionStop() ( clearQueue()), , , TransitJS 3 , , ll , .
, .

0

All Articles