提交 e7effc42 编写于 作者: shutao-dc's avatar shutao-dc

补充修改margin 影响resizeObserver回调示例

上级 0b18f5d1
...@@ -17,4 +17,11 @@ describe('api-resize-observer', () => { ...@@ -17,4 +17,11 @@ describe('api-resize-observer', () => {
const image = await program.screenshot(); const image = await program.screenshot();
expect(image).toSaveImageSnapshot(); 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)
})
}) })
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<view v-show="boxDisplay" style="align-items: center; justify-content: center; margin: 10px;"> <view v-show="boxDisplay" style="align-items: center; justify-content: center; margin: 10px;">
<view <view
style="width: 140px; height: 140px; background-color: blue; align-items: center; justify-content: center; padding: 5px;" style="width: 140px; height: 140px; background-color: blue; align-items: center; justify-content: center; padding: 5px;"
id="outBox" @click="outBoxClick"> id="outBox">
<view style="width: 80px; height: 80px; background-color: red; padding: 5px;" id="innerBox" <view style="width: 80px; height: 80px; background-color: red; padding: 5px;" id="innerBox"
@click="innerBoxClick"></view> @click="innerBoxClick"></view>
</view> </view>
...@@ -34,7 +34,8 @@ ...@@ -34,7 +34,8 @@
boxDisplay: false, boxDisplay: false,
outBoxElement: null as UniElement | null, outBoxElement: null as UniElement | null,
innerBoxElement: null as UniElement | null, innerBoxElement: null as UniElement | null,
resizeObserver: null as UniResizeObserver | null resizeObserver: null as UniResizeObserver | null,
outBoxElementOnResize: false
} }
}, },
onBackPress() : boolean { onBackPress() : boolean {
...@@ -48,7 +49,8 @@ ...@@ -48,7 +49,8 @@
this.resizeObserver = new UniResizeObserver((entries : Array<UniResizeObserverEntry>) => { this.resizeObserver = new UniResizeObserver((entries : Array<UniResizeObserverEntry>) => {
entries.forEach(entry => { entries.forEach(entry => {
if (entry.target == this.outBoxElement) { if (entry.target == this.outBoxElement) {
this.outBoxSizeInfo = this.analysisResizeObserverEntry(entry) this.outBoxSizeInfo = this.analysisResizeObserverEntry(entry)
this.outBoxElementOnResize = true
} else if (entry.target == this.innerBoxElement) { } else if (entry.target == this.innerBoxElement) {
this.innerBoxSizeInfo = this.analysisResizeObserverEntry(entry) this.innerBoxSizeInfo = this.analysisResizeObserverEntry(entry)
} }
...@@ -87,6 +89,13 @@ ...@@ -87,6 +89,13 @@
this.innerBoxElement!.style.setProperty("width", "80px") this.innerBoxElement!.style.setProperty("width", "80px")
this.innerBoxElement!.style.setProperty("height", "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() { toggleDisplay() {
this.boxDisplay = !this.boxDisplay this.boxDisplay = !this.boxDisplay
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册