Search code examples
jqueryhtmlscrollmultiscroll.js

automatic scroll using multiscroll.js


i was testing multiscroll.js for my website on a temp link. I was wondering if it is possible to scroll through without using mouse or keyboard ie. the images should scroll automatically.(like after every 5 secs it should scroll to next block)

my test link is: http://goo.gl/HjkJKx

this page consists of simple jquery call

<script type="text/javascript">
     $(document).ready(function() {
            $('#myContainer').multiscroll({
                sectionsColor: ['#1bbc9b', '#4BBFC3', '#7BAABE'],
                anchors: ['first', 'second', 'third'],
                menu: '#menu',
                loopTop: true,
                loopBottom: true
            });
        });
    </script>

and the html is like this:

<ul id="menu">
    <li data-menuanchor="first"><a href="#first">First slide</a></li>
    <li data-menuanchor="second"><a href="#second">Second slide</a></li>
    <li data-menuanchor="third"><a href="#third">Third slide</a></li>
</ul>

<div id="myContainer">

    <div class="ms-left">
        <div class="ms-section" id="left1">
            <h1>Left 1</h1>
        </div>

        <div class="ms-section" id="left2">
            <h1>Left 2 </h1>
        </div>

        <div class="ms-section" id="left3">
            <h1>Left 3</h1>
        </div>
    </div>

    <div class="ms-right">
        <div class="ms-section" id="right1">
            <h1>Right 1</h1>
        </div>

        <div class="ms-section" id="right2">
            <h1>Right 2</h1>
        </div>

        <div class="ms-section" id="right3">
            <h1>Right 3</h1>
        </div>
    </div>  
</div>

Solution

  • Yes. Multiscroll have methods that can be used for this.

    You could combine moveSectionDown() and setInterval():

    function scrollMe() {
        $.fn.multiscroll.moveSectionDown(); 
    }
    setInterval(scrollMe, 5000);
    

    Make sue you set loopBottom: true.

    JSFiddle