Pageable icon indicating copy to clipboard operation
Pageable copied to clipboard

Links inside pages not working with touch devices

Open robindevouge opened this issue 6 years ago • 12 comments
trafficstars

Hi!

I noticed that with a touch input (either with a mobile device or Chrome responsive emulation) clicking on a link doesn't work unless you "double touch" it.

However, this doesn't happen if you set touch events to false on initialisation, so I thought this was caused by Pageable catching the touch to swipe thus preventing to trigger the link's.

This behaviour can be replicated in the playground by replacing a page text with a link while in responsive mode in chrome.

If anyone else reading this is affected by this issue and looking for a temporary solution : I fixed it with some JS by adding a listener on the affected links that redirects to their url but that isn't ideal

Array.from(document.querySelectorAll('.myLink')).forEach((el) => {
  el.addEventListener('touchend', () => {
    window.location.href = el.href;
  });
});

robindevouge avatar Jan 29 '19 17:01 robindevouge

I'm also having this issue.

I've had to add in some extra buttons that appear on touch devices to get around this bug for now.

conhuynh avatar Feb 22 '19 03:02 conhuynh

I'll get a fix out for this ASAP.

Mobius1 avatar Feb 22 '19 10:02 Mobius1

Confirm the same problem first comment was very helpful

GiorgosK avatar Mar 19 '19 12:03 GiorgosK

A fix should be out soon.

Mobius1 avatar Mar 19 '19 16:03 Mobius1

fixed that after commented this two strings 1

ValeriiMetlenok avatar May 16 '19 02:05 ValeriiMetlenok

fixed that after commented this two strings 1

Works great with it!!

arnulphus avatar Jun 27 '19 22:06 arnulphus

fixed that after commented this two strings 1

It does work but it makes the animation glitch, as if you could scroll freely. Personally as quick fix I wrote an if statement around these preventDefault statements to exclude buttons/links.

StevenJW avatar Aug 02 '19 11:08 StevenJW

This is some solution @ValeriiMetlenok thanks for that! @Mobius1 - thanks for the script anyway - very useful :) Is there a chance for a real solution anytime soon?

piotrku avatar Aug 08 '19 12:08 piotrku

Same trouble on inside scroll and buttons. NAV container works fine...

aleksandrp avatar Sep 07 '21 12:09 aleksandrp

The version 0.6.8 almost solved this problem, to solve this problem completely it is necessary replace (on "_start" method):

this._preventDefault(a) for (b.target.closest("a") || this._preventDefault(a))

@Mobius1

rauny-henrique avatar Oct 18 '21 13:10 rauny-henrique

Desperately wanted @ValeriiMetlenok 's function to work, but it completely broke scrolling as @StevenJW said. @robindevouge 's solution takes you to the link even if you are trying to move between pages. This should detect drag and only take you to links if there is no drag.

var isDragging = false;
jQuery(window)
.touchmove(function(e) {
    isDragging = true;
 })
.touchend(function(e) {
    var wasDragging = isDragging;
    if (!wasDragging) {
    window.location.href = jQuery(e.target).attr("href");
    }
    isDragging = false;
});

teddyh-io avatar Jul 22 '22 02:07 teddyh-io

Screen Shot 2023-03-25 at 15 47 10

You can add in a checks on the e.target.nodeName to ignore those elements e.g inputs and links, seems to work for me

juniorrumbelow avatar Mar 25 '23 15:03 juniorrumbelow