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

Replace node mutation by WeakMap #326

Closed
Grsmto opened this issue May 20, 2019 · 3 comments
Closed

Replace node mutation by WeakMap #326

Grsmto opened this issue May 20, 2019 · 3 comments

Comments

@Grsmto
Copy link
Owner

Grsmto commented May 20, 2019

As discussed there it would be better to use a WeakMap to keep track of SimpleBar instances instead of mutating the nodes elements.

We also need to add a static helper to retrieve the SimpleBar instance (that will now sits at SimpleBar.instances.get(el)).

cc @andersk

@andersk
Copy link
Contributor

andersk commented May 20, 2019

Sounds good to me. Let's give the static helper a short name since Simplebar.instances.get(el).getScrollElement() is quite a mouthful. Maybe SimpleBar.of?

@Grsmto
Copy link
Owner Author

Grsmto commented May 20, 2019

Yeah definitely.
I liked the SimpleBar.ofElement that you proposed before. Makes it clear what type of parameter it's expecting.

@andersk
Copy link
Contributor

andersk commented May 20, 2019

ofElement is more explicit, but I’m trying to imagine typical use cases like

SimpleBar.ofElement(document.getElementById("pane")).getScrollElement().addEventListener("scroll", () => {
    
})

and wondering whether the extra word is actually worth the extra horizontal space, when there’s not really anything else that you could take the SimpleBar of. Your call though.

@Grsmto Grsmto closed this as completed Nov 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants