Skip to content

Commit

Permalink
change: toggle popup on touchstart
Browse files Browse the repository at this point in the history
  • Loading branch information
eddieantonio committed Jun 17, 2020
1 parent 443cc3c commit 3fdc6a3
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {createPopper} from '@popperjs/core/dist/esm/popper'

const showEvents = ['mouseenter', 'focus']
const hideEvents = ['mouseleave', 'blur']
const toggleEvents = ['touchstart']

let popperInstance = null

Expand Down Expand Up @@ -50,4 +51,16 @@ export function createTooltip(icon, popup) {
destroy()
})
}

for (let event of toggleEvents) {
icon.addEventListener(event, () => {
if (popup.hasAttribute('data-show')) {
popup.removeAttribute('data-show')
destroy()
} else {
popup.setAttribute('data-show', '')
create(icon, popup)
}
})
}
}

0 comments on commit 3fdc6a3

Please # to comment.