Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit resize notifications #31

Merged
merged 4 commits into from
Nov 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions cosmoz-tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
},

behaviors: [
Cosmoz.TabbableBehavior,
Cosmoz.TabbedBehavior
Cosmoz.TabbedBehavior,
Cosmoz.TabbableBehavior
],

observers: [
Expand Down Expand Up @@ -104,6 +104,10 @@
value: value,
item: this
});
},

resizerShouldBeNotified(resizable) {
return resizable.parentNode !== this.$.header;
}

});
Expand Down
34 changes: 33 additions & 1 deletion cosmoz-tabbable-behavior.html
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@
opts = {node: item, bubbles: false };

if (index > -1) {
this.async(this.notifyResize);
this.debounce('select-resize', this.notifyResize);

if (!item._previouslySelected) {
this.fire('tab-first-select', {}, opts);
Expand Down Expand Up @@ -210,7 +210,39 @@

_normalizeValue: function (value) {
return this.attrForSelected ? value : isNaN(value) || value === null ? value : Number(value);
},

/**
* True if the current element is visible.
*/
get _isVisible() {
return Boolean(this.offsetWidth || this.offsetHeight);
},

resizerShouldBeNotified() {
return true;
},

_onDescendantIronResize(event) {
if (this._notifyingDescendant || !this._isVisible || !this.resizerShouldBeNotified(event.target)) {
event.stopPropagation();
return;
}

if (Polymer.Settings.useShadow && event.target.domHost === this) {
return;
}

this._fireResize();
},

notifyResize() {
if (!this.isAttached || !this._isVisible) {
return;
}
Polymer.IronResizableBehavior.notifyResize.call(this);
}

};

/** @polymerBehavior */
Expand Down
8 changes: 8 additions & 0 deletions cosmoz-tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,14 @@
}

event.preventDefault();
},

resizerShouldNotify(resizable) {
return resizable.is === 'paper-tabs' || resizable.isSelected;
},

resizerShouldBeNotified(resizable) {
return this.items.indexOf(resizable) > -1 && resizable.isSelected;
}
});
}());