setTimeout() not working on Samsung devices


#1

Hi there.

I have a strange behaviour happening on Samsung devices. I have an ion-slides with some slides inside. In each slide i have some buttons i want to drag and drop. All works fine on browser, iOS or any other android device but not on Samsung. i have a setTimeout() function which is not called at all. If i connect the device to the pc and use chrome inspect to debug, it starts to work.

Here is the piece of code which has the problem. The touchstart event is fired and the code inside is executed.

This is the link for the directive I used.

https://github.com/cormacrelf/dragula-touch-demo/blob/master/src/app/delay-drag.directive.ts

@HostListener('touchstart', ['$event'])
  private onTouchStart(evt: Event): void {
    this.touchTimeout = setTimeout(() => {
      this.draggable = true;
    }, this.delay);
  }

Help is much appreciated. Thank you


#2

I don’t know what’s going on specifically, but I avoid setTimeout() because it can have different behavior on different platforms (and in different runs on the same platform). What do you want to achieve there? It might be possible to do without setTimeout().


#3

I am using dragula to drag and drop items in one slides. But when I press an item, and start dragging it, on release, the change slide event is called and it will change the slide. This directive fixed the issue but it caused the other issue with samsung devices. I tried using the press gesture to avoid using setTimeout(). But dragula is disabled after the press event is fired. Dragula has a press time after which it will not respond on touch devices, so since dragula does not have a default timeout to be launched, I found this directive to achievethe desired functionality. On desktop you can click and hold for as long as you want and still be able to drag. This dragula issue was fixed in an older version but I think they removed it.
Since i found no solution to this,I figured that the Ionic forum would be of help.