From f7e3c0329d07abcadf631c669f085a591bb3403d Mon Sep 17 00:00:00 2001 From: Amolith Date: Thu, 20 Jul 2023 19:39:35 -0400 Subject: [PATCH] enable ghosty cursor --- static/js/ghostCursor.js | 80 ++++++++++++++++++++ themes/secluded/layouts/_default/baseof.html | 5 ++ themes/secluded/layouts/partials/head.html | 3 + 3 files changed, 88 insertions(+) create mode 100644 static/js/ghostCursor.js diff --git a/static/js/ghostCursor.js b/static/js/ghostCursor.js new file mode 100644 index 0000000..231b2a8 --- /dev/null +++ b/static/js/ghostCursor.js @@ -0,0 +1,80 @@ +var cursoreffects = function(e) { + "use strict"; + return e.ghostCursor = function(e) { + let t, i, n, o = e && e.element, + s = o || document.body, + h = window.innerWidth, + c = window.innerHeight, + l = { + x: h / 2, + y: h / 2 + }, + d = [], + r = new Image; + r.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAATCAYAAACk9eypAAAAAXNSR0IArs4c6QAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAhGVYSWZNTQAqAAAACAAFARIAAwAAAAEAAQAAARoABQAAAAEAAABKARsABQAAAAEAAABSASgAAwAAAAEAAgAAh2kABAAAAAEAAABaAAAAAAAAAEgAAAABAAAASAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAADKADAAQAAAABAAAAEwAAAAAChpcNAAAACXBIWXMAAAsTAAALEwEAmpwYAAABWWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNS40LjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczp0aWZmPSJodHRwOi8vbnMuYWRvYmUuY29tL3RpZmYvMS4wLyI+CiAgICAgICAgIDx0aWZmOk9yaWVudGF0aW9uPjE8L3RpZmY6T3JpZW50YXRpb24+CiAgICAgIDwvcmRmOkRlc2NyaXB0aW9uPgogICA8L3JkZjpSREY+CjwveDp4bXBtZXRhPgpMwidZAAABqElEQVQoFY3SPUvDQBgH8BREpRHExYiDgmLFl6WC+AYmWeyLg4i7buJX8DMpOujgyxGvUYeCgzhUQUSKKLUS0+ZyptXh8Z5Ti621ekPyJHl+uftfomhaf9Ei5JyxXKfynyEA6EYcLHpwyflT958GAQ7DTABNHd8EbtDbEH2BD5QEQmi2mM8P/Iq+A0SzszEg+3sPjDnDdVEtQKQbMUidHD3xVzf6A9UDEmEm+8h9KTqTVUjT+vB53aHrCbAPiceYq1dQI1Aqv4EhMll0jzv+Y0yiRgCnLRSYyDQHVoqUXe4uKL9l+L7GXC4vkMhE6eW/AOJs9k583ORDUyXMZ8F5SVHVVnllmPNKSFagAJ5DofaqGXw/gHBYg51dIldkmknY3tguv3jOtHR4+MqAzaraJXbEhqHhcQlwGSOi5pytVQHZLN5s0WNe8HPrLYlFsO20RPHkImxsbmHdLJFI76th7Z4SeuF53hTeFLvhRCJRCTKZKxgdnRDbW+iozFJbBMw14/ElwGYc0egMBMFzT21f5Rog33Z7dX02GBm7WV5ZfT5Nn5bE3zuCDe9UxdTpNvK+5AAAAABJRU5ErkJggg=="; + const a = window.matchMedia("(prefers-reduced-motion: reduce)"); + + function A() { + if (a.matches) return console.log("This browser has prefers reduced motion turned on, so the cursor did not init"), !1; + t = document.createElement("canvas"), i = t.getContext("2d"), t.style.top = "0px", t.style.left = "0px", t.style.pointerEvents = "none", o ? (t.style.position = "absolute", s.appendChild(t), t.width = s.clientWidth, t.height = s.clientHeight) : (t.style.position = "fixed", document.body.appendChild(t), t.width = h, t.height = c), s.addEventListener("mousemove", g), s.addEventListener("touchmove", m, { + passive: !0 + }), s.addEventListener("touchstart", m, { + passive: !0 + }), window.addEventListener("resize", u), p() + } + + function u(e) { + h = window.innerWidth, c = window.innerHeight, o ? (t.width = s.clientWidth, t.height = s.clientHeight) : (t.width = h, t.height = c) + } + + function m(e) { + if (e.touches.length > 0) + for (let t = 0; t < e.touches.length; t++) f(e.touches[t].clientX, e.touches[t].clientY, r) + } + + function g(e) { + if (o) { + const t = s.getBoundingClientRect(); + l.x = e.clientX - t.left, l.y = e.clientY - t.top + } else l.x = e.clientX, l.y = e.clientY; + f(l.x, l.y, r) + } + + function f(e, t, i) { + d.push(new w(e, t, i)) + } + + function p() { + ! function() { + if (0 != d.length) { + i.clearRect(0, 0, h, c); + for (let e = 0; e < d.length; e++) d[e].update(i); + for (let e = d.length - 1; e >= 0; e--) d[e].lifeSpan < 0 && d.splice(e, 1); + 0 == d.length && i.clearRect(0, 0, h, c) + } + }(), n = requestAnimationFrame(p) + } + + function y() { + t.remove(), cancelAnimationFrame(n), s.removeEventListener("mousemove", g), s.removeEventListener("touchmove", m), s.removeEventListener("touchstart", m), window.addEventListener("resize", u) + } + + function w(e, t, i) { + this.initialLifeSpan = 40, this.lifeSpan = 40, this.position = { + x: e, + y: t + }, this.image = i, this.update = function(e) { + this.lifeSpan--; + const t = Math.max(this.lifeSpan / this.initialLifeSpan, 0); + e.globalAlpha = t, e.drawImage(this.image, this.position.x, this.position.y) + } + } + return a.onchange = () => { + a.matches ? y() : A() + }, A(), { + destroy: y + } + }, Object.defineProperty(e, "__esModule", { + value: !0 + }), e +}({}); diff --git a/themes/secluded/layouts/_default/baseof.html b/themes/secluded/layouts/_default/baseof.html index d80e5e1..af3a73d 100644 --- a/themes/secluded/layouts/_default/baseof.html +++ b/themes/secluded/layouts/_default/baseof.html @@ -8,4 +8,9 @@ {{ partial "footer.html" . -}} + diff --git a/themes/secluded/layouts/partials/head.html b/themes/secluded/layouts/partials/head.html index 769f86e..b3c5c00 100644 --- a/themes/secluded/layouts/partials/head.html +++ b/themes/secluded/layouts/partials/head.html @@ -48,4 +48,7 @@ + + +