diff --git a/pages/API/resize-observer/resize-observer.test.js b/pages/API/resize-observer/resize-observer.test.js index eee1bcdcef692429f2560530ddfda2364dfe5921..fb854f890a13ec371d0bd207a544ee235a3eefed 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 cd1f30545c155d5a0892bcb5058d1f4e2d6cdc2e..e872748847cb81f449e87ce1e0e5736b02bcfd73 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