Skip to content

Instantly share code, notes, and snippets.

@keeganbrown
Last active August 29, 2015 14:27
Show Gist options
  • Save keeganbrown/c802aa0d6860cbd2fa7c to your computer and use it in GitHub Desktop.
Save keeganbrown/c802aa0d6860cbd2fa7c to your computer and use it in GitHub Desktop.
mobile master timeline scrub
var scrubpoint = 0;
var isScrolling = null;
$('body').hammer().on('pan', function (e) {
var deltaY = e.gesture.deltaY;
if ( deltaY != 0 && Math.abs(deltaY) > 2 ) {
if ( !isScrolling ) {
$('video').each( function (i, ele) { ele.pause() } );
}
master.pause();
scrubpoint = ( deltaY / Math.abs(deltaY) );
if ( !!isScrolling ) {
clearTimeout( isScrolling );
isScrolling = null;
}
isScrolling = setTimeout( function () {
isScrolling = null;
master.play();
scrubpoint = 0;
}, 500 );
}
//console.log(e)
});
TweenMax.ticker.addEventListener('tick', function () {
var scrollmod = scrubpoint / -10;
if ( isScrolling && master.time() + scrollmod > 0.01 && master.time() + scrollmod < master.duration() - 0.01 ) {
master.seek( master.time() + scrollmod );
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment