3

I tried the panelSnap plugin and got it working when the elements I wish to scroll to are within the tag.

But when i'm trying the same thing but with elements inside a wrapper it's not working anymore.

With Chrome I got this error message: 'Uncaught TypeError: Cannot read property 'top' of undefined '

I've created a jsFiddle to make sure i'm not crazy! http://jsfiddle.net/7K2CT/6/

var options = {
    $menu: $('header .menu'),
    panelSelector: 'section.panel',
    directionThreshold: 200,
    slideSpeed: 500
};
$('#wrapper').panelSnap(options);
4

1 回答 1

5

首先,将这些样式添加到您的包装器中:

position: absolute;
overflow: scroll;

然后panelSelector: 'section.panel'从您的选择中取出,它应该可以工作。之后您可能需要微调您的选项。这是一个小提琴

于 2013-12-19T16:48:19.210 回答