guidobouman/panelsnap

Manual Panel Activation (getPanel not returning correctly)

Closed this issue · 3 comments

Hi there,

Great script first of all.

I'm struggling to get the manual activation with a class to work though. On my localhost I'm trying to use the JavaScript hash function to make the element scroll to the correct place from a different page/url. However it only seems to be scrolling to the next section and not the correct section with the defined class.

I've borrowed someone else's jsfiddle and tried it there as well but it also doesn't seem to work?
http://jsfiddle.net/5Va8G/13/ - Updated with console log.

Any help with this would be appreciated

The getPanel function doesn't seem to return the correct value:

var $target = $('.panel-container').panelSnap('getPanel', '.test');
console.log($target);

Returns

[div.panel-container.right-gallery, prevObject: n.fn.init[1], context: document, selector: ".panel-container"]

Were as if I console log the actual return value in the getPanel function you get:

var test = $(self.options.panelSelector + selector, self.$container);
console.log(test);

[prevObject: n.fn.init[1], context: div.panel-container.right-gallery, selector: "> section.test"]

Which I guess would work as the selector is pointing towards test?

Not sure if this is getting lost somewhere? Or if it's something I'm doing wrong?

Added some extra cases to the snapTo function for the time being to get around the above:

$('.panel-container').panelSnap('snapTo', 'third');

case 'third':
                $target = $panels.filter('.element-class');
                break;

My bad, the documentation was wrong. Internal methods can't return data through the external API.

As an alternative you can select a panel manually through var $target = $('.panel-container > .test') and then activate that panel through $('.container').panelSnap('snapToPanel', $target);