Skip to content

Commit

Permalink
Merge pull request #27 from Brightspace/dbatiste/visible-on-ancestor-…
Browse files Browse the repository at this point in the history
…uninit-fix

Fix for unit of visible-on-ancestor to ensure init/uninit do not run …
  • Loading branch information
dbatiste authored Aug 20, 2018
2 parents 3c77b7a + bc730d4 commit a89c0cf
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions d2l-visible-on-ancestor-behavior.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@
},

__voaHandleVisibleOnAncestor: function(newValue, oldValue) {
if (newValue) {
requestAnimationFrame(function() {
requestAnimationFrame(function() {
if (newValue) {
this.__voaInit();
}.bind(this));
} else if (oldValue) {
this.__voaUninit();
}
} else if (oldValue) {
this.__voaUninit();
}
}.bind(this));
},

__voaHide: function() {
Expand All @@ -105,6 +105,8 @@

__voaInit: function() {

if (!this.visibleOnAncestor) return;

this.__voaTarget = D2L.Dom.findComposedAncestor(this, function(node) {
if (!node || node.nodeType !== 1) return false;
return (node.classList.contains('d2l-visible-on-ancestor-target'));
Expand Down

0 comments on commit a89c0cf

Please sign in to comment.