Skip to content

Instantly share code, notes, and snippets.

@weotch
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save weotch/9494115 to your computer and use it in GitHub Desktop.
Save weotch/9494115 to your computer and use it in GitHub Desktop.
Example change handler function. Does a basic fade.
// 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})
;
};
@weotch
Copy link
Author

weotch commented Mar 24, 2014

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment