diff --git a/index.html b/index.html index 1345340..00b225e 100644 --- a/index.html +++ b/index.html @@ -167,7 +167,7 @@
- +
@@ -294,7 +294,7 @@
- +
@@ -338,7 +338,7 @@
- +
@@ -382,7 +382,7 @@
- +
@@ -426,7 +426,7 @@
- +
@@ -471,7 +471,7 @@
- +
@@ -726,7 +726,7 @@
- +
@@ -758,7 +758,7 @@
- +
@@ -790,7 +790,7 @@
- +
@@ -924,7 +924,7 @@
- +
@@ -992,7 +992,7 @@
- +
diff --git a/js/magiccursor.js b/js/magiccursor.js index 4c3d5e5..8c376e6 100644 --- a/js/magiccursor.js +++ b/js/magiccursor.js @@ -27,6 +27,8 @@ class Cursor { }).on('mouseenter', () => { self.show(); }).on('mousemove', (e) => { + if (this.lastMove && Date.now() - this.lastMove < 16) return; // Throttle to ~60fps + this.lastMove = Date.now(); this.pos = { x: this.stick ? this.stick.x - ((this.stick.x - e.clientX) * 0.15) : e.clientX, y: this.stick ? this.stick.y - ((this.stick.y - e.clientY) * 0.15) : e.clientY @@ -95,33 +97,39 @@ class Cursor { } update() { + if (!this.visible) return; this.move(); this.show(); } move(x, y, duration) { + if (!this.el.length) return; gsap.to(this.el, { x: x || this.pos.x, y: y || this.pos.y, force3D: true, - overwrite: true, + overwrite: "auto", ease: this.options.ease, duration: this.visible ? (duration || this.options.speed) : 0 }); } show() { - if (this.visible) return; - clearInterval(this.visibleInt); + if (this.visible || !this.el.length) return; this.el.addClass('-visible'); - this.visibleInt = setTimeout(() => this.visible = true); + this.visible = true; } hide() { - clearInterval(this.visibleInt); + if (!this.el.length) return; this.el.removeClass('-visible'); - this.visibleInt = setTimeout(() => this.visible = false, this.options.visibleTimeout); + this.visible = false; } } -// Init cursor -const cursor = new Cursor(); + +// Init cursor only on desktop and after load +$(window).on('load', function() { + if (window.innerWidth > 1024 && !('ontouchstart' in window)) { + const cursor = new Cursor(); + } +});