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

Throttle recalculations (v2) #40

Closed
ineentho opened this issue Nov 2, 2016 · 4 comments
Closed

Throttle recalculations (v2) #40

ineentho opened this issue Nov 2, 2016 · 4 comments

Comments

@ineentho
Copy link

ineentho commented Nov 2, 2016

What are your thoughts on throttling recalculations triggered by the mutation observer? I have a element which triggers the recaluclation ~ 1000 times before it's done and it's of course killing the performance.

@Grsmto
Copy link
Owner

Grsmto commented Nov 2, 2016

Definitely something needed.
Also I think about letting the user disable the mutation observer if needed for scenarios where perfs matters more.

Can I ask what is your use case so I can understand better the kind of scenario where this could be needed?
Thanks for this

@ineentho
Copy link
Author

ineentho commented Nov 2, 2016

Our use case is quite simple: We have a long scrollable list of items where items are added one by one through appendChild. Most are added at load time, but more are removed and added dynamically afterwards too.

Temporarily disabling the mutation observer while loading the initial batch of items would probably work great too.

@Grsmto
Copy link
Owner

Grsmto commented Nov 2, 2016

Ok thanks very much for that. I'll try to setup a similar scenario so I can test it, seems like a quite common use case (infinite scroll...etc).
The calculation is reading height, scroll position and other stuff so I guess it can be quite performance heavy as well. Probably need some improvements. But I'm sure the debouncing should solve 99% of the issues!

@ineentho
Copy link
Author

ineentho commented Nov 7, 2016

Thanks for the quick update! It works great now :)

@Grsmto Grsmto closed this as completed Nov 13, 2016
Grsmto pushed a commit that referenced this issue Dec 18, 2016
* v2: (50 commits)
  2.0.0
  fix a bug where querySelectorAll is not always an Array (on IE11 for ex)
  after adding of new `enabled` prop Simplebar wasn't working anymore
  add a forceEnabled option to force simplebar to be active even if it's not needed
  refactor static properties as static getters
  Add an `enabled` prop to know if Simplebar is active or uses floating scrollbar (fix #42)
  Update README.md
  Update README.md
  2.0.0-beta.3
  add function to remove mutation observer
  define html api init as static of SimpleBar class
  debounce recalculate function to improve performances (fix #40)
  improve demo with more usecases
  remove useless css selector + scroll to auto
  remove useless line
  fix scrollbar appearant when content is not wide enough to overflow (fix simplar on some layouts)
  fix mouting/unmounting of Simplebar when removed and added back to the DOM
  Update README.md
  2.0.0-beta.2
  MutationObserver now works if the simplebar div itself is deleted too (regression)
  ...

# Conflicts:
#	README.md
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