Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
178
rated 0 times [  183] [ 5]  / answers: 1 / hits: 23665  / 12 Years ago, wed, october 17, 2012, 12:00:00

I want to stop a transition that is in progress.



I have found a few references[1][2] scattered around the internet but I can't seem to piece it together.



Here's a fiddle of the first suggestion (With jQuery and CSS Transit for context): http://jsfiddle.net/thomseddon/gLjuH/



Thanks



[1] https://twitter.com/evilhackerdude/status/20466821462



[2] github.com/madrobby/zepto/issues/508


More From » jquery

 Answers
52

So I figured it out: http://jsfiddle.net/thomseddon/gLjuH/3/



The trick is to set each css property you are animating to its current value (possibly mid transition) like: $(this).css('prop', $(this).css('prop')); (Probably would want to store all properties in an object in the element with $(this).data(props); and loop through them).



Once you have explicitly set the properties you can run a 0s animation to override the previous animation and effectively halt the element.


[#82509] Monday, October 15, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kelsy

Total Points: 486
Total Questions: 86
Total Answers: 76

Location: El Salvador
Member since Sun, Sep 12, 2021
3 Years ago
kelsy questions
Tue, Oct 19, 21, 00:00, 3 Years ago
Tue, Aug 4, 20, 00:00, 4 Years ago
Wed, Jun 17, 20, 00:00, 4 Years ago
Fri, Jan 10, 20, 00:00, 4 Years ago
;