From 744cdc9d19f90cae7d09d2ce9118927a0c57e92d Mon Sep 17 00:00:00 2001 From: Ilia Mashkov Date: Wed, 3 Jun 2026 16:03:51 +0300 Subject: [PATCH] refactor(ComparisonView): size crossfade window per line --- src/widgets/ComparisonView/ui/Line/Line.svelte | 9 ++++----- .../ComparisonView/ui/SliderArea/SliderArea.svelte | 8 +------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/widgets/ComparisonView/ui/Line/Line.svelte b/src/widgets/ComparisonView/ui/Line/Line.svelte index 96e8b6d..4721a1e 100644 --- a/src/widgets/ComparisonView/ui/Line/Line.svelte +++ b/src/widgets/ComparisonView/ui/Line/Line.svelte @@ -10,6 +10,7 @@ import { type ComparisonLine, computeLineRenderModel, + windowSizeForLine, } from '$entities/Font'; import { getTypographySettingsStore } from '$features/AdjustTypography'; import { getComparisonStore } from '../../model'; @@ -24,16 +25,14 @@ interface Props { * Count of chars the slider has passed, from `findSplitIndex`. */ split: number; - /** - * Number of chars in the crossfade window around the split. - */ - windowSize: number; } -let { line, split, windowSize }: Props = $props(); +let { line, split }: Props = $props(); const comparisonStore = getComparisonStore(); +const windowSize = $derived(windowSizeForLine(line.chars.length)); + const model = $derived(computeLineRenderModel(line, split, windowSize)); const typography = getTypographySettingsStore(); diff --git a/src/widgets/ComparisonView/ui/SliderArea/SliderArea.svelte b/src/widgets/ComparisonView/ui/SliderArea/SliderArea.svelte index 8b98abe..e98f9dd 100644 --- a/src/widgets/ComparisonView/ui/SliderArea/SliderArea.svelte +++ b/src/widgets/ComparisonView/ui/SliderArea/SliderArea.svelte @@ -107,12 +107,6 @@ const layout = new DualFontLayout(); let layoutResult = $state({ lines: [], totalHeight: 0 }); -/** - * N-window size for the per-char crossfade zone around the slider split. - * Tuned so chars complete their 100ms opacity crossfade before exiting the window. - */ -const WINDOW_SIZE = 5; - // Track container width changes (window resize, sidebar toggle, etc.) $effect(() => { if (!container) { @@ -344,7 +338,7 @@ $effect(() => { > {#each layoutResult.lines as line, lineIdx (lineIdx)} {@const split = findSplitIndex(line, sliderPos, containerWidth)} - + {/each}