HugoFara / lwt

Learn languages by reading! A language learning app stemmed from Learning with Texts (LWT).
https://hugofara.github.io/lwt/
The Unlicense
168 stars 19 forks source link

Multi-word selection not possible on phone #142

Open HugoFara opened 1 year ago

HugoFara commented 1 year ago

This bug seems to affect all LWT version including 2.8.0, signaled on Discord.

After a quick search, the behavior of mword_drag_n_drop_select in jq_pgm.js may be wrong.

HugoFara commented 1 year ago

Based on https://stackoverflow.com/questions/51333798/how-can-i-make-mousedown-mouseup-trigger-on-mobile-devices and experiments with a nice user, we can trigger the event through:

$('#thetext')
.on('selectstart','span',false)
.on(
        'mousedown', '.wsty',
        {annotation: ANNOTATIONS_MODE}, 
        mword_drag_n_drop_select
).on(
        'touchstart', '.wsty',
        {annotation: ANNOTATIONS_MODE}, 
        mword_drag_n_drop_select
);

(in prepareTextInteractions).

More info incoming!

HugoFara commented 8 months ago

Hi again!

I have spent my day breaking my teeth on this issue as I wanted to "fix" before the next release. Unfortunately, that won't be so easy.

The main issue is that "click" event and "touch" events are not independent, but they do not constitute a subset of one another. Most devices trigger "mousedown" when "touchstart" is triggered, while some other interactions do not have an equivalent ("mouseenter" does not have a "touch" equivalent).

That being said, I started to develop a new system for multi-word that would be touch friendly on mobile-multi-word. The issue is that I cannot find a way to prevent the current interaction system to interfere. I think that the best solution is to redo the multi-word selection system from scratch.

As it is an important UX change, I hope to bundle it in LWT 3.0.0! See you later on!