summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2023-12-29 07:53:01 +0800
committerlittleblack111 <littleblack11111@gmail.com>2023-12-29 07:53:01 +0800
commit8b2924acbc4397509524d27d84d6b5ee0382ebf8 (patch)
treec2b32e316fa254921ec6e189b696dc0ff3b0b64a /src
parent0482fb45396eae47eea50507c0d03b906d872128 (diff)
adjust blob form:
dynamicjs: mobile -> randomblob else -> mouseblob forceForm -> mouse/random
Diffstat (limited to 'src')
-rw-r--r--src/js/dynamicBlob.js34
-rw-r--r--src/js/mouseblob.js13
-rw-r--r--src/js/randomblob.js1
3 files changed, 45 insertions, 3 deletions
diff --git a/src/js/dynamicBlob.js b/src/js/dynamicBlob.js
new file mode 100644
index 00000000..0c7f7bd2
--- /dev/null
+++ b/src/js/dynamicBlob.js
@@ -0,0 +1,34 @@
+const blob = document.querySelector('#blob');
+var blobData = blob.dataset.forceForm;
+
+function loadScript(src) {
+ var script = document.createElement('script');
+ script.src = src;
+ document.body.appendChild(script);
+}
+
+
+
+
+var blobItem;
+
+
+if (blobData) {
+ blobItem = blobData;
+} else {
+ // check if user's on mobile
+ if (navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/BlackBerry/i) || navigator.userAgent.match(/Windows Phone/i) || window.orientation > 1) {
+ // do randomBlob since user is on mobile(mouseBlob is buggy on mobile so ya)
+ blobItem = "random"
+ } else {
+ blobItem = "mouse"
+ }
+}
+
+if (blobItem == "mouse") {
+ loadScript('/dest/js/mouseblob.js')
+} else if (blobItem == "random") {
+ loadScript('/dest/js/randomblob.js')
+} else {
+ throw new Error("Unknown blob type")
+} \ No newline at end of file
diff --git a/src/js/mouseblob.js b/src/js/mouseblob.js
index a3cc0d64..71fdd631 100644
--- a/src/js/mouseblob.js
+++ b/src/js/mouseblob.js
@@ -1,4 +1,13 @@
-const blob = document.querySelector('.sblob');
+// const blob = document.querySelector('.sblob');
+
+
+// window.onpointermove = event => {
+// const { clientX, clientY } = event;
+// blob.animate({
+// left: `${clientX}px`,
+// top: `${clientY}px`
+// }, { duration: 1000, fill: "forwards" });
+// }
window.onpointermove = event => {
const { pageX, pageY } = event;
@@ -6,4 +15,4 @@ window.onpointermove = event => {
left: `${pageX}px`,
top: `${pageY}px`
}, { duration: 1000, fill: "forwards" });
-} \ No newline at end of file
+}
diff --git a/src/js/randomblob.js b/src/js/randomblob.js
index 191b6832..36c7d573 100644
--- a/src/js/randomblob.js
+++ b/src/js/randomblob.js
@@ -1,4 +1,3 @@
-var blob = document.querySelector('.blob')
let isFirstTime = true;
function getRandomInt(min, max) {