simplebar icon indicating copy to clipboard operation
simplebar copied to clipboard

Disable Auto init from DOM

Open Nicolai8 opened this issue 3 years ago • 2 comments

I'm mainly using simplebar-react, but in one specific case I also have to initialize simplebar via vanila JS package.

Before extracting simplebar-core as separate everything was working fine because of SimpleBar.instances check. But right now I'm getting 2 scrollbars instead of 1.

So, is it possible to add an option to disable auto init from DOM elements? or disable MutationObserver after initialization?

Nicolai8 avatar Feb 17 '23 14:02 Nicolai8

Hi @Nicolai8 I see how that can be an issue with the latest version. Maybe you can try adding data-simplebar="init" to the element that gets instantiated 2 times, it should prevent the vanilla SimpleBar from instantiating again. Let me know if that works!

Grsmto avatar Feb 17 '23 15:02 Grsmto

Sorry, I reverted back to previous version and completely forgot about the raised issue on the GitHub.

Was trying recently to update lib again. There are few things with data-simplebar="init" approach:

  1. I can't add it to the <SimpleBar /> react component because in the Observer watcher it will trigger new instance initiation without check if it's initialized or not
  2. so, I have to wrap <SimpleBar /> with <div data-simplebar="init" /> - this fix an issue visually, but: *also generates massive amount of unnecessary HTML: image
  • have to rework, some components

Nicolai8 avatar Oct 20 '23 10:10 Nicolai8