Below code is called whenever user is scrolling an element while not at the edge of element.
setTimeout(() => {
timeout = false;
}, 2000);
This actually leads to (kinda) nothing for smooth scrolls.
Above code will be called multiple times (around 50 times for one swipe in smooth scroll track pad) which will set timeout to false after 2s of each calls.
For example if it's called at time 0000 and it's called again at 1500, the first one will set timeout to false at 2000. If we scroll at 2001 at the edge, the navigation function will go in and users get navigated at 2001 because timeout is set to false.
In above case what we want is navigation timeout set to true until 3500. (right?)
I don't know any other fix except counting all calls, here are the illustration.
someCounter++;
setTimeout(() => {
someCounter--;
}, 2000);
// ..
// disabling navigation
if (someCounter) // do not navigate
Above code works for me. Although it looks kinda ugly and probably not the best practice.
Below code is called whenever user is scrolling an element while not at the edge of element.
This actually leads to (kinda) nothing for smooth scrolls.
Above code will be called multiple times (around 50 times for one swipe in smooth scroll track pad) which will set timeout to false after 2s of each calls.
For example if it's called at time 0000 and it's called again at 1500, the first one will set timeout to false at 2000. If we scroll at 2001 at the edge, the navigation function will go in and users get navigated at 2001 because timeout is set to false.
In above case what we want is navigation timeout set to true until 3500. (right?)
I don't know any other fix except counting all calls, here are the illustration.
Above code works for me. Although it looks kinda ugly and probably not the best practice.
What do you think?