Merge branch 'develop' of https://github.com/misskey-dev/misskey into develop
This commit is contained in:
commit
259be258aa
1 changed files with 8 additions and 1 deletions
|
@ -13,13 +13,20 @@ interface Props {
|
||||||
|
|
||||||
const contentSymbol = Symbol();
|
const contentSymbol = Symbol();
|
||||||
const observer = new ResizeObserver((entries) => {
|
const observer = new ResizeObserver((entries) => {
|
||||||
|
const results: {
|
||||||
|
container: HTMLSpanElement;
|
||||||
|
transform: string;
|
||||||
|
}[] = [];
|
||||||
for (const entry of entries) {
|
for (const entry of entries) {
|
||||||
const content = (entry.target[contentSymbol] ? entry.target : entry.target.firstElementChild) as HTMLSpanElement;
|
const content = (entry.target[contentSymbol] ? entry.target : entry.target.firstElementChild) as HTMLSpanElement;
|
||||||
const props: Required<Props> = content[contentSymbol];
|
const props: Required<Props> = content[contentSymbol];
|
||||||
const container = content.parentElement as HTMLSpanElement;
|
const container = content.parentElement as HTMLSpanElement;
|
||||||
const contentWidth = content.getBoundingClientRect().width;
|
const contentWidth = content.getBoundingClientRect().width;
|
||||||
const containerWidth = container.getBoundingClientRect().width;
|
const containerWidth = container.getBoundingClientRect().width;
|
||||||
container.style.transform = `scaleX(${Math.max(props.minScale, Math.min(1, containerWidth / contentWidth))})`;
|
results.push({ container, transform: `scaleX(${Math.max(props.minScale, Math.min(1, containerWidth / contentWidth))})` });
|
||||||
|
}
|
||||||
|
for (const result of results) {
|
||||||
|
result.container.style.transform = result.transform;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in a new issue