Question

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);
Was it helpful?

Solution

First, add these styles to your wrapper:

position: absolute;
overflow: scroll;

Then take out panelSelector: 'section.panel' from your options, and it should work. You may want to fine tune your options afterwards. Here's a fiddle.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top