1- import type { Properties } from "csstype" ;
21import { read } from "../mutableState" ;
32import { getCursorStyle } from "./getCursorStyle" ;
43
5- let prevCursor : Properties [ "cursor" ] | null = null ;
4+ let prevStyle : string | undefined = undefined ;
65let styleSheet : CSSStyleSheet | undefined = undefined ;
76
87export 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 ) ;
0 commit comments