Created
February 12, 2016 18:33
-
-
Save beardedtim/39fa74db327fe79918fc to your computer and use it in GitHub Desktop.
This file contains 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
jQuery(window).scroll(function(){ | |
var previousHeight = jQuery('#animation-trigger').prev().height() ; | |
var startingPixelsDown = jQuery('#animation-trigger').offset().top; | |
var currentViewPortPosition = jQuery(window).scrollTop(); | |
//console.log(startingPixelsDown); | |
// console.log( currentViewPortPosition + previousHeight); | |
// console.log(startingPixelsDown - ( currentViewPortPosition + previousHeight ) ); | |
// console.log(startingPixelsDown); | |
var pixelsToGoTillDivAtTop = startingPixelsDown - ( currentViewPortPosition + previousHeight ) ; | |
// bigger x === sooner event trigger | |
var x = 5 | |
var pixelsToGoTillTrigger = pixelsToGoTillDivAtTop + previousHeight/x; | |
if(!( pixelsToGoTillTrigger > 0 )) { | |
// console.log('no pixels to go! '); | |
removeClassesFromBoxes(choiceDivs, choiceClass); | |
} | |
}); | |
// console.log('if returned true'); | |
} else { | |
// console.log('false'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment