So im using the window.scrollby like this
<script>
function scrollWindowup() {
window.scrollBy(0,700)
}
function scrollWindowdown() {
window.scrollBy(0,-700) }
</script>
is there any way to animate it like move slowy or an offset or any other option ?
thanks in advance
It is not same as scrollTo behavior. It means scrollBy always scrolls up or down further from current position. Or you can say scrollBy scrolls by distance from current pixels. Or you can say scrollBy consider current position as (0,0) and scroll further.
Method 1: Using window.scrollTo() The scrollTo() method of the window Interface can be used to scroll to a specified location on the page. It accepts 2 parameters the x and y coordinate of the page to scroll to. Passing both the parameters as 0 will scroll the page to the topmost and leftmost point.
scrollBy() method scrolls the document in the window by the given amount.
From a similar question...
You can animate the scrolltop
of the page with jQuery
.
$('html, body').animate({
scrollTop: $(".middle").offset().top
}, 2000);
Or
$('html, body').animate({
scrollTop: 700
}, 2000);
Animating down a page:
$('html, body').animate({
scrollTop: '+=700'
}, 2000);
Animating up a page:
$('html, body').animate({
scrollTop: '-=700'
}, 2000);
See this site: http://papermashup.com/jquery-page-scrolling/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With