First pass draggable touch handle on cursor #5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Touch-dragging over the editable box does not select, it moves the
cursor, and after you lift your finger, triggers the handle showing up,
and the cursor does doesn't blink, a la Android.
A mini-abstraction for one-finger touch events is created and used.
Handle Positioning
There appears to be no way for a descendant of an overflow:hidden
element to be "above" the clipping area, nor any CSS-only way to "lock"
the position of an element relative to another except its offset parent.
So the handle span has to be outside the overflow:hidden root block, and
has to be re-positioned with JS whenever the cursor moves.
The handle is rendered in pure CSS, no images, using pseudo-elements,
positioned relative to the handle span, which is always positioned so
its bottom lines up with the bottom of the cursor. This is nice because
the relative position of the handle and the cursor is entirely in CSS.
(An alternative I could see is making the cursor handle position:
absolute rather than relative, so I wouldn't need to measure its coords,
just its offset parent's. But then I'd either have to set the
.mathquill-editable
to position:relative so it'll be the offsetparent, potentially conflicting with a style set by the host page; or
insert the handle inside the
.textarea
span, but that's a conflationof purpose and while its purpose could be expanded, I was meaning to get
rid of it anyway, turns out setting position:absolute on the textarea
and leaving top and left as auto does exactly what I want.)
As an optimization, store current top and left rather than make DOM
measurements every time.