From 40ee3b38e065e759bb81787c730feed28a2e6129 Mon Sep 17 00:00:00 2001 From: Arthur Refslund Date: Sat, 12 Nov 2022 01:22:10 +0100 Subject: [PATCH] Added `updateHeight` and classes for .v-thumb based on last action (for transitioning based on said action) --- README.md | 47 ++++++++++++++++++++++ src/Svrollbar.svelte | 93 +++++++++++++++++++++++++++++++++++++++++--- src/Svroller.svelte | 8 +++- 3 files changed, 142 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index cf17068..501a305 100644 --- a/README.md +++ b/README.md @@ -287,3 +287,50 @@ you can customize scrollbar visibility with `alwaysVisible` and `initiallyVisibl | ---------------- | ------- | ------------------------------------ | | alwaysVisible | false | scrollbar is always visible | | initiallyVisible | false | scrollbar is visible until scrolling | + +## working with absolute divs + +the `Observer WebAPI` may not recognize a resize change when working with absolute divs. + +you can therefore manually trigger an update calculation, which will update the height of the scrollthumb + +```js +/** + * @type {(divElement: HTMLElement | undefined, minScrollHeight: HTMLElement | undefined) => void} + * @param divElement - Will base the new height of this elements scrollheight. + * This may be wanted if you're working with absolute divs + * @param minScrollHeight - A reference to an element, which makes up for the minimum scrollheight. + * (computed: min-height + top,bottom margins + top,bottom border widths) +*/ +export async function updateHeight(divElement = undefined, minScrollHeight = undefined) +``` + +in this example, we transition from *div A* to *div B*. + +at the start of the transition, both elements will be absolute, and therefore we trigger an update to the thumb height, so it can transition **with** the contents.
+when the content has finished the transition, the thumb will therefore have smoothly transitioned aswell + +the `updateHeight` in the transitionEnd is just a precaution — but should technically not be necessary + +```html +
+ + + updateHeight(elements.divA, elements.view)} + on:transitionEnd={updateHeight} + > +
+ +
+ +
+... + +