But by October, tanks and artillery could be seen.
diff --git a/src/components/BeforeAfter/BeforeAfter.svelte b/src/components/BeforeAfter/BeforeAfter.svelte
index a97a33a4..23621bfc 100644
--- a/src/components/BeforeAfter/BeforeAfter.svelte
+++ b/src/components/BeforeAfter/BeforeAfter.svelte
@@ -6,12 +6,7 @@
import Block from '../Block/Block.svelte';
import PaddingReset from '../PaddingReset/PaddingReset.svelte';
import type { ContainerWidth } from '../@types/global';
-
- /** Helper function to generate a random 4-character string */
- const random4 = () =>
- Math.floor((1 + Math.random()) * 0x10000)
- .toString(16)
- .substring(1);
+ import { random4 } from '../../utils/';
interface Props {
/** Width of the chart within the text well. Options: wide, wider, widest, fluid */
@@ -98,7 +93,7 @@
let figure: HTMLElement | undefined = $state(undefined);
let beforeOverlayWidth = $state(0);
let isFocused = false;
- let containerWidth: number = $state(0); // check if this should be undefined
+ let containerWidth: number = $state(0); // Defaults to 0
let containerHeight = $derived(
containerWidth && heightRatio ? containerWidth * heightRatio : height
@@ -112,6 +107,7 @@
x < beforeOverlayWidth ? Math.abs(x - beforeOverlayWidth) : 0
);
+ /** Toggle `isFocused` */
const onfocus = () => (isFocused = true);
const onblur = () => (isFocused = false);
@@ -127,10 +123,12 @@
}
};
+ /** Measure image and set image offset */
const measureImage = () => {
if (img && img.complete) imgOffset = img.getBoundingClientRect();
};
+ /** Reset image offset on resize */
const resize = () => {
measureImage();
};
@@ -142,6 +140,7 @@
}
};
+ /** Move the slider */
const move = (e: MouseEvent | TouchEvent) => {
if (sliding && imgOffset) {
const el =
@@ -158,11 +157,14 @@
offset = x / w;
}
};
+
+ /** Starts the slider */
const start = (e: MouseEvent | TouchEvent) => {
sliding = true;
move(e);
};
+ /** Sets `sliding` to `false`*/
const end = () => {
sliding = false;
};
@@ -177,46 +179,41 @@
+
{#if beforeSrc && beforeAlt && afterSrc && afterAlt}
-
-
-
-
-
{#if beforeOverlay}
-
+