How to avoid the scroll lock?
Hello everyone
.
I'm trying to create an analogue of this
or
this plugin.
Here is my
code
:
- $(window).scroll(function() {
- if($(this).scrollTop() >= $("#Page_1").offset().top/2){
- var scroll_page_2 = $('#Page_2').offset().top;
- $(document).scrollTop(scroll_page_2);
- }
- if($(this).scrollTop() <= $("#Page_1").offset().top/2){
- var scroll_page_1 = $('#Page_1').offset().top;
- $(document).scrollTop(scroll_page_1);
- }
- });
I have blocked
scrolling
.
An example
is here .
Well
with
my code
so
everything is clear
.
I
get
that
if scrolling
is
below
1
page
, scrolling
should
fall
.
But when
I'm on a
2
page and
anything
up
,
I'm still
here
1
page and
my script
me
down
down
.
This
error
.
Question
-
how to
?
Enter
the variable
to
determine
which page
?
And
then
put
a bunch of
conditions
?
Thanks, Alex