Skip to content

Commit 2f398e6

Browse files
committed
Simplify transformed-fixed-tooltip detection
Now that browsers seem to properly set offsetParent to null for fixed elements. FIX: Make detection of transformed tooltip parent elements (forcing absolute positioning) more robust on current browsers. Issue #74
1 parent 05e9b66 commit 2f398e6

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/tooltip.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -254,16 +254,16 @@ const tooltipPlugin = ViewPlugin.fromClass(class {
254254
let scaleX = 1, scaleY = 1, makeAbsolute = false
255255
if (this.position == "fixed" && this.manager.tooltipViews.length) {
256256
let {dom} = this.manager.tooltipViews[0]
257-
if (browser.gecko) {
258-
// Firefox sets the element's `offsetParent` to the
259-
// transformed element when a transform interferes with fixed
260-
// positioning.
261-
makeAbsolute = dom.offsetParent != this.container.ownerDocument.body
262-
} else if (dom.style.top == Outside && dom.style.left == "0px") {
263-
// On other browsers, we have to awkwardly try and use other
264-
// information to detect a transform.
257+
if (browser.safari) {
258+
// Safari always sets offsetParent to null, even if a fixed
259+
// element is positioned relative to a transformed parent. So
260+
// we use this kludge to try and detect this.
265261
let rect = dom.getBoundingClientRect()
266262
makeAbsolute = Math.abs(rect.top + 10000) > 1 || Math.abs(rect.left) > 1
263+
} else {
264+
// More conforming browsers will set offsetParent to the
265+
// transformed element.
266+
makeAbsolute = !!dom.offsetParent && dom.offsetParent != this.container.ownerDocument.body
267267
}
268268
}
269269
if (makeAbsolute || this.position == "absolute") {

0 commit comments

Comments
 (0)