开发者

Can the Scrollto plugin search within a separate div?

heres some background info:

I want to make a menu where clicking on a lin开发者_如何学运维k scrolls to a specific div within a div. the 'separate div that contains the div i want to scroll to' is also draggable with the dragscroll plugin. because of this, the links cannot be in the same div that will be scrolling. the link menu is outside the draggable div completely.

I have both plugins playing nice with eachother. the div can be drag-scrolled. but when i click on a link the ENTIRE page scrolls down a little instead of the content within the draggable div scrolling.

how can i bring the scope of the scrollto plugin down so it only tries to scroll within my div?

thanks in advance.


I'm not quite sure what you mean by 'dragscroll' plugin, but is this what you're after?

$(".link").click(function() {
    // grab the href from the link, it should correspond with the ID of the element you want to scroll to
    var id = $(this).attr("href");

    // tell your container to start scrolling to the element
    $("#yourDraggableContainer").scrollTo($(id), 800);

    // prevent default behaviour of links
    return false;
});

jsFiddle: http://jsfiddle.net/Kat8t/10/

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜