UNPKG

api-console-assets

Version:

This repo only exists to publish api console components to npm

43 lines (40 loc) 1.79 kB
<!-- @license Copyright (c) 2016 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt --> <link rel="import" href="../app-scroll-effects-behavior.html"> <script> /** * While scrolling down, fade in the rear background layer and fade out the front background * layer (opacity interpolated based on scroll position). */ Polymer.AppLayout.registerEffect('blend-background', { /** @this Polymer.AppLayout.ElementWithBackground */ setUp: function setUp() { var fx = {}; fx.backgroundFrontLayer = this._getDOMRef('backgroundFrontLayer'); fx.backgroundRearLayer = this._getDOMRef('backgroundRearLayer'); fx.backgroundFrontLayer.style.willChange = 'opacity'; fx.backgroundFrontLayer.style.transform = 'translateZ(0)'; fx.backgroundRearLayer.style.willChange = 'opacity'; fx.backgroundRearLayer.style.transform = 'translateZ(0)'; fx.backgroundRearLayer.style.opacity = 0; this._fxBlendBackground = fx; }, /** @this Polymer.AppLayout.ElementWithBackground */ run: function run(p, y) { var fx = this._fxBlendBackground; fx.backgroundFrontLayer.style.opacity = 1 - p; fx.backgroundRearLayer.style.opacity = p; }, /** @this Polymer.AppLayout.ElementWithBackground */ tearDown: function tearDown() { delete this._fxBlendBackground; } }); </script>