Search code examples
jqueryjquery-ui-sliderjquery-sliderjquery-slide-effects

Jquery Slider- Slide right to left and top to bottom


I tried changing the link Demo from fade to slideIn and slideOut but was not able to achieve as i would like to use a slideIn and slideOut style for a project, i am currently working on.

If anyone can help me guide through this, would be a great help.

[jsfiddle.net/chetanmani/6sj8x95y/] 

Thank you.


Solution

  • here you go : Fiddle

     /**
     * Fade-cycles elements with class 'banner'
     */
    $(document).ready(function() {
    
        var delay = 3000, fade = 1000;
        var banners = $('.banner');
        var len = banners.length;
        var i = 0;
    
        setTimeout(cycle, delay);
    
        function cycle() {
            $(banners[i%len]).slideUp(fade, function() {
                $(banners[++i%len]).slideDown(fade, function() {
                    setTimeout(cycle, delay);   
                });
            });
        }
    
    });
    

    so its using the jquery sildeUp and slideDown

    for slide right to left in a cycle here is the fiddle:

    function cycle() {
        $(banners[i % len]).hide("slide", function(){
             $(banners[++i % len]).show("slide", {
                direction: "left"
            });
            setTimeout(cycle, delay);
        });
    }