scroll - jQuery - Run a function when user has scrolled up 100px from current location -
i trying run function once user has scrolled 100px , function when scroll down (any number of pixels) there current location. if user scrolls half way down page , starts scroll need function run once have scrolled 100px current stored scrolltop value.
if user 700px down page , started scroll need function run when hit 600px. should dynamic ever user down page.
as starting point have:
var lastscrolltop = 0; $(window).scroll(function(event){ var st = $(this).scrolltop(); if (st > lastscrolltop){ // scrolling down } else { // scrolling } lastscrolltop = st; });
thanks
jsfiddle(http:/jsfiddle.net/nick_craver/gwd66/1/)
try link. may helpful you
use code
<script type="text/javascript"> var position = $(window).scrolltop(); $(window).scroll(function() { var scroll = $(window).scrolltop(); if(scroll > position) { movecardownward(scroll); // $('#status').html('going down!'); } else { movecarupward(scroll); //$('#status').html('going up!'); } position = scroll; });
one link 1 in javascript link
Comments
Post a Comment