-
Notifications
You must be signed in to change notification settings - Fork 1
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -177,7 +177,7 @@ | |
opts = {node: item, bubbles: false }; | ||
|
||
if (index > -1) { | ||
this.async(this.notifyResize); | ||
this.async(this._notifyTabResize); | ||
|
||
if (!item._previouslySelected) { | ||
this.fire('tab-first-select', {}, opts); | ||
|
@@ -210,7 +210,56 @@ | |
|
||
_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); | ||
}, | ||
|
||
_onDescendantIronResize(event) { | ||
if (this._notifyingDescendant || !this._isVisible) { | ||
event.stopPropagation(); | ||
return; | ||
} | ||
const ev = Polymer.dom(event), | ||
item = ev.localTarget, | ||
index = this.items.indexOf(item); | ||
|
||
if (index < 0 || !item.isSelected) { | ||
event.stopPropagation(); | ||
return; | ||
} | ||
|
||
if (!Polymer.Settings.useShadow) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If redefining |
||
this._fireResize(); | ||
} | ||
}, | ||
|
||
resizerShouldNotify(resizable) { | ||
return resizable.is === 'paper-tabs' || resizable.isSelected; | ||
}, | ||
|
||
_notifyTabResize() { | ||
if (!this.isAttached) { | ||
return; | ||
} | ||
|
||
this._interestedResizables.forEach(resizable => { | ||
if (this.resizerShouldNotify(resizable)) { | ||
this._notifyDescendant(resizable); | ||
} | ||
}); | ||
|
||
if (!this._isVisible) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't it be also possible to not notify descendants when |
||
// Fire resize on tab change only if this element is visible | ||
return; | ||
} | ||
this._fireResize(); | ||
} | ||
|
||
}; | ||
|
||
/** @polymerBehavior */ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redefining
_onDescendantIronResize
in tabbable behavior is a bit confusing.Because, looking at
cosmoz-tab
behaviors:one might think this overridden method will also apply to
cosmoz-tab
, which is not the case (because the last behavior takes precedence).So because tabbable behavior is shared between
cosmoz-tabs
andcosmoz-tab
, it would be much clearer if_onDescendantIronResize
was redefined incosmoz-tabs
.