开发者

can't use animate scrollTop with jscrollpane?

I'm using the following jQuery function to smoothly scroll to page sectio开发者_如何学JAVAns:

function scrollTo(element) {    
    //$('html, body').animate({           // before the addition of jscrollpane
    $('#full-page-container').animate({   // after addition of jscrollpane
        scrollTop: $(element).offset().top
    }, 1500);
}

I've added jscrollpane to replace the default page scrollbar, and it seems that the animate function with scrollTop above won't work with jscrollpane, but works flawlessly without it.

Is it possible to use both jscrollpane and animate with scrollTop ?


No, you can't use scrollTop.

However, scrollpane has their own built in scrolling, which you can see examples of here.

Scroll To - JScrollPane

Example, taken from the jScrollPane site:

var api = pane.data('jsp');

    $('#but-scroll-to').bind(
        'click',
        function()
        {
            // Note, there is also scrollToX and scrollToY methods if you only
            // want to scroll in one dimension
            api.scrollTo(parseInt($('#toX').val()), parseInt($('#toY').val()));
            return false;
        }
    );


Notes: You can't animate() and jScrollPane together. However, jScrollPane is nice enough to include this feature. It isn't very intuitive, but I made a some examples for you. Cheerio!

See the jScrollPane API for more useful information.


I had some examples, but jsfiddle is hanging on them (I can't even see the source code), so I have removed them.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜