Skip to content

Commit a28eb11

Browse files
author
Kenneth Cheng
committed
fine-tune the recal of pagesize
1 parent 93b52a8 commit a28eb11

File tree

3 files changed

+36
-10
lines changed

3 files changed

+36
-10
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.49",
5+
"version": "1.0.51",
66
"main": "src/main.js",
77
"dependencies": {
88
"@vuepic/vue-datepicker": "^3.3.0",

src/VueExcelEditor.vue

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1776,16 +1776,36 @@ export default defineComponent({
17761776
const scrollerWidth = this.$refs.hScroll.getBoundingClientRect().width
17771777
this.hScroller.scrollerUnseenWidth = this.footer.getBoundingClientRect().width - this.numColWidth - scrollerWidth
17781778
}
1779+
1780+
let outerElement = this.editor.parentElement
1781+
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
1788+
}
1789+
if (outerElement) {
1790+
bottomOffset += parseInt(style.paddingBottom)
1791+
bottomOffset += parseInt(style.borderBottomWidth)
1792+
}
1793+
1794+
const outerHeight = outerElement?.clientHeight || window.innerHeight
1795+
const outerTop = outerElement?.getBoundingClientRect().top || 0
1796+
17791797
if (!this.noPaging) {
1780-
const offset = this.summaryRow ? 60 : 35
1781-
let controlHeight = window.innerHeight - this.recordBody.getBoundingClientRect().top - offset
1782-
const height = this.height.replace(/px/,'') * 1 + this.systable.getBoundingClientRect().top - this.recordBody.getBoundingClientRect().top
1783-
if (this.height && controlHeight > height) controlHeight = height
1798+
const offset = bottomOffset + (this.summaryRow ? 25 : 0) + (this.noFooter ? 0 : 25)
1799+
let controlHeight = outerHeight - (this.recordBody.getBoundingClientRect().top - outerTop) - offset
1800+
1801+
if (this.height) {
1802+
const height = parseInt(this.height) + this.systable.getBoundingClientRect().top - this.recordBody.getBoundingClientRect().top
1803+
if (controlHeight > height) controlHeight = height
1804+
}
17841805
this.pageSize = this.page || Math.floor(controlHeight / 24)
1785-
// this.pageSize = this.page || Math.floor((this.systable.parentNode.style.height - this.recordBody.getBoundingClientRect().top - offset) / 24)
17861806
}
17871807
else if (this.height === 'auto') {
1788-
let h = Math.floor((window.innerHeight - this.tableContent.getBoundingClientRect().top - 25))
1808+
let h = Math.floor(window.innerHeight - this.tableContent.getBoundingClientRect().top - 25)
17891809
let offset = 4
17901810
if (this.filterRow) offset += 29
17911811
if (this.summaryRow) offset += 25
@@ -3216,9 +3236,12 @@ input:focus, input:active:focus, input.active:focus {
32163236
}
32173237
.footer-left {
32183238
position: absolute;
3219-
left: calc(v-bind(numColWidth)*1px);
3239+
left: 40px;
32203240
margin-left: 6px;
32213241
}
3242+
.no-number .footer-left {
3243+
left: 0px;
3244+
}
32223245
.footer-right {
32233246
position: absolute;
32243247
right: 6px;
@@ -3228,10 +3251,13 @@ input:focus, input:active:focus, input.active:focus {
32283251
position: absolute;
32293252
background-color: #f4f6f9;
32303253
height: 25px;
3231-
margin-left: calc(v-bind(numColWidth)*1px);
3254+
margin-left: 40px;
32323255
width: 65%;
32333256
cursor: pointer;
32343257
}
3258+
.no-number .h-scroll {
3259+
margin-left: 0px;
3260+
}
32353261
.h-scroll:hover, .h-scroll.focus, .footer:hover .h-scroll {
32363262
background-color: lightgray;
32373263
}

0 commit comments

Comments
 (0)