tiny-slider icon indicating copy to clipboard operation
tiny-slider copied to clipboard

mousedragging opens lightbox

Open dijkermans opened this issue 3 years ago • 3 comments

Hi,

When using a lightbox, it opens when you mousedrag a slide. It should only open when you click. It works fine with Owl.

I'm using Tiny Slider with Lightgallery but it also happens with Ekko Lightbox, so it seems to be an issue with Tiny Slider.

Example:

https://codepen.io/TOUnail/pen/EeyGOO

This problem doesn't occur with Owl.

Any idea how to solve this?

tns 2.9.3

dijkermans avatar Feb 11 '22 09:02 dijkermans

Seems to be an old unfixed issue: https://github.com/ganlanyuan/tiny-slider/issues/360 https://github.com/ganlanyuan/tiny-slider/issues/189

dijkermans avatar Feb 11 '22 20:02 dijkermans

Normally this would have been a good workaround, but unfortunately, dragStart and dragMove are triggered on mousedown without moving.

slider.events.on('dragStart', function () {

document.body.classList.add('drag');

});

slider.events.on('dragEnd', function () {

document.body.classList.remove('drag');

});

.drag .slider .tns-item a { pointer-events:none }

dijkermans avatar Feb 16 '22 12:02 dijkermans

You can use custom events of tiny slider to track mouse drag. Something like this:

var dragMove = false;
slider.events.on('dragEnd', function (info) {
    dragMove = false;
});
slider.events.on('dragMove', function (info) {
    dragMove = true;
});

And check this variable before lightbox usage In this way you can understand is it normal click or slider drag

UPD: ⚠️ Be careful of use dragEnd, because this event is not fired when curson returns to exactly same place after dragMove

rozaljkeee avatar Mar 03 '22 13:03 rozaljkeee