Last active
August 29, 2015 13:57
-
-
Save weotch/9494115 to your computer and use it in GitHub Desktop.
Example change handler function. Does a basic fade.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Change the page | |
View.change = function(e, new_page) { | |
// Make sure old page has lower z-index and stop any trams. | |
// Note: calling set() invokes stop() | |
var old = this.$slides.eq(e.previous('page')).tram() | |
.set({'z-index': 1}) | |
; | |
// Hide the old one after the transition is done. Don't use | |
// then() because it won't be fired if the animation is stopped. | |
tram.delay(300, function () { | |
old.set({display: 'none'}); | |
}); | |
// Animate in new page | |
this.$slides.eq(new_page).tram() | |
.add('opacity 300ms') | |
.set({ display: 'block', opacity: 0, 'z-index': 2} ) | |
.start({ opacity: 1}) | |
; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm doing a new approach currently where I create new instances of slides in the DOM rather than mess with the state on existing slides.