From e7effc4223f626c4e90db69fd6ca368225b52851 Mon Sep 17 00:00:00 2001 From: shutao Date: Sun, 28 Apr 2024 20:10:07 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85=E4=BF=AE=E6=94=B9margin=20?= =?UTF-8?q?=E5=BD=B1=E5=93=8DresizeObserver=E5=9B=9E=E8=B0=83=E7=A4=BA?= =?UTF-8?q?=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/API/resize-observer/resize-observer.test.js | 7 +++++++ pages/API/resize-observer/resize-observer.uvue | 15 ++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/pages/API/resize-observer/resize-observer.test.js b/pages/API/resize-observer/resize-observer.test.js index eee1bcdc..fb854f89 100644 --- a/pages/API/resize-observer/resize-observer.test.js +++ b/pages/API/resize-observer/resize-observer.test.js @@ -17,4 +17,11 @@ describe('api-resize-observer', () => { const image = await program.screenshot(); expect(image).toSaveImageSnapshot(); }) + + it('check_outbox_resize', async () => { + await page.callMethod('setOutBoxMarginLeft', '100px') + await page.waitFor(500) + const value = await page.data('outBoxElementOnResize') + expect(value).toBe(false) + }) }) diff --git a/pages/API/resize-observer/resize-observer.uvue b/pages/API/resize-observer/resize-observer.uvue index cd1f3054..e8727488 100644 --- a/pages/API/resize-observer/resize-observer.uvue +++ b/pages/API/resize-observer/resize-observer.uvue @@ -4,7 +4,7 @@ + id="outBox"> @@ -34,7 +34,8 @@ boxDisplay: false, outBoxElement: null as UniElement | null, innerBoxElement: null as UniElement | null, - resizeObserver: null as UniResizeObserver | null + resizeObserver: null as UniResizeObserver | null, + outBoxElementOnResize: false } }, onBackPress() : boolean { @@ -48,7 +49,8 @@ this.resizeObserver = new UniResizeObserver((entries : Array) => { entries.forEach(entry => { if (entry.target == this.outBoxElement) { - this.outBoxSizeInfo = this.analysisResizeObserverEntry(entry) + this.outBoxSizeInfo = this.analysisResizeObserverEntry(entry) + this.outBoxElementOnResize = true } else if (entry.target == this.innerBoxElement) { this.innerBoxSizeInfo = this.analysisResizeObserverEntry(entry) } @@ -87,6 +89,13 @@ this.innerBoxElement!.style.setProperty("width", "80px") this.innerBoxElement!.style.setProperty("height", "80px") } + }, + //自动化测试专用 + setOutBoxMarginLeft(value: string) { + if (this.outBoxElement != null) { + this.outBoxElementOnResize = false + this.outBoxElement!.style.setProperty("margin-left", value) + } }, toggleDisplay() { this.boxDisplay = !this.boxDisplay -- GitLab