Skip to content

Commit

Permalink
Allow document.fullscreenElement to be tether's element parent. Other…
Browse files Browse the repository at this point in the history
…wise tether is not visible when a non-BODY element is fullscreen. It's because tether reattaches itself to BODY and no BODY's descendant is visible except fullscreenElement.
  • Loading branch information
sergey-su committed Sep 27, 2018
1 parent 192ab8a commit 4ca3d2e
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tether",
"version": "1.4.4",
"version": "1.4.5",
"homepage": "http://github.hubspot.com/tether",
"authors": [
"Zack Bloom <zackbloom@gmail.com>",
Expand Down
9 changes: 8 additions & 1 deletion dist/js/tether.js
Original file line number Diff line number Diff line change
Expand Up @@ -1252,9 +1252,16 @@ var TetherClass = (function (_Evented) {
this.options.bodyElement.appendChild(this.element);
}
} else {
var isFullscreenElement = function isFullscreenElement(e) {
var d = e.ownerDocument;
var fe = d.fullscreenElement || d.webkitFullscreenElement || d.mozFullScreenElement || d.msFullscreenElement;
return fe === e;
};

var offsetParentIsBody = true;

var currentNode = this.element.parentNode;
while (currentNode && currentNode.nodeType === 1 && currentNode.tagName !== 'BODY') {
while (currentNode && currentNode.nodeType === 1 && currentNode.tagName !== 'BODY' && !isFullscreenElement(currentNode)) {
if (getComputedStyle(currentNode).position !== 'static') {
offsetParentIsBody = false;
break;
Expand Down
2 changes: 1 addition & 1 deletion dist/js/tether.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tether",
"version": "1.4.4",
"version": "1.4.5",
"description": "A client-side library to make absolutely positioned elements attach to elements in the page efficiently.",
"authors": [
"Zack Bloom <zackbloom@gmail.com>",
Expand Down
7 changes: 6 additions & 1 deletion src/js/tether.js
Original file line number Diff line number Diff line change
Expand Up @@ -765,8 +765,13 @@ class TetherClass extends Evented {
}
} else {
let offsetParentIsBody = true;
function isFullscreenElement(e) {
let d = e.ownerDocument;
let fe = d.fullscreenElement || d.webkitFullscreenElement || d.mozFullScreenElement || d.msFullscreenElement;
return fe === e;
}
let currentNode = this.element.parentNode;
while (currentNode && currentNode.nodeType === 1 && currentNode.tagName !== 'BODY') {
while (currentNode && currentNode.nodeType === 1 && currentNode.tagName !== 'BODY' && !isFullscreenElement(currentNode)) {
if (getComputedStyle(currentNode).position !== 'static') {
offsetParentIsBody = false;
break;
Expand Down

0 comments on commit 4ca3d2e

Please sign in to comment.