I am trying to slide in a button when the scroll position is between two pxiel values and slides out when its not. The following code is not really working as the button sometimes slides in and sometimes not and most of the time not between the defined pixel values .. is this a script loading issue or is my jQuery code wrong?
var y = jQuery(this).scrollTop();
if (y > 700 && y < 1300) {
jQuery('.side-button-wrap').animate({ left: '0px' });
} else {
jQuery('.side-button-wrap').animate({ left: '-200px' });
}
});´´´