Lib: Remove previous lazy loading approach and replace with static aspect ratios
The element size must be valid before it is loaded, this is a problem for cards, as they adapt to their content's size. Previously I tried to load the first card non-lazily and measure its dimensions for the next cards, but that was not stable on viewport changes (could have measured the aspect ratio instead...). Now, all the aspect ratios are just measured and defined manually, stupid but simple.
This commit is contained in:
@ -6,7 +6,12 @@
|
||||
import type { Driver } from "$lib/schema";
|
||||
import Input from "./Input.svelte";
|
||||
import LazyDropdown, { type LazyDropdownOption } from "./LazyDropdown.svelte";
|
||||
import { DRIVER_HEADSHOT_HEIGHT, DRIVER_HEADSHOT_WIDTH } from "$lib/config";
|
||||
import {
|
||||
DRIVER_CARD_ASPECT_HEIGHT,
|
||||
DRIVER_CARD_ASPECT_WIDTH,
|
||||
DRIVER_HEADSHOT_HEIGHT,
|
||||
DRIVER_HEADSHOT_WIDTH,
|
||||
} from "$lib/config";
|
||||
|
||||
interface DriverCardProps {
|
||||
/** The [Driver] object used to prefill values. */
|
||||
@ -43,7 +48,8 @@
|
||||
</script>
|
||||
|
||||
<LazyCard
|
||||
group="DriverCard"
|
||||
cardwidth={DRIVER_CARD_ASPECT_WIDTH}
|
||||
cardheight={DRIVER_CARD_ASPECT_HEIGHT}
|
||||
imgsrc={driver?.headshot_url ?? headshot_template}
|
||||
imgwidth={DRIVER_HEADSHOT_WIDTH}
|
||||
imgheight={DRIVER_HEADSHOT_HEIGHT}
|
||||
|
||||
Reference in New Issue
Block a user