0

i have this code

$(document).ready(function () {
setInterval(function () {
    var iScroll = $(window).scrollTop();
    iScroll = iScroll + 200;
    $('html, body').animate({
        scrollTop: iScroll
    }, 1000);
}, 2000);});

it works properly and it scrolls automatically my page but i want when scrolling ends go to beginning and repeat scrolling automatically , What is the problem?

thanks great man @lessugar i solved my problem :) here is my code

setInterval(function () {
    var iScroll = $(window).scrollTop();
    iScroll = iScroll + 200;
    if ($(window).scrollTop() + $(window).height() > $(document).height() - 100) {
        $('html, body').animate({ scrollTop: 0 }, 800);
    }
    else {
        $('html, body').animate({ scrollTop: iScroll }, 1000);
    }
}, 2000);
dashtinejad
  • 6,193
  • 4
  • 28
  • 44

0 Answers0