Focus du resultat dans la liste et dans l'URL
This commit is contained in:
parent
7d45e2f717
commit
af337ea0bf
2 changed files with 26 additions and 12 deletions
|
|
@ -147,7 +147,11 @@ export class BidiPanelElement extends HTMLElement {
|
|||
let progress = this.contentContainer.scrollLeft / (this.contentContainer.scrollWidth - thisGeometry.width)
|
||||
let focusedElementIndex = Math.floor(progress * this.children.length)
|
||||
if(Number.isFinite(focusedElementIndex)){
|
||||
return focusedElementIndex
|
||||
if(focusedElementIndex == this.children.length){
|
||||
return this.children.length - 1
|
||||
} else {
|
||||
return focusedElementIndex
|
||||
}
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
|
|
@ -193,14 +197,20 @@ export class BidiPanelElement extends HTMLElement {
|
|||
if(Number.isFinite(newIndex)){
|
||||
this.setActiveChildrenIndex(newIndex, {behavior: "instant"})
|
||||
}
|
||||
this.requestDispatchChangeEvent()
|
||||
}
|
||||
|
||||
handleContentScroll(e){
|
||||
this.updateProgress()
|
||||
this.#currentIndex = this.activeChildrenIndex
|
||||
if(this.#currentIndex != this.#lastActive){
|
||||
this.requestDispatchChangeEvent()
|
||||
}
|
||||
|
||||
requestDispatchChangeEvent(){
|
||||
let currentPanel = this.activeChildren
|
||||
if(currentPanel != this.#lastActive){
|
||||
this.dispatchEvent(new ActivePanelChangeEvent("activePanelChange", this.#currentIndex))
|
||||
this.#lastActive = this.#currentIndex
|
||||
this.#lastActive = currentPanel
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue