Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1603)

Unified Diff: third_party/polymer/v1_0/components-chromium/iron-fit-behavior/iron-fit-behavior-extracted.js

Issue 1766433002: Roll Polymer to 1.3.1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/polymer/v1_0/components-chromium/iron-fit-behavior/iron-fit-behavior-extracted.js
diff --git a/third_party/polymer/v1_0/components-chromium/iron-fit-behavior/iron-fit-behavior-extracted.js b/third_party/polymer/v1_0/components-chromium/iron-fit-behavior/iron-fit-behavior-extracted.js
index e6ebe2ebdcfdd7263787cc7455184ffb7a3dbb1e..562b67c0670005dbe8f843fa0cbfc10acaea5d8d 100644
--- a/third_party/polymer/v1_0/components-chromium/iron-fit-behavior/iron-fit-behavior-extracted.js
+++ b/third_party/polymer/v1_0/components-chromium/iron-fit-behavior/iron-fit-behavior-extracted.js
@@ -157,14 +157,14 @@ CSS properties | Action
* the memoized data.
*/
resetFit: function() {
- if (!this._fitInfo || !this._fitInfo.sizedBy.height) {
- this.sizingTarget.style.maxHeight = '';
- this.style.top = this._fitInfo ? this._fitInfo.inlineStyle.top : '';
- }
if (!this._fitInfo || !this._fitInfo.sizedBy.width) {
this.sizingTarget.style.maxWidth = '';
- this.style.left = this._fitInfo ? this._fitInfo.inlineStyle.left : '';
}
+ if (!this._fitInfo || !this._fitInfo.sizedBy.height) {
+ this.sizingTarget.style.maxHeight = '';
+ }
+ this.style.top = this._fitInfo ? this._fitInfo.inlineStyle.top : '';
+ this.style.left = this._fitInfo ? this._fitInfo.inlineStyle.left : '';
if (this._fitInfo) {
this.style.position = this._fitInfo.positionedBy.css;
}
@@ -225,18 +225,30 @@ CSS properties | Action
* `position:fixed`.
*/
center: function() {
- if (!this._fitInfo.positionedBy.vertically || !this._fitInfo.positionedBy.horizontally) {
- // need position:fixed to center
- this.style.position = 'fixed';
+ var positionedBy = this._fitInfo.positionedBy;
+ if (positionedBy.vertically && positionedBy.horizontally) {
+ // Already positioned.
+ return;
}
- if (!this._fitInfo.positionedBy.vertically) {
- var top = (this._fitHeight - this.offsetHeight) / 2 + this._fitTop;
- top -= this._fitInfo.margin.top;
+ // Need position:fixed to center
+ this.style.position = 'fixed';
+ // Take into account the offset caused by parents that create stacking
+ // contexts (e.g. with transform: translate3d). Translate to 0,0 and
+ // measure the bounding rect.
+ if (!positionedBy.vertically) {
+ this.style.top = '0px';
+ }
+ if (!positionedBy.horizontally) {
+ this.style.left = '0px';
+ }
+ // It will take in consideration margins and transforms
+ var rect = this.getBoundingClientRect();
+ if (!positionedBy.vertically) {
+ var top = this._fitTop - rect.top + (this._fitHeight - rect.height) / 2;
this.style.top = top + 'px';
}
- if (!this._fitInfo.positionedBy.horizontally) {
- var left = (this._fitWidth - this.offsetWidth) / 2 + this._fitLeft;
- left -= this._fitInfo.margin.left;
+ if (!positionedBy.horizontally) {
+ var left = this._fitLeft - rect.left + (this._fitWidth - rect.width) / 2;
this.style.left = left + 'px';
}
}

Powered by Google App Engine
This is Rietveld 408576698