| Index: third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/resize-title-extracted.js
|
| diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/resize-title-extracted.js b/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/resize-title-extracted.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..68c59a55a47f36b3bf404055279af965d6c29fa0
|
| --- /dev/null
|
| +++ b/third_party/polymer/v1_0/components-chromium/app-layout/app-scroll-effects/effects/resize-title-extracted.js
|
| @@ -0,0 +1,76 @@
|
| +(function() {
|
| + function interpolate(progress, points, fn, ctx) {
|
| + fn.apply(ctx, points.map(function(point) {
|
| + return point[0] + (point[1] - point[0]) * progress;
|
| + }));
|
| + }
|
| +
|
| + /**
|
| + * Transform the font size of a designated title element between two values based on the scroll
|
| + * position.
|
| + */
|
| + Polymer.AppLayout.registerEffect('resize-title', {
|
| + /** @this Polymer.AppLayout.ElementWithBackground */
|
| + setUp: function setUp() {
|
| + var title = Polymer.dom(this).querySelector('[title]');
|
| + var condensedTitle = Polymer.dom(this).querySelector('[condensed-title]');
|
| +
|
| + if (!condensedTitle) {
|
| + this._warn(this._logf('effects[resize-title]', 'undefined `condensed-title`'));
|
| + return false;
|
| + }
|
| + if (!title) {
|
| + this._warn(this._logf('effects[resize-title]', 'undefined `title`'));
|
| + return false;
|
| + }
|
| +
|
| + condensedTitle.style.willChange = 'opacity';
|
| + title.style.willChange = 'opacity';
|
| +
|
| + condensedTitle.style.webkitTransform = 'translateZ(0)';
|
| + title.style.webkitTransform = 'translateZ(0)';
|
| +
|
| + var titleClientRect = title.getBoundingClientRect();
|
| + var condensedTitleClientRect = condensedTitle.getBoundingClientRect();
|
| + var fx = {};
|
| +
|
| + fx.scale = parseInt(window.getComputedStyle(condensedTitle)['font-size'], 10) /
|
| + parseInt(window.getComputedStyle(title)['font-size'], 10);
|
| + fx.titleDX = titleClientRect.left - condensedTitleClientRect.left;
|
| + fx.titleDY = titleClientRect.top - condensedTitleClientRect.top;
|
| + fx.condensedTitle = condensedTitle;
|
| + fx.title = title;
|
| +
|
| + this._fxResizeTitle = fx;
|
| + },
|
| + /** @this Polymer.AppLayout.ElementWithBackground */
|
| + tearDown: function tearDown() {
|
| + delete this._fxResizeTitle;
|
| + },
|
| + /** @this PolymerElement */
|
| + run: function run(p, y) {
|
| + var fx = this._fxResizeTitle;
|
| + if (!this.condenses) {
|
| + y = 0;
|
| + }
|
| + if (p >= 1) {
|
| + fx.title.style.opacity = 0;
|
| + fx.condensedTitle.style.opacity = 1;
|
| + } else {
|
| + fx.title.style.opacity = 1;
|
| + fx.condensedTitle.style.opacity = 0;
|
| + }
|
| +
|
| + interpolate(Math.min(1, p),
|
| + [
|
| + [1, fx.scale],
|
| + [0, -fx.titleDX],
|
| + [y, y-fx.titleDY]
|
| + ],
|
| + function(scale, translateX, translateY) {
|
| + this.transform('translate(' + translateX + 'px, ' + translateY + 'px) ' +
|
| + 'scale3d(' + scale + ', ' + scale + ', 1)', fx.title);
|
| + }, this);
|
| + }
|
| + });
|
| + })();
|
|
|