Prevent overflow of sizeDimensions or image handle buttons

This commit is contained in:
Henrik Giesel 2021-08-06 04:44:33 +02:00 committed by Damien Elmes
parent cc2641095f
commit 18f63ef17e
2 changed files with 10 additions and 2 deletions

View file

@ -10,14 +10,20 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
let dimensions: HTMLDivElement; let dimensions: HTMLDivElement;
let overflowFix = 0; let overflowFix = 0;
afterUpdate(() => { function updateOverflow(dimensions: HTMLDivElement) {
const boundingClientRect = dimensions.getBoundingClientRect(); const boundingClientRect = dimensions.getBoundingClientRect();
const overflow = isRtl const overflow = isRtl
? window.innerWidth - boundingClientRect.x - boundingClientRect.width ? window.innerWidth - boundingClientRect.x - boundingClientRect.width
: boundingClientRect.x; : boundingClientRect.x;
overflowFix = Math.min(0, overflowFix + overflow, overflow); overflowFix = Math.min(0, overflowFix + overflow, overflow);
}); }
function updateOverflowAsync(dimensions: HTMLDivElement) {
setTimeout(() => updateOverflow(dimensions));
}
afterUpdate(() => updateOverflow(dimensions));
const dispatch = createEventDispatcher(); const dispatch = createEventDispatcher();
@ -29,6 +35,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
class="image-handle-dimensions" class="image-handle-dimensions"
class:is-rtl={isRtl} class:is-rtl={isRtl}
style="--overflow-fix: {overflowFix}px" style="--overflow-fix: {overflowFix}px"
use:updateOverflowAsync
> >
<slot /> <slot />
</div> </div>

View file

@ -10,6 +10,7 @@
#fields { #fields {
display: flex; display: flex;
overflow-x: hidden;
flex-direction: column; flex-direction: column;
margin: 5px; margin: 5px;
} }