Skip to content

Commit

Permalink
Improve custom transformation comments
Browse files Browse the repository at this point in the history
Added additional comments to help explain what is happening. Also added
variable maxMiddleScale to make it easier to change size of condensed
appName. Per @addyosmani comment.
  • Loading branch information
chuckh authored and addyosmani committed Jul 9, 2015
1 parent 27942a3 commit de57e68
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 7 additions & 3 deletions app/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,19 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
// imports are loaded and elements have been registered
});

// Custom transformation: scale header's titles
// Main area's paper-scroll-header-panel custom condensing transformation of
// the appName in the middle-container and the bottom title in the bottom-container.
// The appName is moved to top and shrunk on condensing. The bottom sub title
// is shrunk to nothing on condensing.
addEventListener('paper-header-transform', function(e) {
var appName = document.querySelector('.app-name');
var middleContainer = document.querySelector('.middle-container');
var bottomContainer = document.querySelector('.bottom-container');
var detail = e.detail;
var heightDiff = detail.height - detail.condensedHeight;
var yRatio = Math.min(1, detail.y / heightDiff);
var scaleMiddle = Math.max(0.50, (heightDiff - detail.y) / (heightDiff / 0.50) + 0.50);
var maxMiddleScale = 0.50; // appName max size when condensed. The smaller the number the smaller the condensed size.
var scaleMiddle = Math.max(maxMiddleScale, (heightDiff - detail.y) / (heightDiff / (1-maxMiddleScale)) + maxMiddleScale);
var scaleBottom = 1 - yRatio;

// Move/translate middleContainer
Expand All @@ -47,7 +51,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
// Scale bottomContainer and bottom sub title to nothing and back
Polymer.Base.transform('scale(' + scaleBottom + ') translateZ(0)', bottomContainer);

// Scale middle app name
// Scale middleContainer appName
Polymer.Base.transform('scale(' + scaleMiddle + ') translateZ(0)', appName);
});

Expand Down
2 changes: 2 additions & 0 deletions app/styles/app-theme.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
paper-toolbar.tall .app-name {
font-size: 40px;
font-weight: 300;
/* Required for main area's paper-scroll-header-panel custom condensing transformation */
-webkit-transform-origin: left center;
transform-origin: left center;
}
Expand All @@ -116,6 +117,7 @@

#mainToolbar .bottom {
margin-left: 48px;
/* Required for main area's paper-scroll-header-panel custom condensing transformation */
-webkit-transform-origin: left center;
transform-origin: left center;
}
Expand Down

0 comments on commit de57e68

Please sign in to comment.