Splide is creating a large sum of event listeners
Checks
- [X] Not a duplicate.
- [X] Not a question, feature request, or anything other than a bug report directly related to Splide. Use Discussions for these topics: https://github.com/Splidejs/splide/discussions
Version
4.1.4
Description
If multiple Splide instances are created on a page, Splide creates multiple events for every instance. Can all instance events be grouped to a single event type?
Example code that could fix the issue
type ResizeEventCallback = () => void
const onResizeEvents: ResizeEventCallback[] = [];
window.addEventListener('resize', () => {
onResizeEvents.forEach(callback => callback());
})
const useScreen = () => ({
onResize(callback: ResizeEventCallback) {
onResizeEvents.push(callback);
}
});
const { onResize } = useScreen();
onResize(() => {
// do some stuf
});
Reproduction Link
No response
Steps to Reproduce
Create mutliple Splide sliders
Expected Behaviour
Splide creates a single event listener for all Splide instances of that event type.
I think this might be an issue with how you're creating your keydown event listener and not with Splide.
I think this might be an issue with how you're creating your keydown event listener and not with Splide.
Can you elaborate a bit further?
Because I'm not creating any keydown event-listeners in my code.
When I check the event origin, the keydown events are created by the splide esm bundle.