Browse Source

Transition: prevents same animation from occurring twice by default

pull/524/head
jlukic 10 years ago
parent
commit
4dcfe8aa40
1 changed files with 16 additions and 3 deletions
  1. 19
      src/modules/transition.js

19
src/modules/transition.js

@ -130,7 +130,12 @@ $.fn.transition = function() {
} }
module.debug('Preparing animation', settings.animation); module.debug('Preparing animation', settings.animation);
if(module.is.animating() && settings.queue) { if(module.is.animating() && settings.queue) {
module.queue(settings.animation);
if(!settings.allowRepeats && module.has.direction() && module.is.occuring() && instance.queuing !== true) {
module.error(error.repeated);
}
else {
module.queue(settings.animation);
}
return false; return false;
} }
if(module.can.animate) { if(module.can.animate) {
@ -540,6 +545,10 @@ $.fn.transition = function() {
looping: function() { looping: function() {
return $module.hasClass(className.looping); return $module.hasClass(className.looping);
}, },
occuring: function(animation) {
animation = animation || settings.animation;
return ( $module.hasClass(animation) );
},
visible: function() { visible: function() {
return $module.is(':visible'); return $module.is(':visible');
}, },
@ -766,9 +775,12 @@ $.fn.transition.settings = {
onShow : function() {}, onShow : function() {},
onHide : function() {}, onHide : function() {},
// whether animation can occur twice in a row
allowRepeats : false,
// animation duration // animation duration
animation : 'fade',
duration : '700ms',
animation : 'fade',
duration : '700ms',
// new animations will occur after previous ones // new animations will occur after previous ones
queue : true, queue : true,
@ -788,6 +800,7 @@ $.fn.transition.settings = {
// possible errors // possible errors
error: { error: {
noAnimation : 'There is no css animation matching the one you specified.', noAnimation : 'There is no css animation matching the one you specified.',
repeated : 'You specified the same animation to occur again while it was already occurring, preventing repeated animation',
method : 'The method you called is not defined', method : 'The method you called is not defined',
support : 'This browser does not support CSS animations' support : 'This browser does not support CSS animations'
} }

Loading…
Cancel
Save