I am in the process of adding a "resize handle" to adjust the width of my left navigation panel. This handle, represented by a div
, triggers an onMouseDown()
event that calculates the necessary widths and applies them to the relevant elements during subsequent calls to onMouseMove()
. However, I am experiencing some issues.
1) The article
element, located to the right of the navigation panel and handle, fails to trigger the onMouseUp()
event when I release the mouse there. Could this be due to the initial activation of onMouseDown()
in another element?
2) If I move the mouse rapidly to the right, I am unable to prevent text within the article
from being selected, despite attempts to use methods like preventDefault()
and stopPropagation()
.
3) Even if there is no text present in the article
, the resizing functionality only works effectively when the mouse is moved very slowly. Moving the mouse swiftly over the article
results in the resizing stopping abruptly unless the mouse button is released – in such cases, the resizing proceeds smoothly (implying that text selection was hindering the process even when no text was present). However, upon releasing the mouse button, the resizing should ideally cease (refer to point 1).
I have come across suggestions involving CSS properties like user-select: none
, but implementing these would indiscriminately prevent text selection within the article
, which seems excessive.
Hence, how can I achieve seamless resizing without inadvertent text selection while moving the mouse across any element within my document? (Following the initial click within the right div
, of course.)
The following snippets showcase my HTML, CSS, and JavaScript code for reference:
To view the complete code and a functional example, please visit:
<a href="https://jsfiddle.net/45h7vq7u/" rel="nofollow noreferrer">Resize Handle Example</a>
<a href="https://jsfiddle.net/v1cmk2f6/1/" rel="nofollow noreferrer">Additional Implementation Example</a>