CLS
Cumulative Layout Shift đ https://web.dev/cls/
*âšī¸ Have not yet conducted any testing (currently focused on other tasks, will revisit this). The following list may provide some insights or leads to better understanding of the situation. It does not appear to require heavy scripting, there may be a more elegant solution available (potentially contrary to typical library practices where target-selectors for sidemenus are used without scripting).
Here are some initial thoughts, conjectures, experiences, investigations, links, and in my opinion, the root cause of why this issue occurs.
Let's begin:
- Initially, it seems like anchor jumping by id, e.g.
#slide1
jumps to element with id="slide1"
, using native anchor jumps, so preventDefault would halt everything (let's rule that out)
Suspecting the unknown width and height of the images as the root cause (necessitating safeNumbers, percentages, vw,vh in safeNumbers rather than just percentages etc. might work, but we require percentages đĨŗ).
Check if animation targets top, right, bottom, left and if so, use:
`transform: translate()` instead. Just came to mind: DaisyUI and HeadlessUI could be ideal here.
Â
The issue could potentially be related to loading time:
img { max-width: 100%; height: auto; }
...but don't we typically preload images in carousels anyway? If so, then the dimensions of the image are known â unknown width/height of the image as the root cause â and useLayoutEffect() is where you can calculate and set px values before the render is painted to the screen, right?
- Aspect Ratio Solution
good luck (will fix the typos another day ^^ when I pick up your end solution hehe)