Polyfills to enable editor positoning on MS Edge (issue #7)
This commit is contained in:
parent
a22068960a
commit
41529a4cd1
|
@ -5,6 +5,8 @@ import SelectionHandler from './selection/SelectionHandler';
|
||||||
import RelationsLayer from './relations/RelationsLayer';
|
import RelationsLayer from './relations/RelationsLayer';
|
||||||
import RelationEditor from './relations/editor/RelationEditor';
|
import RelationEditor from './relations/editor/RelationEditor';
|
||||||
|
|
||||||
|
import './utils/MSEdgePolyfills';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pulls the strings between the annotation highlight layer
|
* Pulls the strings between the annotation highlight layer
|
||||||
* and the editor popup.
|
* and the editor popup.
|
||||||
|
|
|
@ -11,9 +11,9 @@ const setPosition = (wrapperEl, editorEl, annotationBounds) => {
|
||||||
editorEl.style.opacity = 1;
|
editorEl.style.opacity = 1;
|
||||||
|
|
||||||
// Default orientation
|
// Default orientation
|
||||||
const { x, y, height, top, right } = annotationBounds;
|
const { left, top, right, height } = annotationBounds;
|
||||||
editorEl.style.top = `${y + height - containerBounds.top}px`;
|
editorEl.style.top = `${top + height - containerBounds.top}px`;
|
||||||
editorEl.style.left = `${x + scrollX - containerBounds.left}px`;
|
editorEl.style.left = `${left + scrollX - containerBounds.left}px`;
|
||||||
|
|
||||||
const defaultOrientation = editorEl.getBoundingClientRect();
|
const defaultOrientation = editorEl.getBoundingClientRect();
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
if (!Element.prototype.matches) {
|
||||||
|
Element.prototype.matches = Element.prototype.msMatchesSelector ||
|
||||||
|
Element.prototype.webkitMatchesSelector;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Element.prototype.closest) {
|
||||||
|
Element.prototype.closest = function(s) {
|
||||||
|
let el = this;
|
||||||
|
|
||||||
|
do {
|
||||||
|
if (Element.prototype.matches.call(el, s)) return el;
|
||||||
|
el = el.parentElement || el.parentNode;
|
||||||
|
} while (el !== null && el.nodeType === 1);
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in New Issue