Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Adding and removing elements at runtime #47

Open
23tux opened this Issue Sep 26, 2012 · 2 comments

Comments

Projects
None yet
3 participants

23tux commented Sep 26, 2012

I'm adding parallax to some elements at runtime. The first time, it works fine. But when I remove an element from the DOM, and I move my mouse outside the window and back, I'm getting this error:

Uncaught TypeError: Cannot read property 'freeze' of undefined

This is at line 391 in the jquery.parallax.js

And when I'm adding the element back to the DOM and call $(".bubbles").parallax() it doesn't work anymore (the bubbles don't move).

Is it possible to provide a destroy function that the listeners are removed when an element is removed? Or any other solution?

Owner

stephband commented Sep 26, 2012

If you check out the git branch '2.0' you will find a version without
freeze events, but with an .unparallax() method for destroying the parallax.

Let me know how it goes. It has been used in production only a couple of
times.
On 26 Sep 2012 16:40, "Hubert Hölzl" notifications@github.com wrote:

I'm adding parallax to some elements at runtime. The first time, it works
fine. But when I remove an element from the DOM, and I move my mouse
outside the window and back, I'm getting this error:

Uncaught TypeError: Cannot read property 'freeze' of undefined

This is at line 391 in the jquery.parallax.js

And when I'm adding the element back to the DOM and call
$(".bubbles").parallax() it doesn't work anymore (the bubbles don't move).

Is it possible to provide a destroy function that the listeners are
removed when an element is removed? Or any other solution?


Reply to this email directly or view it on GitHubhttps://github.com/stephband/jparallax/issues/47.

Hi,
First of all : nice job !
When using your unparallax method like this :
$(window).bind("resize", function () {
jQuery('#parallax .parallax-layer')
.unparallax(true)
.parallax({
mouseport: jQuery('#parallax')
});
});
I get an exception telling that elem is undefined in the unstyle function.
It happens only when giving true to unparallax.
I tried this because after calling unparallax, it flickers, seems like the layers would have been duplicated or something like that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment