/**
@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
*/
import"../../polymer/polymer-legacy.js";export const _scrollEffects={};export let _scrollTimer=null;export const scrollTimingFunction=function easeOutQuad(e,o,r,t){return-r*(e/=t)*(e-2)+o};export const registerEffect=function registerEffect(e,o){if(null!=_scrollEffects[e])throw new Error("effect `"+e+"` is already registered.");_scrollEffects[e]=o};export const queryAllRoot=function(e,o){for(var r=[o],t=[];r.length>0;){var l=r.shift();t.push.apply(t,l.querySelectorAll(e));for(var n=0;l.children[n];n++)l.children[n].shadowRoot&&r.push(l.children[n].shadowRoot)}return t};export const scroll=function scroll(e){e=e||{};var o=document.documentElement,r=e.target||o,t="scrollBehavior"in r.style&&r.scroll,l=e.top||0,n=e.left||0,c=r===o?window.scrollTo:function scrollTo(e,o){r.scrollLeft=e,r.scrollTop=o};if("smooth"===e.behavior)if(t)r.scroll(e);else{var s=scrollTimingFunction,i=Date.now(),a=r===o?window.pageYOffset:r.scrollTop,f=r===o?window.pageXOffset:r.scrollLeft,u=l-a,m=n-f;(function updateFrame(){var e=Date.now()-i;e<300?(c(s(e,f,m,300),s(e,a,u,300)),requestAnimationFrame(updateFrame)):c(n,l)}).bind(this)()}else if("silent"===e.behavior){var p=queryAllRoot("app-header",document.body);p.forEach((function(e){e.setAttribute("silent-scroll","")})),_scrollTimer&&window.cancelAnimationFrame(_scrollTimer),_scrollTimer=window.requestAnimationFrame((function(){p.forEach((function(e){e.removeAttribute("silent-scroll")})),_scrollTimer=null})),c(n,l)}else c(n,l)};export class ElementWithBackground{isContentBelow(){}isOnScreen(){}_getDOMRef(e){}}