Closed sumitmann closed 5 years ago
You could just add a EventListener to the slide with an ID, this would work I guess?
Yes I could, but i wanted an event which get triggered only when there is no dragging. With current version of 'lory' if i add a click event listener to do some stuff then it'll get triggered every time i click and drag mouse on slider.
I had the same problem and solved it with the following code:
LORY_CLASS_NAME_FRAME_ELEMENT.addEventListener('click', function (e) {
if (!e.defaultPrevented) {
// This is a real click, because lory has called e.preventDefault();
// This happens in https://github.com/meandmax/lory/blob/81de415866d0e8723928a909a05c624341c93eba/src/lory.js#L538
// You have to set enableMouseEvents = true for this to work
} else {
// This is a drag/move event
}
});
Important
You have to add your event listener after you initiated lory. Otherwise your event handler is called, before lory can call e.preventDefault();
@christoph-bessei thank you for your contribution to this issue - closing it. @sumitmann If you can provide an example/demo of what you are having trouble with people can better assist you in helping with the solution.
Hi
Thanks for this awesome sliders. I tried lots of sliders including 'lory' but no one has the feature to attach click event to 'js_slide'. I wonder if there is a possibility to add something like 'on.lory.click' so that custom click events can be attached to individual slide.
Thanks a lot!