pressAndHold icon indicating copy to clipboard operation
pressAndHold copied to clipboard

Mobile not works

Open appfood opened this issue 4 years ago • 3 comments

Testing in Safari from iPhone, not work.

appfood avatar Apr 11 '20 01:04 appfood

I have same issue with mobile. tested in google chrome.

Geosysir avatar Feb 16 '23 08:02 Geosysir

I fixed my problem by mimicking mousedown and mouseup events with touchstart and touchend events on target element.

$(".target").on('touchstart', function(){
    $(this).trigger("mousedown");
});
$(".target").on('touchend', function(){
    $(this).trigger("mouseup");
});

Geosysir avatar Feb 16 '23 09:02 Geosysir

You need to do a little more than that, because long presses on mobiles are basically right clicks. There's a mouseexit event too, that you need to replace.

Suggest to use pointerdown, pointerup, pointerout instead, that'll be a way cleaner solution.

jackie-t avatar Jun 23 '23 10:06 jackie-t