Skip to content

Instantly share code, notes, and snippets.

@victor-homyakov
Created November 21, 2012 06:36
Show Gist options
  • Save victor-homyakov/4123398 to your computer and use it in GitHub Desktop.
Save victor-homyakov/4123398 to your computer and use it in GitHub Desktop.
transition: function (method, startEvent, completeEvent) {
var that = this
, complete = function (e) {
if (this.transitioning) {
if (e.type == 'show') this.reset()
this.transitioning = 0
this.$element.trigger(completeEvent)
}
}
this.$element.trigger(startEvent)
if (startEvent.isDefaultPrevented()) return
this.transitioning = 1
if ($.support.transition && this.$element.hasClass('collapse')) {
// assign callback to transition end event, then start transition
this.$element.one($.support.transition.end, complete)
this.$element[method]('in')
// guarantee callback invokation
// timeout is equal to transition time from component-animations.less
setTimeout(function(){
complete.call(that, startEvent);
}, 350)
} else {
this.$element[method]('in')
complete.call(this, startEvent)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment