Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimization #98

Merged
merged 1 commit into from
May 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions src/services/detection-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,21 @@ const getMouseDownOnHandle = (
resizable: ResizableModel,
vertical: boolean,
registerResizeEvent: any) => (e: any) => {
const {detectionDetails: detectionCoordinate} = resizable
const {detectionDetails} = resizable

const cursorCoordinate = vertical ? e.clientX : e.clientY

const resizerClickedCoordinateList = []
for (let i = 0; i < detectionCoordinate.length; i++) {
const [x1, x2] = detectionCoordinate[i]
const resizerClickedCoordinateList = detectionDetails.map(([x1, x2]) => {
const coordinates = Math.abs(((x1 + x2) / 2) - cursorCoordinate)
resizerClickedCoordinateList.push(coordinates)
}
return coordinates
})

const copyForSort = sortNumber(resizerClickedCoordinateList)

const closestCoordinate = copyForSort.pop()

const closestIndex = resizerClickedCoordinateList.indexOf(closestCoordinate)
const [x1, x2, handleId] = detectionCoordinate[closestIndex]
const [x1, x2, handleId] = detectionDetails[closestIndex]
if (closestCoordinate <= ((x2 - x1) / 2)) {
resizable.previousTouchEvent = e
const resizableEvent = getResizableEvent(e, vertical, {})
Expand All @@ -68,12 +67,11 @@ const onContainerMouseMove = (
const {detectionDetails} = resizable
const cursorCoordinate = vertical ? e.clientX : e.clientY
element.style.cursor = 'auto'
for (let i = 0; i < detectionDetails.length; i++) {
const [x1, x2] = detectionDetails[i]
detectionDetails.forEach(([x1, x2]) => {
if (cursorCoordinate >= x1 && cursorCoordinate <= x2) {
element.style.cursor = cursorStyle
}
}
})
}

const getResize = (resizable: ResizableModel, vertical: boolean) => (e: any) => {
Expand Down
Loading