Skip to content

Commit 357c1be

Browse files
author
Kenneth Cheng
committed
revise refreshPageSize
1 parent 0ce4917 commit 357c1be

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "vue3-excel-editor",
33
"email": "apple.6502@gmail.com",
44
"description": "Vue3 plugin for displaying and editing the array-of-object in Excel style",
5-
"version": "1.0.55",
5+
"version": "1.0.56",
66
"main": "src/main.js",
77
"dependencies": {
88
"@vuepic/vue-datepicker": "^3.3.0",

src/VueExcelEditor.vue

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ export default defineComponent({
620620
this.calStickyLeft()
621621
}, 200)
622622
623-
if (ResizeObserver) new ResizeObserver(this.winResize).observe(this.tableContent)
623+
if (ResizeObserver) new ResizeObserver(this.winResize).observe(this.editor)
624624
window.addEventListener('resize', this.winResize)
625625
window.addEventListener('paste', this.winPaste)
626626
window.addEventListener('keydown', this.winKeydown)
@@ -1777,14 +1777,16 @@ export default defineComponent({
17771777
this.hScroller.scrollerUnseenWidth = this.footer.getBoundingClientRect().width - this.numColWidth - scrollerWidth
17781778
}
17791779
1780-
let outerElement = this.editor.parentElement
1780+
let outerElement = this.editor
17811781
let bottomOffset = 0
1782-
while (outerElement && !outerElement.style.height && outerElement.style.height !== 'auto') {
1783-
const style = getComputedStyle(outerElement)
1784-
bottomOffset += parseInt(style.marginBottom)
1785-
bottomOffset += parseInt(style.paddingBottom)
1786-
bottomOffset += parseInt(style.borderBottomWidth)
1787-
outerElement = outerElement.parentElement
1782+
if (this.height !== 'auto') {
1783+
while (outerElement && !outerElement.style.height && outerElement.style.height !== 'auto') {
1784+
const style = getComputedStyle(outerElement)
1785+
bottomOffset += parseInt(style.marginBottom)
1786+
bottomOffset += parseInt(style.paddingBottom)
1787+
bottomOffset += parseInt(style.borderBottomWidth)
1788+
outerElement = outerElement.parentElement
1789+
}
17881790
}
17891791
if (outerElement) {
17901792
const style = getComputedStyle(outerElement)
@@ -1800,8 +1802,15 @@ export default defineComponent({
18001802
let controlHeight = outerHeight - (this.recordBody.getBoundingClientRect().top - outerTop) - offset
18011803
18021804
if (this.height) {
1803-
const height = parseInt(this.height) + this.systable.getBoundingClientRect().top - this.recordBody.getBoundingClientRect().top
1804-
if (controlHeight > height) controlHeight = height
1805+
if (this.height === 'auto') {
1806+
const p = this.editor.parentElement
1807+
if (p && p.scrollHeight > p.clientHeight)
1808+
controlHeight += p.clientHeight - p.scrollHeight
1809+
}
1810+
else {
1811+
const height = parseInt(this.height) + this.systable.getBoundingClientRect().top - this.recordBody.getBoundingClientRect().top
1812+
if (controlHeight > height) controlHeight = height
1813+
}
18051814
}
18061815
this.pageSize = this.page || Math.floor(controlHeight / 24)
18071816
}

0 commit comments

Comments
 (0)