
I use FullSlider.js to create a full slide page. If the red element is fully visible, I need the browser to block the scroll event (means: the window does not move, but I can get the action), and then after I have done some things that I want to enable scrolling again.
This is what I have done so far:
I read a lot about this and tried even more solutions, such as: stop scrolling: 1. stop scrolling a web page using jquery does not work at all
How to programmatically disable page scrolling using jQuery stops scrolling, but it is not possible to enable scrolling again
event prevents default, works fine in chrome, but less subtle in firefox
check if element exists:
Check if the item is visible after scrolling
I used the solution above and tried:
In fact, solution 2 worked really well, but I just couldn't find the offset that I needed to compensate for βfixed-heading navigationβ.
I am currently using "isScrolledIntoView" to determine if a position is suitable (works well on large screens, generally does not work on small screens). To scroll the stop, I use the following hack:
CSS: .scrollHack {position: static; overflow: hidden; }
JS:
$(document).on('mousewheel', function(event, delta) { // stopScroll and isStopped are booleans delivered by another script if(isScrolledIntoView($("#s3"))) { isStopped = false; if(delta >= 0) { $('#s3').get(0).contentWindow.car.next(); // car.next(); } else{ $('#s3').get(0).contentWindow.car.previous(); } stopScroll = $('#s3').get(0).contentWindow.isStopped; } if(!stopScroll && isScrolledIntoView($("#s3"))) { event.preventDefault(); $("body").addClass("scrollHack"); } else { $("body").removeClass("scrollHack"); } }); function isScrolledIntoView(elem) { var docViewTop = $(window).scrollTop(); var docViewBottom = docViewTop + $(window).height(); var elemTop = $(elem).offset().top; var elemBottom = elemTop + $(elem).height(); return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop)); }
Has anyone come across a familiar situation and have some scripts or hacks to help me?
javascript jquery scroll
Qullbrune
source share