데스크탑 앱 전략편집기 수정
This commit is contained in:
@@ -48,21 +48,26 @@ export interface BindWindowDragOptions {
|
||||
*/
|
||||
export function bindWindowDrag(
|
||||
onMove: (xy: ClientXY, ev: Event) => void,
|
||||
onEnd: () => void,
|
||||
onEnd: (xy: ClientXY, ev: Event) => void,
|
||||
options: BindWindowDragOptions = {},
|
||||
): () => void {
|
||||
const { preventTouchScroll = true } = options;
|
||||
let lastXY: ClientXY = { x: 0, y: 0 };
|
||||
|
||||
const move = (ev: Event) => {
|
||||
const xy = clientXYFromNative(ev);
|
||||
if (!xy) return;
|
||||
lastXY = xy;
|
||||
if (preventTouchScroll && ev.cancelable && (ev instanceof TouchEvent || ev.type === 'touchmove')) {
|
||||
ev.preventDefault();
|
||||
}
|
||||
onMove(xy, ev);
|
||||
};
|
||||
|
||||
const end = () => onEnd();
|
||||
const end = (ev: Event) => {
|
||||
const xy = clientXYFromNative(ev) ?? lastXY;
|
||||
onEnd(xy, ev);
|
||||
};
|
||||
|
||||
window.addEventListener('pointermove', move);
|
||||
window.addEventListener('pointerup', end);
|
||||
|
||||
Reference in New Issue
Block a user