Поправка бага при resize

This commit is contained in:
Book Pauk
2020-11-06 01:08:22 +07:00
parent ca40854106
commit f07a157a2a

View File

@@ -234,7 +234,10 @@ class ExternalLibs extends Vue {
this.justOpened = true; this.justOpened = true;
this.$root.addKeyHook(this.keyHook); this.$root.addKeyHook(this.keyHook);
this.$root.$on('resize', this.frameResize); this.$root.$on('resize', async() => {
await utils.sleep(200);
this.frameResize();
});
document.addEventListener('fullscreenchange', () => { document.addEventListener('fullscreenchange', () => {
this.fullScreenActive = (document.fullscreenElement !== null); this.fullScreenActive = (document.fullscreenElement !== null);
@@ -521,18 +524,21 @@ class ExternalLibs extends Vue {
} }
frameResize() { frameResize() {
if (this.$refs.frame) { this.$refs.frameWrap.style = 'width: 1px; height: 1px;';
const w = this.$refs.frameBox.offsetWidth; this.$nextTick(() => {
const h = this.$refs.frameBox.offsetHeight; if (this.$refs.frame) {
const normalSize = `width: ${w}px; height: ${h}px;`; const w = this.$refs.frameBox.offsetWidth;
this.$refs.frameWrap.style = normalSize; const h = this.$refs.frameBox.offsetHeight;
if (this.frameScale != 1) { const normalSize = `width: ${w}px; height: ${h}px;`;
const s = this.frameScale; this.$refs.frameWrap.style = normalSize;
this.$refs.frame.style = `width: ${w/s}px; height: ${h/s}px; transform: scale(${s}); transform-origin: 0 0;`; if (this.frameScale != 1) {
} else { const s = this.frameScale;
this.$refs.frame.style = normalSize; this.$refs.frame.style = `width: ${w/s}px; height: ${h/s}px; transform: scale(${s}); transform-origin: 0 0;`;
} else {
this.$refs.frame.style = normalSize;
}
} }
} });
} }
changeScale(delta) { changeScale(delta) {