goodpals / middle-english-mouse-dictionary

A browser extension to facilitate the reading of Middle English texts.
https://addons.mozilla.org/en-GB/firefox/addon/memd/
GNU Affero General Public License v3.0
7 stars 0 forks source link

double-click info popup boundary controls #3

Closed CallumBeaney closed 10 months ago

CallumBeaney commented 1 year ago
function createPopup(event, info) {
  let popup = document.createElement('div');
  popup.className = 'singleWordInfoPopup';
  popup.innerHTML = info;

  /// TODO: when near the browser window edge this can create an element that partially spills outside of the DOM
  popup.style.position = 'absolute';
  popup.style.left = (event.clientX + window.scrollX - 100) + 'px';
  popup.style.top = (event.clientY + window.scrollY + 15) + 'px';

  document.body.appendChild(popup);

  document.addEventListener('click', function(event) {
    document.removeEventListener('click', this);
    popup.remove();
  });
}
CallumBeaney commented 10 months ago

Fixed as of https://github.com/goodpals/middle-english-mouse-dictionary/commit/ec2131501da68b19aef14db5b8df299d87559642

Hacky fix -- will revisit later see if more elegant/non-JS way of doing it exists