Skip to content

Instantly share code, notes, and snippets.

@nicolocarpignoli
Created November 1, 2019 10:28
Show Gist options
  • Save nicolocarpignoli/a99362f659937a657da5d6761bdb9474 to your computer and use it in GitHub Desktop.
Save nicolocarpignoli/a99362f659937a657da5d6761bdb9474 to your computer and use it in GitHub Desktop.
// 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