jakiestfu / Snap.js

A Library for creating beautiful mobile shelfs in Javascript (Facebook and Path style side menus)

Home Page:http://jakiestfu.github.io/Snap.js/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Snap.js with Push.js

ttulkin opened this issue · comments

I'm new to JavaScript and I've been having an issue with snap.js and push.js. I'm building a prototype on Ratchet (that uses push.js to switch to the next page) and snap.js for the sidebar. Once I click on a link that is animated by push.js to the next page, the snap.js sidebar stops working. I have to update the page once in order to be able to use the sidebar.

It seems like this issue has been addressed in the documentation. However, I don't know where to insert the snippet. I would be really appreciated if anybody could advice me on that!

This is a section of a Q&A from the Snap.js documentation:

"I am using Push.js from Ratchet, I keep losing my events on my elements, how can I fix this?

Simple. As wack as Push.js is (yes, it is in desperate need of attention as of v1.0.0), we can still solve this problem with it's only callback, 'push'.

// The function that will initialize your Snap.js instance
var doSnap = function(){
if(window.snapper){
// Snap.js already exists, we just need to re-bind events
window.snapper.enable();
} else {
// Initialize Snap.js
window.snapper = new Snap({
element: document.getElementById('content')
});
}
};

window.addEventListener('push', doSnap);
doSnap();"