|
|
@@ -100,15 +100,15 @@ this.singlefile.ui = this.singlefile.ui || (() => {
|
|
|
|
|
|
function getTarget(event) {
|
|
|
let newTarget, target = event.target, boundingRect = target.getBoundingClientRect();
|
|
|
- newTarget = determineTargetElement(target, event.clientX - boundingRect.left, getMatchedParents(target, "left"));
|
|
|
+ newTarget = determineTargetElementFloor(target, event.clientX - boundingRect.left, getMatchedParents(target, "left"));
|
|
|
if (newTarget == target) {
|
|
|
- newTarget = determineTargetElement(target, boundingRect.left + boundingRect.width - event.clientX, getMatchedParents(target, "right"));
|
|
|
+ newTarget = determineTargetElementCeil(target, boundingRect.left + boundingRect.width - event.clientX, getMatchedParents(target, "right"));
|
|
|
}
|
|
|
if (newTarget == target) {
|
|
|
- newTarget = determineTargetElement(target, event.clientY - boundingRect.top, getMatchedParents(target, "top"));
|
|
|
+ newTarget = determineTargetElementFloor(target, event.clientY - boundingRect.top, getMatchedParents(target, "top"));
|
|
|
}
|
|
|
if (newTarget == target) {
|
|
|
- newTarget = determineTargetElement(target, boundingRect.top + boundingRect.height - event.clientY, getMatchedParents(target, "bottom"));
|
|
|
+ newTarget = determineTargetElementCeil(target, boundingRect.top + boundingRect.height - event.clientY, getMatchedParents(target, "bottom"));
|
|
|
}
|
|
|
target = newTarget;
|
|
|
while (target && target.clientWidth <= SELECT_PX_THRESHOLD && target.clientHeight <= SELECT_PX_THRESHOLD) {
|
|
|
@@ -209,7 +209,14 @@ this.singlefile.ui = this.singlefile.ui || (() => {
|
|
|
return parents;
|
|
|
}
|
|
|
|
|
|
- function determineTargetElement(target, widthDistance, parents) {
|
|
|
+ function determineTargetElementCeil(target, widthDistance, parents) {
|
|
|
+ if (Math.ceil(widthDistance / SELECT_PX_THRESHOLD) <= parents.length) {
|
|
|
+ target = parents[parents.length - Math.ceil(widthDistance / SELECT_PX_THRESHOLD) - 1];
|
|
|
+ }
|
|
|
+ return target;
|
|
|
+ }
|
|
|
+
|
|
|
+ function determineTargetElementFloor(target, widthDistance, parents) {
|
|
|
if (Math.floor(widthDistance / SELECT_PX_THRESHOLD) <= parents.length) {
|
|
|
target = parents[parents.length - Math.floor(widthDistance / SELECT_PX_THRESHOLD) - 1];
|
|
|
}
|