javascript - if element offset top is at 10% of viewport -
javascript - if element offset top is at 10% of viewport -
i execute function , observe when element.offset().top
@ more or less 10% of viewport(window) when scroll. how can proceed?
i have @ moment.
$(window).on('scroll', function() { var wst = $(this).scrolltop(); var wh = $(this).height(); var elpos = wrapper.offset().top; if (wst >= elpos) { console.log('snoop doggy dog'); } });
thanks help.
note: it's element position top needs @ 10% of window. not 10% of document. thanks.
i have written different implementation help accomplish task. explain rest in snippet comments.
$(window).on('scroll', function() { /* onscroll */ /* calculate if scroll position > 10% */ if($(document).scrolltop() > (0.1 * $(document).height())) { console.log('scroll passed 10%'); } else { /* less 10% */ } });
demo
didn't got question quiet deleted.
javascript jquery
Comments
Post a Comment