jquery scrollorama视差效应

时间:2014-04-22 14:45:14

标签: javascript jquery html css parallax

我正在尝试在水平网页上滑动实现scrolllorama效果,但是当我尝试调用它时,我的菜单不起作用,导航箭头也不起作用。此外,scrolllorama也不起作用。 这是我的小提琴:http://jsfiddle.net/jarod51/Tm9fs/

这里是我的jquery:

$(document).ready(function() {      
        var scrollorama = $.scrollorama({ blocks:'.panel' });


    scrollorama.animate('#contact h2',{
        duration:200, property:'left', end:-860
    });

});


    $(function () {
        var 
            animation = function ( href ) {
                var 
                    name = "active",
                    element = $( "a[href='" + href + "']" );

                $( "html, body" ).stop().animate( {
                    scrollLeft: $( href ).offset().left
                }, 1200 );

                element.closest( "ul" ).find( "li" ).removeClass( name );
                element.parent().addClass( name );
            },
            menu = $( "#list" );

        animation( menu.find( "li" ).eq( 0 ).find( "> a" ).attr( "href" ) );

        $( "#cssmenu a" ).bind( "click", function( event ) {
            var target = $( this ).attr("href");

            animation( target );

            event.preventDefault();
        } );

        $( "#next, #prev" ).click( function ( event ) {
            var
                positionActiveClass = menu.find( "> li.active" ).index(),
                menuLength = menu.find( "> li" ).length - 1,
                buttonId = $( this ).attr( "id" );

            if ( buttonId === "next" ) {
                if ( positionActiveClass === ( menuLength ) ) {
                    newElementActiveClass = menu.find( "li" ).eq( 0 );
                    newPositionActiveClass = newElementActiveClass.find( "> a" ).attr( "href" );

                    animation( newPositionActiveClass );
                } else {
                    newElementActiveClass = menu.find( "li" ).eq( positionActiveClass + 1 );
                    newPositionActiveClass = newElementActiveClass.find( "> a" ).attr( "href" );

                    animation( newPositionActiveClass );
                }
            } else {
                if ( positionActiveClass === 0 ) {
                    newElementActiveClass = menu.find( "li" ).eq( menuLength );
                    newPositionActiveClass = newElementActiveClass.find( "> a" ).attr( "href" );

                    animation( newPositionActiveClass );
                } else {
                    newElementActiveClass = menu.find( "li" ).eq( positionActiveClass - 1 );
                    newPositionActiveClass = newElementActiveClass.find( "> a" ).attr( "href" );

                    animation( newPositionActiveClass );
                }
            }

            event.preventDefault();
        } );

    } );

你知道我做错了吗?

0 个答案:

没有答案