Owlcarousel2: Click event wont trigger after touchdrag

Created on 3 May 2017  路  11Comments  路  Source: OwlCarousel2/OwlCarousel2

When a slide has been changed , the user can click the current slide to submit this slide.

Problem is however that the click event wont trigger the first time when a touchswipe / touchdrag has been done only the second time the user clicks it will trigger.

On desktop everything works fine, it only occurs when I set Chrome to mobile or open the site on a phone, so It must be an issue / bug from Owl Carousel right?

Because it looks like the touch wont stop untill there has been a click.

Click event:
$('#owl-example').on('click', '.emoji', function () {};

Carousel itself:
https://pastebin.com/bejSU9GN

Could someone please help me out?

Most helpful comment

This is an Owl Carousel bug.
You can correct it by editing dist/owl.carousel.js line 821.

Original:

if (Math.abs(delta.x) > 3 || new Date().getTime() - this._drag.time > 300) {

Bug fix:

if ((Math.abs(delta.x) > 3 || new Date().getTime() - this._drag.time > 300) && event.type === 'mouseup') {

All 11 comments

This is an Owl Carousel bug.
You can correct it by editing dist/owl.carousel.js line 821.

Original:

if (Math.abs(delta.x) > 3 || new Date().getTime() - this._drag.time > 300) {

Bug fix:

if ((Math.abs(delta.x) > 3 || new Date().getTime() - this._drag.time > 300) && event.type === 'mouseup') {

thnks worked! Can this bug be fixed in the min.js?

Thanks a lot for this!

is this code pushed to the latest version?

@jdx10 's fix fixed the issue for me.

This works for me too. Did a search and seems no one made a pull request for this. I will create one.

Actual fix for owl.carousel.min.js
Original:
(Math.abs(d.x)>3||(new Date).getTime()-this._drag.time>300)
Bug fix:
((Math.abs(d.x)>3||(new Date).getTime()-this._drag.time>300)&&e.Type==="mouseup")

Fix needs to be improved as when flipping occurs click.

Hi @cakama3a , Seem, this bug is still exist on version 2.3.4.
I didn't see codes:
Actual fix for owl.carousel.min.js
Original:
(Math.abs(d.x)>3||(new Date).getTime()-this._drag.time>300)
Bug fix:
((Math.abs(d.x)>3||(new Date).getTime()-this._drag.time>300)&&e.Type==="mouseup")

work done, thanks everyone

Fix needs to be improved as when flipping occurs click.

When I use that fix in non compressed file it works fine, but in owl.carousel.min.js it occurs click event while flipping

Was this page helpful?
0 / 5 - 0 ratings

Related issues

siwel picture siwel  路  3Comments

SimonHarte picture SimonHarte  路  3Comments

JezCheese picture JezCheese  路  3Comments

Laraveldeep picture Laraveldeep  路  3Comments

hemanthsp picture hemanthsp  路  3Comments