Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion public/r/Ballpit-JS-CSS.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/r/Ballpit-JS-TW.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/r/Ballpit-TS-CSS.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/r/Ballpit-TS-TW.json

Large diffs are not rendered by default.

13 changes: 9 additions & 4 deletions src/content/Backgrounds/Ballpit/Ballpit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ class x {
onAfterResize = () => {};
#s = false;
#n = false;
// Bind once: `.bind()` returns a new function on every call, so binding again
// in the teardown would hand removeEventListener a function that was never
// registered, leaving the listener attached for the lifetime of the page.
#boundResize = this.#f.bind(this);
#boundVisibilityChange = this.#v.bind(this);
isDisposed = false;
#o;
#r;
Expand Down Expand Up @@ -83,7 +88,7 @@ class x {
}
#g() {
if (!(this.#e.size instanceof Object)) {
window.addEventListener('resize', this.#f.bind(this));
window.addEventListener('resize', this.#boundResize);
if (this.#e.size === 'parent' && this.canvas.parentNode) {
this.#r = new ResizeObserver(this.#f.bind(this));
this.#r.observe(this.canvas.parentNode);
Expand All @@ -95,13 +100,13 @@ class x {
threshold: 0
});
this.#o.observe(this.canvas);
document.addEventListener('visibilitychange', this.#v.bind(this));
document.addEventListener('visibilitychange', this.#boundVisibilityChange);
}
#y() {
window.removeEventListener('resize', this.#f.bind(this));
window.removeEventListener('resize', this.#boundResize);
this.#r?.disconnect();
this.#o?.disconnect();
document.removeEventListener('visibilitychange', this.#v.bind(this));
document.removeEventListener('visibilitychange', this.#boundVisibilityChange);
}
#u(e) {
this.#s = e[0].isIntersecting;
Expand Down
13 changes: 9 additions & 4 deletions src/tailwind/Backgrounds/Ballpit/Ballpit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ class x {
onAfterResize = () => {};
#s = false;
#n = false;
// Bind once: `.bind()` returns a new function on every call, so binding again
// in the teardown would hand removeEventListener a function that was never
// registered, leaving the listener attached for the lifetime of the page.
#boundResize = this.#f.bind(this);
#boundVisibilityChange = this.#v.bind(this);
isDisposed = false;
#o;
#r;
Expand Down Expand Up @@ -83,7 +88,7 @@ class x {
}
#g() {
if (!(this.#e.size instanceof Object)) {
window.addEventListener('resize', this.#f.bind(this));
window.addEventListener('resize', this.#boundResize);
if (this.#e.size === 'parent' && this.canvas.parentNode) {
this.#r = new ResizeObserver(this.#f.bind(this));
this.#r.observe(this.canvas.parentNode);
Expand All @@ -95,13 +100,13 @@ class x {
threshold: 0
});
this.#o.observe(this.canvas);
document.addEventListener('visibilitychange', this.#v.bind(this));
document.addEventListener('visibilitychange', this.#boundVisibilityChange);
}
#y() {
window.removeEventListener('resize', this.#f.bind(this));
window.removeEventListener('resize', this.#boundResize);
this.#r?.disconnect();
this.#o?.disconnect();
document.removeEventListener('visibilitychange', this.#v.bind(this));
document.removeEventListener('visibilitychange', this.#boundVisibilityChange);
}
#u(e) {
this.#s = e[0].isIntersecting;
Expand Down
13 changes: 9 additions & 4 deletions src/ts-default/Backgrounds/Ballpit/Ballpit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ class X {
#animationState = { elapsed: 0, delta: 0 };
#isAnimating: boolean = false;
#isVisible: boolean = false;
// Bind once: `.bind()` returns a new function on every call, so binding again
// in the teardown would hand removeEventListener a function that was never
// registered, leaving the listener attached for the lifetime of the page.
#boundResize = this.#onResize.bind(this);
#boundVisibilityChange = this.#onVisibilityChange.bind(this);

canvas!: HTMLCanvasElement;
camera!: PerspectiveCamera;
Expand Down Expand Up @@ -123,7 +128,7 @@ class X {

#initObservers() {
if (!(this.#config.size instanceof Object)) {
window.addEventListener('resize', this.#onResize.bind(this));
window.addEventListener('resize', this.#boundResize);
if (this.#config.size === 'parent' && this.canvas.parentNode) {
this.#resizeObserver = new ResizeObserver(this.#onResize.bind(this));
this.#resizeObserver.observe(this.canvas.parentNode as Element);
Expand All @@ -135,7 +140,7 @@ class X {
threshold: 0
});
this.#intersectionObserver.observe(this.canvas);
document.addEventListener('visibilitychange', this.#onVisibilityChange.bind(this));
document.addEventListener('visibilitychange', this.#boundVisibilityChange);
}

#onResize() {
Expand Down Expand Up @@ -283,10 +288,10 @@ class X {
}

#onResizeCleanup() {
window.removeEventListener('resize', this.#onResize.bind(this));
window.removeEventListener('resize', this.#boundResize);
this.#resizeObserver?.disconnect();
this.#intersectionObserver?.disconnect();
document.removeEventListener('visibilitychange', this.#onVisibilityChange.bind(this));
document.removeEventListener('visibilitychange', this.#boundVisibilityChange);
}
}

Expand Down
13 changes: 9 additions & 4 deletions src/ts-tailwind/Backgrounds/Ballpit/Ballpit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ class X {
#animationState = { elapsed: 0, delta: 0 };
#isAnimating: boolean = false;
#isVisible: boolean = false;
// Bind once: `.bind()` returns a new function on every call, so binding again
// in the teardown would hand removeEventListener a function that was never
// registered, leaving the listener attached for the lifetime of the page.
#boundResize = this.#onResize.bind(this);
#boundVisibilityChange = this.#onVisibilityChange.bind(this);

canvas!: HTMLCanvasElement;
camera!: PerspectiveCamera;
Expand Down Expand Up @@ -123,7 +128,7 @@ class X {

#initObservers() {
if (!(this.#config.size instanceof Object)) {
window.addEventListener('resize', this.#onResize.bind(this));
window.addEventListener('resize', this.#boundResize);
if (this.#config.size === 'parent' && this.canvas.parentNode) {
this.#resizeObserver = new ResizeObserver(this.#onResize.bind(this));
this.#resizeObserver.observe(this.canvas.parentNode as Element);
Expand All @@ -135,7 +140,7 @@ class X {
threshold: 0
});
this.#intersectionObserver.observe(this.canvas);
document.addEventListener('visibilitychange', this.#onVisibilityChange.bind(this));
document.addEventListener('visibilitychange', this.#boundVisibilityChange);
}

#onResize() {
Expand Down Expand Up @@ -283,10 +288,10 @@ class X {
}

#onResizeCleanup() {
window.removeEventListener('resize', this.#onResize.bind(this));
window.removeEventListener('resize', this.#boundResize);
this.#resizeObserver?.disconnect();
this.#intersectionObserver?.disconnect();
document.removeEventListener('visibilitychange', this.#onVisibilityChange.bind(this));
document.removeEventListener('visibilitychange', this.#boundVisibilityChange);
}
}

Expand Down