diff --git a/src/components/interactive-background/interactive-background.ts b/src/components/interactive-background/interactive-background.ts index 5ac1e95..c1143c9 100644 --- a/src/components/interactive-background/interactive-background.ts +++ b/src/components/interactive-background/interactive-background.ts @@ -277,7 +277,7 @@ class ParticleEngine { export class InteractiveBackground implements AfterViewInit, OnDestroy { @ViewChild('canvas', { static: true }) private readonly canvasRef!: ElementRef; - isCursorVisible = false; + isCursorVisible = InteractiveBackground.detectFinePointer(); isPointerDown = false; cursorTransform = 'translate3d(-9999px, -9999px, 0)'; @@ -311,8 +311,6 @@ export class InteractiveBackground implements AfterViewInit, OnDestroy { } } - this.isCursorVisible = this.getMediaQuery('(pointer: fine)').matches; - const onResize = () => this.resizeCanvas(); const supportsPointerEvents = 'PointerEvent' in window; const onPointerMove = (event: PointerEvent) => this.handlePointerMove(event); @@ -581,6 +579,14 @@ export class InteractiveBackground implements AfterViewInit, OnDestroy { dispatchEvent: () => false, }; } + + private static detectFinePointer(): boolean { + if (typeof window === 'undefined' || typeof window.matchMedia !== 'function') { + return false; + } + + return window.matchMedia('(pointer: fine)').matches; + } }