mirror of
https://github.com/ankitects/anki.git
synced 2025-11-10 22:57:11 -05:00
Prevent overflow of sizeDimensions or image handle buttons
This commit is contained in:
parent
cc2641095f
commit
18f63ef17e
2 changed files with 10 additions and 2 deletions
|
|
@ -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>
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
#fields {
|
#fields {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
overflow-x: hidden;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
margin: 5px;
|
margin: 5px;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue