Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update scene start after DOM removal? #307

Closed
JonMcL opened this issue May 3, 2015 · 4 comments
Closed

Update scene start after DOM removal? #307

JonMcL opened this issue May 3, 2015 · 4 comments
Milestone

Comments

@JonMcL
Copy link

JonMcL commented May 3, 2015

My apologies if this is covered somewhere already; my searching has failed me.

If I remove DOM elements, which happen to come before the start of an existing scene, is there any way to update the start of the scene now that it is in a different scroll position?

I've tried Controller.update() and Scene.update().

The only thing that seems to work for me is to remove all remaining scenes from the controller and then add them back in.

Thanks!

@janpaepke
Copy link
Owner

Actually this should be handled automatically.
If the triggerElement position changes for whatever reason the scene's start position and progress are updated automatically.
In case it doesn't for you, it might be a bug, in which case it would be helpful if you could make a jsfiddle showcasing it.

@JonMcL
Copy link
Author

JonMcL commented May 3, 2015

Sorry, I JUST figured it out. You are right, it is handled automatically and correctly.

I had two scenes attached to the particular DOM element that I was removing. One to trigger a reveal animation and another scene to trigger the removal of the element. When I removed the element, I was only removing one of those scenes (from the controller) before removing the actual DOM element.

So this triggered a type error of "Cannot read property 'hasAttribute' of null" in the updateTriggerElementPosition function during the update. I guess because it was trying to update the un-removed scene and it's element was no longer inside the DOM.

Might be a good idea to do a sanity check on the "while (telem.parentNode.hasAttribute(PIN_SPACER_ATTRIBUTE))" loop?

@janpaepke
Copy link
Owner

I'll look into that. thx :)

@janpaepke janpaepke added the bug label May 4, 2015
@janpaepke janpaepke added this to the v2.0.6 milestone May 4, 2015
@janpaepke
Copy link
Owner

Investigating this I actually stumbled over a bug: When removing the triggerElement the trigger position wasn't reset to 0 (unless explicitly triggered).
So now I fixed this and also added a a warning, if a triggerElement of a scene is removed from the DOM.

Thanks again for posting this.

janpaepke added a commit that referenced this issue May 4, 2015
Both using Scene.triggerElement(undefined) or removing a triggerElement
from the DOM caused problems, which are now resolved.
See: #307
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants