OverlayScrollbars
OverlayScrollbars copied to clipboard
Using Vue OverlayScrollbarsComponent.osInstance() got null
This is the first time that I've applied OverlayScrollbars to my Vue project, and now I've got a little problem
The version I use is: overlayscrollbars: ‘1.13.1’ overlayscrollbars-vue: '0.2.2'
Before using it, I looked up the official example: https://github.com/KingSora/OverlayScrollbars/blob/master/packages/overlayscrollbars-vue/example/src/App.vue
I want to change the scroll of overlay scrollbars. First, I call osinstance () to get the instance, but when I use this method, it returns a null
Can you take a look for me?
When osinstance () returns null
If there is anything wrong with me, I hope you can point it out. Thank you very much for your help
Tips: English is not my native language; please excuse typing errors.
Good day @HaceraI!
Please create a small example of your problem in CodeSandbox or StackBlitz. I can't spot anything wrong in your provided screenshots.
@KingSora This is the CodeSandbox link: https://codesandbox.io/s/nifty-framework-4ubb8?file=/src/App.vue:2248-2293 Of course, I also created the corresponding warehouse in GitHub: https://github.com/HaceraI/OverlayScrollbars-vue-example
I seem to have found the reason If I don't add judgment, the first time. scroll() will report an error, and then the entire. osInstance() will get null
At present, I add if judgment to the place where. Scroll() is used.
If you want to see the abnormal effect, you can try to remove lines 90 and 92
Thank you very much for helping me
Thanks!
I got the issue, but I'm not sure why it happens yet. You see, the osInstance
is available after the mounted
lifecycle method, but for some reason I don't know yet the onContentSizeChanged
callback is called before that. Thats also why your if
condition is fixing it.. I'll look deeper into it as soon as I have a bit more time. You can check this behavior yourself by placing a console.log
in the mounted
method like I did here: https://codesandbox.io/s/epic-galois-2glbm?file=/src/App.vue
overlayscrollbars
v2
released today and with it a new version of overlayscrollbars-vue
where this issue should be fixed