Skip to content

Commit

Permalink
Merge pull request #177 from epam/EPMUII-8057-delete-annotation-impro…
Browse files Browse the repository at this point in the history
…vements

EPMUII-8057-delete-annotation-improvements
  • Loading branch information
oleksandr-zhynzher authored Oct 26, 2023
2 parents 87f732b + 4097e09 commit 41d5bfb
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/engine/utils/PointerChecker.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
*/
class PointerChecker {
static isPointerOnLine(vs, ve, vScr) {
// The distance to the line by "x" and "y"
const MIN_DIST = 10;
// Define the center point of the line by "y" coordinate
const centerLineY = (vs.y + ve.y) / 2;
// Define the angle slope of the line
Expand All @@ -21,22 +23,20 @@ class PointerChecker {
const b = vs.y - m * vs.x;
// Define the length of the line by "y"
const widthY = Math.abs(ve.y - vs.y);
// Define the distance to the line by "y"
const MIN_DIST_Y = 10;
// Check if the point is on the border of the line
if (
vs.x != ve.x &&
(vs.x < ve.x ? vScr.x >= vs.x && vScr.x <= ve.x : vScr.x <= vs.x && vScr.x >= ve.x) &&
Math.floor(vScr.y) >= Math.floor(m * vScr.x + b) - MIN_DIST_Y &&
Math.floor(vScr.y) <= Math.floor(m * vScr.x + b) + MIN_DIST_Y
Math.floor(vScr.y) >= Math.floor(m * vScr.x + b) - MIN_DIST &&
Math.floor(vScr.y) <= Math.floor(m * vScr.x + b) + MIN_DIST
) {
return true;
}
// Check if the point is on the border of the vertical line
if (
vs.x === ve.x &&
vScr.x <= vs.x + 10 &&
vScr.x >= vs.x - 10 &&
vScr.x <= vs.x + MIN_DIST &&
vScr.x >= vs.x - MIN_DIST &&
vScr.y >= centerLineY - widthY / 2 &&
vScr.y <= centerLineY + widthY / 2
) {
Expand Down

0 comments on commit 41d5bfb

Please sign in to comment.