Simplebar: Destroying the object

Created on 28 Mar 2018  路  7Comments  路  Source: Grsmto/simplebar

Hey! You've done a great job and I'd like to thank you for that. Cool stuff, much better than all those other plugins that affect the actual scrolling performance (on some devices though). But.... I'm lacking a nice destroying function, that will revert the DOM structure to its initial state - without _"simplebar-xxx"_ containers. Perfect-scrollbar has that option actually.

Had to create some 'dirty' workaround....

Looking forward to your respond ;)

P.S. unmount() doesn't solve the problem I described

enhancement

Most helpful comment

So funny, just came here looking for the same, sort of "destroy" function and this is actually an on-going conversation haha.

I was looking for a destroy function because the parent container of the scroll area has an arrow for collapse and expand the container, after collapse it, when I open the container, the scrollbar of simplebar remains hidden, don't know why, so I was trying to "destroy" when collapsing and "initialize" simplebar when expanding the parent.

All 7 comments

Hey @apopelyshev thanks for your kind words.
Some users have asked for the same thing but I don't think it's a good idea to implement such a thing because it will add a lot of code for an edge case.
Can I ask what is your use case and why you need to get the original DOM element back to how it was before?
I guess if I get a proper use case I can understand better why some users want to do that and how we can find a workaround.

Well....in my case I think it's more bout aesthetics. I have an expandable absolutely positioned container which serves more as a 'dialog-box' with some overflowing content (a long list of entries). I have my CSS-animations set and some JS also. It's just .... I don't really need those _simplebar-content_ inside _simplebar-scroll-content_ in a small, non-expanded version (I limit the number of displaying list items instead)

It's not a problem at all. I kinda don't like everything being 'containered' when it's not needed (in my particular project)

Ok got it.
Yes that's one of the quirks of SimpleBar compare to other libraries: you get DOM alterations/more DOM elements versus simulating the scroll event with JS. The idea of SimpleBar is that the number of DOM elements and the JS happening there is still more performant than the alternatives. But maybe if you have a lot of instances that can be a problem.

I know DOM alteration to init SimpleBar causes lot of other problems with unmounting and also cross compatibility with other plugins/frameworks. I should probably document that in a "quirks" section!

To come back to this issue specifically, I think that's something that could be implemented if it's not too much code.
I took a look a other plugins and it seems like some are having this feature like Siema carousel for example.

So funny, just came here looking for the same, sort of "destroy" function and this is actually an on-going conversation haha.

I was looking for a destroy function because the parent container of the scroll area has an arrow for collapse and expand the container, after collapse it, when I open the container, the scrollbar of simplebar remains hidden, don't know why, so I was trying to "destroy" when collapsing and "initialize" simplebar when expanding the parent.

@juanpablob sounds like an interesting issue. Maybe open a new issue and if you can provide a jsfiddle showing the issue that would be awesome! (you can use this as a start point https://jsfiddle.net/Grsmto/57obe5w2/1/ )

Thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

barnu5 picture barnu5  路  5Comments

FuturFuturFutur picture FuturFuturFutur  路  4Comments

luky1984 picture luky1984  路  5Comments

Grsmto picture Grsmto  路  7Comments

adjourn picture adjourn  路  6Comments