Skip to content

Commit e08fe42

Browse files
committed
Improve iOS/Safari resize UX
1 parent 2cab92c commit e08fe42

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

lib/global/cursor/updateCursorStyle.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import type { Properties } from "csstype";
21
import { read } from "../mutableState";
32
import { getCursorStyle } from "./getCursorStyle";
43

5-
let prevCursor: Properties["cursor"] | null = null;
4+
let prevStyle: string | undefined = undefined;
65
let styleSheet: CSSStyleSheet | undefined = undefined;
76

87
export function updateCursorStyle() {
@@ -17,31 +16,32 @@ export function updateCursorStyle() {
1716
switch (interactionState.state) {
1817
case "active":
1918
case "hover": {
20-
const style = getCursorStyle({
19+
const cursorStyle = getCursorStyle({
2120
cursorFlags,
2221
groups: interactionState.hitRegions.map((current) => current.group),
2322
state: interactionState.state
2423
});
2524

26-
if (prevCursor === style) {
25+
const nextStyle = `*{cursor: ${cursorStyle} !important; ${interactionState.state === "active" ? "touch-action: none;" : ""} }`;
26+
if (prevStyle === nextStyle) {
2727
return;
2828
}
2929

30-
prevCursor = style;
30+
prevStyle = nextStyle;
3131

32-
if (style) {
32+
if (cursorStyle) {
3333
if (styleSheet.cssRules.length === 0) {
34-
styleSheet.insertRule(`*{cursor: ${style} !important;}`);
34+
styleSheet.insertRule(nextStyle);
3535
} else {
36-
styleSheet.replaceSync(`*{cursor: ${style} !important;}`);
36+
styleSheet.replaceSync(nextStyle);
3737
}
3838
} else if (styleSheet.cssRules.length === 1) {
3939
styleSheet.deleteRule(0);
4040
}
4141
break;
4242
}
4343
case "inactive": {
44-
prevCursor = null;
44+
prevStyle = undefined;
4545

4646
if (styleSheet.cssRules.length === 1) {
4747
styleSheet.deleteRule(0);

lib/global/event-handlers/onGroupPointerLeave.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ export function onGroupPointerLeave(event: PointerEvent) {
66
return;
77
} else if (event.relatedTarget !== null) {
88
return;
9+
} else if (event.clientX === 0 && event.clientY === 0) {
10+
// Edge case iOS Safari bug; coordinates are seemingly nonsensical which would break the drag event
11+
return;
912
}
1013

1114
const { interactionState, mountedGroups } = read();

0 commit comments

Comments
 (0)