Skip to content

Commit

Permalink
revise $forceUpdate
Browse files Browse the repository at this point in the history
  • Loading branch information
Kenneth Cheng committed May 2, 2023
1 parent 17c4721 commit e8a6f7c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vue3-excel-editor",
"email": "[email protected]",
"description": "Vue3 plugin for displaying and editing the array-of-object in Excel style",
"version": "1.0.17",
"version": "1.0.18",
"main": "src/main.js",
"dependencies": {
"@vuepic/vue-datepicker": "^3.3.0",
Expand Down
32 changes: 19 additions & 13 deletions src/VueExcelEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,8 @@ export default {
})
if (valid) {
this.fields = newFields
this.$forceUpdate()
const instance = getCurrentInstance()
instance?.proxy?.$forceUpdate()
}
}
}
Expand Down Expand Up @@ -890,7 +891,8 @@ export default {
else if (this.leftMost === -1) this.leftMost = left
}
})
this.$forceUpdate()
const instance = getCurrentInstance()
instance?.proxy?.$forceUpdate()
},
renderColumnCellStyle (field) {
let result = field.initStyle
Expand Down Expand Up @@ -1110,7 +1112,8 @@ export default {
this.vScroller.buttonHeight = Math.max(24, this.vScroller.height * ratio)
const prop = (this.tableContent.scrollTop + this.pageTop * 24) / (this.table.length * 24 - this.vScroller.height)
this.vScroller.buttonTop = (this.vScroller.height - this.vScroller.buttonHeight) * prop
this.$forceUpdate()
const instance = getCurrentInstance()
instance?.proxy?.$forceUpdate()
},
vsMouseDown (e) {
e.stopPropagation()
Expand Down Expand Up @@ -1149,7 +1152,8 @@ export default {
this.pageTop = Math.round((this.table.length - this.pageSize) * ratio)
}
this.vScroller.runner = ''
this.$forceUpdate()
const instance = getCurrentInstance()
instance?.proxy?.$forceUpdate()
},
vsbMouseMove (e) {
if (e.buttons === 0)
Expand All @@ -1171,7 +1175,8 @@ export default {
.filter((field, i) => field.keyField || field.sticky || this.sortPos === i)
.map(field => field.label + ': ' + rec[field.name])
.join('<br>')
this.$forceUpdate()
const instance = getCurrentInstance()
instance?.proxy?.$forceUpdate()
}
}
},
Expand All @@ -1198,14 +1203,15 @@ export default {
}
},
sbMouseUp () {
window.removeEventListener('mousemove', this.sbMouseMove)
window.removeEventListener('mouseup', this.sbMouseUp)
this.lazy(() => {
if (!this.$refs.hScroll) return
this.$refs.hScroll.classList.remove('focus')
})
this.hScroller.mouseX = 0
this.$forceUpdate()
window.removeEventListener('mousemove', this.sbMouseMove)
window.removeEventListener('mouseup', this.sbMouseUp)
this.lazy(() => {
if (!this.$refs.hScroll) return
this.$refs.hScroll.classList.remove('focus')
})
this.hScroller.mouseX = 0
const instance = getCurrentInstance()
instance?.proxy?.$forceUpdate()
},
sbMouseMove (e) {
if (e.buttons === 0)
Expand Down

0 comments on commit e8a6f7c

Please sign in to comment.