is there an "isMounted" property / mount() called on a Glide object thats already mounted causes slides to duplicate
See original GitHub issueDoesn’t seem like it. As per multiple issues re: the calculation of the layout during paint (my comments: https://github.com/glidejs/glide/issues/508#issuecomment-687353604), I just want to construct and mount my Glide slider once after a bootstrap modal has fired the “shown” event. As per https://github.com/glidejs/glide/issues/376, doing a destroy() on the “hidden” event causes subsequent errors for “this.listeners is undefined”:
Uncaught TypeError: this.listeners is undefined
node_modules glidejs/glide/dist/glide.esm.js?:1950
node_modules glidejs/glide/dist/glide.esm.js?:2005
node_modules glidejs/glide/dist/glide.esm.js?:2014
node_modules glidejs/glide/dist/glide.esm.js?:555
node_modules glidejs/glide/dist/glide.esm.js?:554
node_modules glidejs/glide/dist/glide.esm.js?:698
It got me thinking that I really only need to mount it once, because if they open/close it’ll be the same slider, whatever. Of course, calling mount() on a slider thats already been mounted causes it to double its slide clones and screw up the index/order of the slides. So there’s nothing in mount() to check to see if a Glide object is initialized, and there doesn’t seem to be anything through a console.log dump that jumps out as an “is mounted” property. For my purposes, a local variable is sufficient, but it seems odd that I wouldn’t be able to access a Glide object and have access to whether or not its mounted - makes it hard to grab that stuff dynamically, and it seems like the base implementation of mount() could really benefit from being able to access that property and choose whether to mount or not.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:5 (2 by maintainers)
Top GitHub Comments
Thanks for the info @jedrzejchalubek, much appreciated and fully understand!
@tomgreenhill Yeah, trying to keep Glide as much agnostic to single-use cases as it can be and provide tools to control it outside (the term for that is IoC). If something can be easily done via API it should not be a part of the core.
It is easy to add it, but this part of the code will be needless for 90% of other folks that use Glide and only add weight to its scripts 😃