Last active
August 29, 2015 14:27
-
-
Save keeganbrown/c802aa0d6860cbd2fa7c to your computer and use it in GitHub Desktop.
mobile master timeline scrub
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
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