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

Destroy should set back the menu or fixedElement to their initial DOM position #4263

Open
sneko opened this issue Sep 8, 2021 · 5 comments
Labels

Comments

@sneko
Copy link

sneko commented Sep 8, 2021

Description

Hi,

I have multiple pages using fullPage.js on a Single Page Application, so when I leave a page I destroy the fullPage.js instance and I init a new fullPage.js instance on the new page. This works great... but:

The menu I specified into your plugin (it could have been a fixedElements) seems to be put outside the fullPage element by your plugin, and set just under the body in the DOM tree. My issue with that is when I delete the instance, this element remains. So after I navigate to another page, the menu will be recreated over and over... stacking them up.

It's a memory leak issue (guessing a user would switch pages the website for too long), but also, that's the older menu that is over all others, so since I change menu style depending on the current page, I won't see changes.

I hope I'm clear enough 😄 , maybe I'm doing something wrong?

Thank you,

@alvarotrigo

EDIT:
Note that I tried both destroy() and destroy('all')

@sneko
Copy link
Author

sneko commented Sep 8, 2021

@alvarotrigo please see the reproductible example on https://codepen.io/sneko7/pen/VwWPyaZ

After clicking "Destroy" the DOM outside the plugin element remains:
image

@alvarotrigo
Copy link
Owner

Thanks for reporting it!
It seems like this is something that has to be dealt with inside the destroy method. It should be moving the menu back where it initially was: inside the full-page wrapper.

I guess that should solve your issue?

@alvarotrigo alvarotrigo added the bug label Sep 8, 2021
@sneko
Copy link
Author

sneko commented Sep 8, 2021

@alvarotrigo yes indeed, it would solve the issue 😊

@alvarotrigo
Copy link
Owner

alvarotrigo commented Sep 20, 2021

@sneko would moving it outside of the fullpage.js wrapper be enough?

@sneko
Copy link
Author

sneko commented Sep 21, 2021

@alvarotrigo you mean I set by default my menu outside the wrapper so it's never moved?

I think in my case it would solve the issue because there would be no replication at each initialisation of the plugin, but guess someone use fixed elements into nested components for some reason, it's pretty hard for this kind of user to "move it up" in the elements tree.

But indeed if I'm the only one facing this kind of issue, I guess I'm fine with that (and no need to rework a piece of the logic for fixed elements) 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants