Closed anakinjay closed 6 years ago
Thank you. I didn't though about the static attach method. I'm currently rewriting the source and then I'll integrated your proposal into it.
Hi, this error occurs on version 2.2.0 again...
@alexssandrog please give me more details because the code has been totally refactored and this issue has taken into account many points.
And please try last release v3.0.0
Tks, v3.0.0 build perfectly!!!
Perfect 😊
Only tested with angular, but this should probably fix integration with other frameworks like vue and react as well. One big caveat to this is I removed the on dom ready auto-attachment. Frameworks like angular and react (and I think vue?) have their own shadow dom that is a separate ready event. Adding this method lets you attach when your framework of choice is ready.
The downside is if you're not using a framework like these, you'll have to manually call Carousel.attach() after loading the script on the page.
Also sorry for all the formatting changes, my code editor reformats automatically and I didn't even think about it before I worked through the changes.
Main Changes:
Added static attach method to attach the carousel instead of just auto-attaching at run time. This is allows angular to re-attach if it dynamically changes the carousel items.
Added 100ms buffer to the element attachment (in the static attach method). For some reason in angular, things were just flying too fast, and it would try to attach before angular was finished with the dom.
Line 221 had this:
which I'm pretty sure was a bug, if items has 1 element, it matches that statement, but then you're setting to items[1] which would fail and cause issues when applying classes to null items.
should definitely fix #27 , potentially fixes or related to #30