Skip to content

Commit

Permalink
Popover edits
Browse files Browse the repository at this point in the history
  • Loading branch information
turner committed Dec 12, 2023
1 parent 61007c7 commit fb79361
Showing 1 changed file with 36 additions and 34 deletions.
70 changes: 36 additions & 34 deletions js/trackViewport.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ let mouseDownCoords
let lastClickTime = 0
let lastHoverUpdateTime = 0
let popupTimerID
let globalPopoverList
let globalPopoverList = []

let popover

class TrackViewport extends Viewport {

Expand Down Expand Up @@ -48,20 +50,6 @@ class TrackViewport extends Viewport {
this.stopSpinner()
this.addMouseHandlers()

// this.browser.on('willpresentpopover', trackViewport => {
//
// if (trackViewport !== this && globalPopoverList) {
//
// for (let i = 0; i < globalPopoverList.length; i++ ) {
// globalPopoverList[ i ].dispose()
// }
//
// globalPopoverList = undefined
// }
//
// })


}

setContentHeight(contentHeight) {
Expand Down Expand Up @@ -781,22 +769,36 @@ class TrackViewport extends Viewport {
const content = this.getPopupContent(event)
if (content) {

// this.browser.fireEvent('willpresentpopover', [this])
if (false === event.shiftKey) {

if (undefined === globalPopoverList) {
globalPopoverList = []
}
if (popover) {
popover.dispose()
}

if (false === event.shiftKey) {
for (let i = 0; i < globalPopoverList.length; i++ ) {
globalPopoverList[ i ].dispose()
if (globalPopoverList.length > 0) {
for (const gp of globalPopoverList) {
gp.dispose()
}
globalPopoverList = []
}
globalPopoverList = []
}

// Use column element as parent to popover
globalPopoverList.push(new Popover(this.$viewport.get(0).parentElement, true, undefined, undefined))
globalPopoverList[ globalPopoverList.length - 1 ].presentContentWithEvent(event, content)
popover = new Popover(this.$viewport.get(0).parentElement, true, undefined, () => {
popover.dispose()
})

popover.presentContentWithEvent(event, content)
} else {

let po = new Popover(this.$viewport.get(0).parentElement, true, undefined, () => {
const index = globalPopoverList.indexOf(po)
globalPopoverList.splice(index, 1)
po.dispose()
})

globalPopoverList.push( po )

po.presentContentWithEvent(event, content)
}

}
window.clearTimeout(popupTimerID)
Expand Down Expand Up @@ -890,13 +892,13 @@ class TrackViewport extends Viewport {
this.popover.dispose()
}

if (globalPopoverList) {
for (let i = 0; i < globalPopoverList.length; i++ ) {
globalPopoverList[ i ].dispose()
}

globalPopoverList = undefined
}
// if (globalPopoverList) {
// for (let i = 0; i < globalPopoverList.length; i++ ) {
// globalPopoverList[ i ].dispose()
// }
//
// globalPopoverList = undefined
// }

super.dispose()
}
Expand Down

0 comments on commit fb79361

Please sign in to comment.