提交 27b2f4ee 编写于 作者: 郭胜强

fix: 解决resize-sensor组件第一次事件观测实效的问题

上级 83718ec9
...@@ -10,8 +10,8 @@ export default { ...@@ -10,8 +10,8 @@ export default {
data: function () { data: function () {
return { return {
size: { size: {
width: 0, width: -1,
height: 0 height: -1
} }
} }
}, },
...@@ -19,15 +19,10 @@ export default { ...@@ -19,15 +19,10 @@ export default {
size: { size: {
deep: true, deep: true,
handler: function (size) { handler: function (size) {
this.reset()
this.$emit('resize', Object.assign({}, size)) this.$emit('resize', Object.assign({}, size))
} }
} }
}, },
beforeDestroy: function () {
this.$emit('resize', { width: 0, height: 0 })
this.$emit('resizeSensorBeforeDestroy')
},
mounted: function () { mounted: function () {
if (this.initial === true) { if (this.initial === true) {
this.$nextTick(this.update) this.$nextTick(this.update)
...@@ -65,6 +60,7 @@ export default { ...@@ -65,6 +60,7 @@ export default {
update: function () { update: function () {
this.size.width = this.$el.offsetWidth this.size.width = this.$el.offsetWidth
this.size.height = this.$el.offsetHeight this.size.height = this.$el.offsetHeight
this.reset()
} }
}, },
render: function (create) { render: function (create) {
...@@ -94,7 +90,7 @@ export default { ...@@ -94,7 +90,7 @@ export default {
</script> </script>
<style> <style>
@keyframes resizeSensorVisibility { @keyframes once-show {
from { from {
top: 0; top: 0;
} }
...@@ -112,7 +108,7 @@ uni-resize-sensor { ...@@ -112,7 +108,7 @@ uni-resize-sensor {
display: block; display: block;
z-index: -1; z-index: -1;
visibility: hidden; visibility: hidden;
animation-name: resizeSensorVisibility; animation-name: once-show;
} }
uni-resize-sensor > div > div { uni-resize-sensor > div > div {
position: absolute; position: absolute;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册