BUG: #149300 - 图标容器添加分页上限
This commit is contained in:
parent
847f2d7032
commit
77dda47765
|
@ -744,7 +744,11 @@ export class GaiaContainer extends StarBaseElement {
|
||||||
if (pagination < 0) return
|
if (pagination < 0) return
|
||||||
let page = this.pages[pagination]
|
let page = this.pages[pagination]
|
||||||
if (!page) {
|
if (!page) {
|
||||||
page = this.addPage()
|
page = this.addPage()!
|
||||||
|
if (!page) {
|
||||||
|
console.error('Append child error!')
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
let proto = HTMLElement.prototype.appendChild
|
let proto = HTMLElement.prototype.appendChild
|
||||||
let func
|
let func
|
||||||
|
@ -1025,6 +1029,8 @@ export class GaiaContainer extends StarBaseElement {
|
||||||
|
|
||||||
addPage(pages?: {page: HTMLElement; shadowPage: HTMLElement}) {
|
addPage(pages?: {page: HTMLElement; shadowPage: HTMLElement}) {
|
||||||
const {page, shadowPage} = pages ?? this.pages.addPage()
|
const {page, shadowPage} = pages ?? this.pages.addPage()
|
||||||
|
if (!page || !shadowPage) return null
|
||||||
|
|
||||||
HTMLElement.prototype.appendChild.call(this, page)
|
HTMLElement.prototype.appendChild.call(this, page)
|
||||||
HTMLElement.prototype.appendChild.call(this, shadowPage)
|
HTMLElement.prototype.appendChild.call(this, shadowPage)
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,8 @@ class GaiaContainerPage {
|
||||||
_suspending: HTMLElement[] = []
|
_suspending: HTMLElement[] = []
|
||||||
_manager: GaiaContainer
|
_manager: GaiaContainer
|
||||||
_shadowPagesMap: WeakMap<HTMLElement, HTMLElement> = new WeakMap()
|
_shadowPagesMap: WeakMap<HTMLElement, HTMLElement> = new WeakMap()
|
||||||
|
// 分页数量上限
|
||||||
|
_limit: number = 15
|
||||||
|
|
||||||
_tail: HTMLElement | undefined
|
_tail: HTMLElement | undefined
|
||||||
_shadowTail: HTMLElement | undefined
|
_shadowTail: HTMLElement | undefined
|
||||||
|
@ -74,6 +76,13 @@ class GaiaContainerPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
addPage = () => {
|
addPage = () => {
|
||||||
|
if (this._pages.length >= this._limit) {
|
||||||
|
console.info('The number of pages reaches the limit!')
|
||||||
|
return {
|
||||||
|
page: null,
|
||||||
|
shadowPage: null,
|
||||||
|
}
|
||||||
|
}
|
||||||
const div = document.createElement('div')
|
const div = document.createElement('div')
|
||||||
const pagination = `${this._pages.length}`
|
const pagination = `${this._pages.length}`
|
||||||
div.className = `gaia-container-page`
|
div.className = `gaia-container-page`
|
||||||
|
@ -106,6 +115,10 @@ class GaiaContainerPage {
|
||||||
addTail = () => {
|
addTail = () => {
|
||||||
if (!this._tail || !this._shadowTail || this._tail.children.length) {
|
if (!this._tail || !this._shadowTail || this._tail.children.length) {
|
||||||
const pages = this.addPage()
|
const pages = this.addPage()
|
||||||
|
if (!pages.page || !pages.shadowPage) {
|
||||||
|
console.log('Can not add the page!')
|
||||||
|
return
|
||||||
|
}
|
||||||
this._tail = pages.page
|
this._tail = pages.page
|
||||||
this._suspending.push(this._tail)
|
this._suspending.push(this._tail)
|
||||||
this._shadowTail = pages.shadowPage
|
this._shadowTail = pages.shadowPage
|
||||||
|
|
Loading…
Reference in New Issue