Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
BipanKishore committed May 12, 2024
2 parents 04d374e + 8ab0355 commit cd0c2a4
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 17 deletions.
1 change: 0 additions & 1 deletion src/components/pane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export const Pane = (props: IPane) => {
<div
className={classname}
data-cy={id}
key={id}
ref={setPaneRef}
style={style}
>
Expand Down
2 changes: 1 addition & 1 deletion src/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ export const EVENT_NAMES = {
mousedown: 'mousedown',
touchmove: 'touchmove',
touchend: 'touchend',
touchStartCapture: 'touchStartCapture'
touchstart: 'touchstart'
}
3 changes: 0 additions & 3 deletions src/context/resizable-panes-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import {
synSizeToMaxSize, synSizeToMinSize, syncPaneRatioSizeToSize
} from '../models/pane'
import {attachDetectionCoordinate, detectionService} from '../services/detection-service'
import {consoleGetSize} from '../utils/development-util'

export const getResizableContext = (
props: IResizablePaneProviderProps
Expand Down Expand Up @@ -134,7 +133,6 @@ export const getResizableContext = (
direction: DIRECTIONS.NONE,
axisCoordinate: mouseCoordinate
})
console.log(handleId, mouseCoordinate)
setMouseDownFlag(true)
syncAxisSizes()
}
Expand Down Expand Up @@ -251,7 +249,6 @@ export const getResizableContext = (
afterResizeStop()

setMouseDownFlag(false)
consoleGetSize(resizable.items)
}

resizable.onMouseUp = onMoveEndFn
Expand Down
9 changes: 5 additions & 4 deletions src/services/detection-service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {ResizableModel} from '../models'
import {getSize} from '../models/pane'
import {addDOMEvent, getResizableEvent, removeDOMEvent} from '../utils/dom'
import {addDOMEvent, addDOMEventPassive, getResizableEvent, removeDOMEvent} from '../utils/dom'
import {getVisibleItems} from '../utils/panes'

import throttle from 'throttleit'
Expand Down Expand Up @@ -38,7 +38,7 @@ const getMouseDownOnHandle = (
registerResizeEvent: any) => (e: any) => {
const {detectionDetails} = resizable

const cursorCoordinate = vertical ? e.clientX : e.clientY
const [cursorCoordinate] = getResizableEvent(e, vertical, {})

const resizerClickedCoordinateList = detectionDetails.map(([x1, x2]) => {
const coordinates = Math.abs(((x1 + x2) / 2) - cursorCoordinate)
Expand Down Expand Up @@ -85,7 +85,7 @@ export const detectionService = (containerNode: HTMLElement, resizable: Resizabl

const onGlobalMouseMoveDebounce = throttle(onContainerMouseMove(containerNode, resizable, vertical, cursorStyle), 100)

addDOMEvent(containerNode, onGlobalMouseMoveDebounce, EVENT_NAMES.mousemove)
addDOMEventPassive(containerNode, onGlobalMouseMoveDebounce, EVENT_NAMES.mousemove)
document.addEventListener(EVENT_NAMES.touchmove, onGlobalMouseMoveDebounce, {passive: false})

const resize = getResize(resizable, vertical)
Expand All @@ -102,7 +102,8 @@ export const detectionService = (containerNode: HTMLElement, resizable: Resizabl

const onMouseDownOnHandle = getMouseDownOnHandle(resizable, vertical, registerResizeEvent)

addDOMEvent(containerNode, onMouseDownOnHandle, EVENT_NAMES.mousedown, EVENT_NAMES.touchStartCapture)
addDOMEvent(containerNode, onMouseDownOnHandle, EVENT_NAMES.mousedown)
addDOMEventPassive(containerNode, onMouseDownOnHandle, EVENT_NAMES.touchstart)

addDOMEvent(document, clearResizeEvent, EVENT_NAMES.mouseup, EVENT_NAMES.touchend)
}
8 changes: 0 additions & 8 deletions src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@
background-clip: padding-box;
}

/* .resizer-vertical {
cursor: row-resize;
} */

/* .resizer-horizontal {
cursor: col-resize;
} */

.overflow-hidden {
overflow: hidden;
}
Expand Down
5 changes: 5 additions & 0 deletions src/utils/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ export const addDOMEvent = (node: HTMLElement | Document | Window,
eventNames.forEach((eventName) => node.addEventListener(eventName, callBack))
}

export const addDOMEventPassive = (node: HTMLElement | Document | Window,
callBack: (e: any) => void, eventName: string) => {
node.addEventListener(eventName, callBack, {passive: false})
}

export const removeDOMEvent = (node: HTMLElement | Document | Window,
callBack: (e: any) => void, ...eventNames: string[]) => {
eventNames.forEach((eventName) => node.removeEventListener(eventName, callBack))
Expand Down

0 comments on commit cd0c2a4

Please sign in to comment.