Answer the question
In order to leave comments, you need to log in
How to stop scrolling in exact place?
The wheel event does not fire every 100px or more. And I need pixel-perfect to stop at the right place using JS.
Answer the question
In order to leave comments, you need to log in
To do this, you need to reduce the sensitivity of the wheel in the operating system to one pixel per tick.
(Hint: none of your users will be doing this kind of bullshit.)
A more realistic plan: move the scroll yourself when the user has scrolled approximately where you need.
#elem {
position: absolute; // ваши параметры
top: 30px;
left: 30px;
}
.fixed_elem {
position: fixed !important;
top: 10px !important; // ваши параметры
left: 10px !important;
}
var elem=document.getElementById('elem');
window.onscroll=fixed_scroll;
function fixed_scroll() {
if(window.pageYOffset > 100) { // ваша высота
elem.classList.add('fixed_elem');} else {
elem.classList.remove('fixed_elem')}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question