lecion / vue-perfect-scrollbar

scrollbar for vue, depend on perfect-scrollbar(https://github.com/noraesae/perfect-scrollbar)
244 stars 25 forks source link

How to destroy it temporary and restore later via property. #24

Open jsinhSolanki opened 5 years ago

jsinhSolanki commented 5 years ago

Hey, I have swtich to destroy perfect scrollbar. But I can not figure I out how can I implement this where I want to disable perfect scrollbar if switch's value is true and restore scrollbar if value is false.

don-boldyrev commented 5 years ago

the same question

lwxbr commented 5 years ago

@jsinhSolanki, my issue is similar of yours. I didn't found out how to access the perfect-scroll instance through vue-perfect-scroll to update it. If the component allow to access the instance directly or offering the methods of it, it would be easy to call the method destroy or update(in my case) to that: https://github.com/mdbootstrap/perfect-scrollbar#how-to-use

Edit: Reading the component, it is particularly easy to do that:

It is just passing a ref to the component like

<perfect-scroll ref="scrollbar"></perfect-scrollbar>

and in the code access it using:

this.$refs.scrollbar.reset(); // to reset
this.$refs.scrollbar.update() //to update
this.$refs.scrollbar.ps //to access the instance of the perfect-scrollbar