Prevent link opening while mobile scrolling in scrollarea

  • Hi Klaus,
    hi Forum,

    there is something I can't find a solution for.

    I use a textlayer with layertype scrollarea. There is a long text with some links in this scrollarea.

    On mobile device one tends to just touch anywhere in the area and swipe there to scroll up or down.
    Unfortunately it often happens that you touch a link. What happens is that as soon as you release your finger from the screen the link will be opend.

    Is there any way to prevent opening of links when these are just touched while swiping for scrolling a scrollarea?

    I could think of replacing the links with some onclick action like openlink("http://foo.bar") and have a test in that action if scrolling/touching is active - however I don't know how to test that for a scrollarea.

    Thanks for any input!

    Best wishes
    Stefan

    2 Mal editiert, zuletzt von s-maier (11. August 2023 um 20:02)

  • So here is my temporary solution - until someone comes up with something better:

    1. Set scrolling() function as onscroll attribute in scrollarea layer

    Code
    <layer name="scrollarea"
    	type="scrollarea"
    	...
    	onscroll="scrolling()"
    	...
    </layer>

    2. Copy millisecond "timestamp" into variable last_scroll on every scroll movement in the scrolling() function

    Code
    <action name="scrolling">
    set(last_scroll, *timertick);
    </action>

    3. Replace link in the text with onclick="open_link(http://foo.bar)" in the scrollarea text.
    Whenever the "link" is touched this function compares the current timestamp to the timestamp of the last onscroll trigger and opens the link if the diffrence is greater than 2. This means that it could not have been touched unintenionally while scrolling as the diffrence would be 0 than.

    Code
    <action name="open_link">
    calc(scroll_div, timertick - last_scroll);
    if (scroll_div GT 2, openurl(%1));
    </action>

    If anyone (especially Klaus) has a better solution please let me know!

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!