Created
November 1, 2019 10:28
-
-
Save nicolocarpignoli/a99362f659937a657da5d6761bdb9474 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this click listener has to be added simply to a click event on an a-entity element | |
const clickListener = function (ev) { | |
ev.stopPropagation(); | |
ev.preventDefault(); | |
const name = ev.target.getAttribute('name'); | |
const el = ev.detail.intersection && ev.detail.intersection.object.el; | |
if (el && el === ev.target) { | |
// after click, we are adding a label with the name of the place | |
const label = document.createElement('span'); | |
const container = document.createElement('div'); | |
container.setAttribute('id', 'place-label'); | |
label.innerText = name; | |
container.appendChild(label); | |
document.body.appendChild(container); | |
setTimeout(() => { | |
// that will disappear after less than 2 seconds | |
container.parentElement.removeChild(container); | |
}, 1500); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment