diff --git a/resources/script/polymer/app-layout/.bower.json b/resources/script/polymer/app-layout/.bower.json index 61dd0f23f..981dccb8e 100644 --- a/resources/script/polymer/app-layout/.bower.json +++ b/resources/script/polymer/app-layout/.bower.json @@ -1,54 +1,54 @@ { "name": "app-layout", - "version": "0.10.2", + "version": "0.10.6", "description": "A set of layout elements for your app", "authors": [ "The Polymer Authors" ], - "private": true, + "license": "https://polymer.github.io/LICENSE.txt", "homepage": "https://github.com/PolymerElements/app-layout", "repository": { "type": "git", "url": "git://github.com/PolymerElements/app-layout" }, "main": "app-layout.html", - "license": "http://polymer.github.io/LICENSE.txt", - "ignore": [], "dependencies": { - "polymer": "polymer/polymer#^1.6.0", - "iron-flex-layout": "polymerelements/iron-flex-layout#^1.0.0", - "iron-media-query": "polymerelements/iron-media-query#^1.0.0", - "iron-resizable-behavior": "polymerelements/iron-resizable-behavior#^1.0.0", - "iron-scroll-target-behavior": "polymerelements/iron-scroll-target-behavior#^1.0.0" + "iron-flex-layout": "PolymerElements/iron-flex-layout#^1.0.0", + "iron-media-query": "PolymerElements/iron-media-query#^1.0.0", + "iron-resizable-behavior": "PolymerElements/iron-resizable-behavior#^1.0.0", + "iron-scroll-target-behavior": "PolymerElements/iron-scroll-target-behavior#^1.0.0", + "polymer": "Polymer/polymer#^1.6.0" }, "devDependencies": { - "font-roboto": "polymerelements/font-roboto#^1.0.0", - "iron-component-page": "polymerelements/iron-component-page#^1.0.0", - "iron-icon": "polymerelements/iron-icon#^1.0.0", - "iron-icons": "polymerelements/iron-icons#^1.0.0", - "iron-list": "polymerelements/iron-list#^1.0.0", - "iron-pages": "polymerelements/iron-pages#^1.0.0", - "iron-scroll-threshold": "polymerelements/iron-scroll-threshold#^1.0.0", - "paper-card": "polymerelements/paper-card#^1.0.0", - "paper-fab": "polymerelements/paper-fab#^1.0.0", - "paper-icon-button": "polymerelements/paper-icon-button#^1.0.0", - "paper-item": "polymerelements/paper-item#^1.0.0", - "paper-menu": "polymerelements/paper-menu#^1.0.0", - "paper-tabs": "polymerelements/paper-tabs#^1.0.0", - "paper-progress": "polymerelements/paper-progress#~1.0.2", - "paper-styles": "polymerelements/paper-styles#^1.0.0", - "paper-spinner": "polymerelements/paper-spinner#^1.0.0", - "test-fixture": "polymerelements/test-fixture#^1.0.0", - "webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0", - "web-component-tester": "^4.0.0" + "font-roboto": "PolymerElements/font-roboto#^1.0.0", + "iron-component-page": "PolymerElements/iron-component-page#^1.0.0", + "iron-icon": "PolymerElements/iron-icon#^1.0.0", + "iron-icons": "PolymerElements/iron-icons#^1.0.0", + "iron-list": "PolymerElements/iron-list#^1.0.0", + "iron-pages": "PolymerElements/iron-pages#^1.0.0", + "iron-scroll-threshold": "PolymerElements/iron-scroll-threshold#^1.0.0", + "paper-card": "PolymerElements/paper-card#^1.0.0", + "paper-fab": "PolymerElements/paper-fab#^1.0.0", + "paper-icon-button": "PolymerElements/paper-icon-button#^1.0.0", + "paper-item": "PolymerElements/paper-item#^1.0.0", + "paper-menu": "PolymerElements/paper-menu#^1.0.0", + "paper-progress": "PolymerElements/paper-progress#~1.0.2", + "paper-spinner": "PolymerElements/paper-spinner#^1.0.0", + "paper-styles": "PolymerElements/paper-styles#^1.0.0", + "paper-tabs": "PolymerElements/paper-tabs#^1.0.0", + "test-fixture": "PolymerElements/test-fixture#^1.0.0", + "web-component-tester": "^4.0.0", + "webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0" }, - "_release": "0.10.2", + "ignore": [], + "private": true, + "_release": "0.10.6", "_resolution": { "type": "version", - "tag": "v0.10.2", - "commit": "65311d2e5447b5f82018d01dc308c216cecd9d71" + "tag": "v0.10.6", + "commit": "0d8311c582c2e83d7443b3952752abcd6354fe33" }, - "_source": "git://github.com/polymerelements/app-layout.git", + "_source": "https://github.com/polymerelements/app-layout.git", "_target": "^0.10.1", "_originalSource": "polymerelements/app-layout" } \ No newline at end of file diff --git a/resources/script/polymer/app-layout/.travis.yml b/resources/script/polymer/app-layout/.travis.yml index 8ebcbaa8a..d8113221a 100644 --- a/resources/script/polymer/app-layout/.travis.yml +++ b/resources/script/polymer/app-layout/.travis.yml @@ -1,22 +1,23 @@ language: node_js sudo: required dist: trusty -node_js: stable +node_js: '6' addons: - sauce_connect: true - firefox: '46.0' + firefox: latest apt: sources: - - google-chrome + - google-chrome packages: - - google-chrome-stable + - google-chrome-stable before_script: -- npm install -g bower polylint web-component-tester -- bower install + - npm install -g bower polylint web-component-tester + - bower install script: -- xvfb-run wct -- if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then wct -s 'default'; fi + - xvfb-run wct + - 'if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then wct -s ''default''; fi' env: global: - - secure: aLLRRtzSz/QImXYAEO7lBZcmp8xhXH28J6HONXOboy8H2eQmie0kAG8EIL1EYw1OMomAwawvh9BMJqhJHiLg23h6+asXdEaYefF+QDKIKh11dCZFUPJ71DAwKOLQpL+3D4iV/Wmndr4dIEGASCUdPufoBbmG1ZVY5dGkQYG8TO7mAOwzCciPNRaHws5fkMhWbm+tzWCDrIoMOWKDBZiAk4Rm7pXQ7c+Vnr07R0qrWlsCuiaMMc9J34q0bqrzmnV+EWjqKHXzhv1hJEbKHvO73cJorwtdpkeqLi1UsdkDCBuA8soxLSicCcpFe7eMkpr9WrbuJZ5QOEVlq+qb3aW9tH5wABiXSL4K8J7otvaXgRIaTg6i5pRGrivmNAOS6YXzT7oQAdmfFxHSpUr4OeV3Nvm9Ik7p8sOLHMGj4Eo00djjPtbO9MutF3CBLvYuEmdfa0BRXe3WqeJdaCVyYiMAPG7lYqz+aNAl6O4qAVRLMzXIRl/+vF2cso/rG7SsZORSuMk34NZhdXiHlBI+e5lyNrdrCyirukZmTd5rLiyEfbO9ty8BgxQ5MlomEXoZM3GYgFKgViYiMFQ8QuaGBUJBdeyo0IJiqp7ohcbUZq46XOXz//5hOOcp4ddgMNNjyIqjGmBJff0+oYalhJXK56UivTAXhoiXDLIQXHsJ3rUexcE= - - secure: TqRTXbcw5+a/XY/pb3rh8a/PkbLluNZKdN9FI/ZfHOVJu1xWCQSPUcI8XNmnPks/SVz8aCSWpPi4dh6oa8k1FXo7Q0lQ+2wAdfe7imnqoj6YIt0guHbe/YWGZoUmzuptSgufygzKGRh37oZx8fOH9bMb0vyMxCTZs4PcTeaqhmRQRHfVK/W2dyDRnSuHior5niKnboLXXR+XitcT3k+0S/jUGUwice0BivjHPpB9CNgm2lChRX3tHIru4iE3XW5U4+8Eg4SulLXd8DybQ3hzMIEmapPU7T/EO/xpIe1hIfVbJBY0LB4Ri5GGCK00OEDEcHSSJmubJ4usn2jitAyfztXg8BLEg8d/1BSTmAF+l7gUKgqhJ968Prc09EUdnyBPwRmnt1sPcZpDaDZuegg+y5Gx3qmWuqDAVSsHw08BbtK37ppHFRwswtRUMFOQKuOQXM74uI10BOWshONGitqKNYFvXniZxqO7Ezc/LSAfxSn278ews/KRNl/elGLgOtw92cJPXw515h56FvWb7gc1cm5WtJir2NwX7KlhHU3IPoDYq3QDKKQ63sPmUGPhCBAtfBGRDd5Os1MbcoyChpMr4osxHv03PNvQPY5hKjg2mUnb5QwMpJiEPs70CLXdx8Q7psX56RKjDHunFpXf5M4/SQIEmVFVi2PLoUymWlpvdBc= + - secure: >- + aLLRRtzSz/QImXYAEO7lBZcmp8xhXH28J6HONXOboy8H2eQmie0kAG8EIL1EYw1OMomAwawvh9BMJqhJHiLg23h6+asXdEaYefF+QDKIKh11dCZFUPJ71DAwKOLQpL+3D4iV/Wmndr4dIEGASCUdPufoBbmG1ZVY5dGkQYG8TO7mAOwzCciPNRaHws5fkMhWbm+tzWCDrIoMOWKDBZiAk4Rm7pXQ7c+Vnr07R0qrWlsCuiaMMc9J34q0bqrzmnV+EWjqKHXzhv1hJEbKHvO73cJorwtdpkeqLi1UsdkDCBuA8soxLSicCcpFe7eMkpr9WrbuJZ5QOEVlq+qb3aW9tH5wABiXSL4K8J7otvaXgRIaTg6i5pRGrivmNAOS6YXzT7oQAdmfFxHSpUr4OeV3Nvm9Ik7p8sOLHMGj4Eo00djjPtbO9MutF3CBLvYuEmdfa0BRXe3WqeJdaCVyYiMAPG7lYqz+aNAl6O4qAVRLMzXIRl/+vF2cso/rG7SsZORSuMk34NZhdXiHlBI+e5lyNrdrCyirukZmTd5rLiyEfbO9ty8BgxQ5MlomEXoZM3GYgFKgViYiMFQ8QuaGBUJBdeyo0IJiqp7ohcbUZq46XOXz//5hOOcp4ddgMNNjyIqjGmBJff0+oYalhJXK56UivTAXhoiXDLIQXHsJ3rUexcE= + - secure: >- + TqRTXbcw5+a/XY/pb3rh8a/PkbLluNZKdN9FI/ZfHOVJu1xWCQSPUcI8XNmnPks/SVz8aCSWpPi4dh6oa8k1FXo7Q0lQ+2wAdfe7imnqoj6YIt0guHbe/YWGZoUmzuptSgufygzKGRh37oZx8fOH9bMb0vyMxCTZs4PcTeaqhmRQRHfVK/W2dyDRnSuHior5niKnboLXXR+XitcT3k+0S/jUGUwice0BivjHPpB9CNgm2lChRX3tHIru4iE3XW5U4+8Eg4SulLXd8DybQ3hzMIEmapPU7T/EO/xpIe1hIfVbJBY0LB4Ri5GGCK00OEDEcHSSJmubJ4usn2jitAyfztXg8BLEg8d/1BSTmAF+l7gUKgqhJ968Prc09EUdnyBPwRmnt1sPcZpDaDZuegg+y5Gx3qmWuqDAVSsHw08BbtK37ppHFRwswtRUMFOQKuOQXM74uI10BOWshONGitqKNYFvXniZxqO7Ezc/LSAfxSn278ews/KRNl/elGLgOtw92cJPXw515h56FvWb7gc1cm5WtJir2NwX7KlhHU3IPoDYq3QDKKQ63sPmUGPhCBAtfBGRDd5Os1MbcoyChpMr4osxHv03PNvQPY5hKjg2mUnb5QwMpJiEPs70CLXdx8Q7psX56RKjDHunFpXf5M4/SQIEmVFVi2PLoUymWlpvdBc= diff --git a/resources/script/polymer/app-layout/README.md b/resources/script/polymer/app-layout/README.md index 79df397b3..a430e4faa 100644 --- a/resources/script/polymer/app-layout/README.md +++ b/resources/script/polymer/app-layout/README.md @@ -1,8 +1,76 @@ -# App Layout [![Build Status](https://travis-ci.org/PolymerElements/app-layout.svg?branch=master)](https://travis-ci.org/PolymerElements/app-layout) - +# App Layout [![Build Status](https://travis-ci.org/PolymerElements/app-layout.svg?branch=master)](https://travis-ci.org/PolymerElements/app-layout) [![Published on webcomponents.org](https://img.shields.io/badge/webcomponents.org-published-blue.svg)](https://beta.webcomponents.org/element/PolymerElements/app-layout) [](https://polymerelements.github.io/app-layout/) + +```html + + + +
My app
+ + + + +
+
+ + +``` + https://polymerelements.github.io/app-layout/ For additional documentation, please check out [Responsive app layout](https://www.polymer-project.org/1.0/toolbox/app-layout). diff --git a/resources/script/polymer/app-layout/app-box/README.md b/resources/script/polymer/app-layout/app-box/README.md index ecdd77e14..6c9efb9fb 100644 --- a/resources/script/polymer/app-layout/app-box/README.md +++ b/resources/script/polymer/app-layout/app-box/README.md @@ -10,9 +10,10 @@ rate than the foreground. ``` -Notice the `background` attribute in the `img` element; this attribute specifies that that image is used as the background. -By adding the background to the light dom, you can compose backgrounds that can change dynamically. -Alternatively, the mixin `--app-box-background-front-layer` allows to style the background. For example: +Notice the `background` attribute in the `img` element; this attribute specifies that that +image is used as the background. By adding the background to the light dom, you can compose +backgrounds that can change dynamically. Alternatively, the mixin `--app-box-background-front-layer` + allows to style the background. For example: ```css .parallaxAppBox { @@ -30,14 +31,39 @@ Finally, app-box can have content inside. For example: ``` -## Scroll effects +#### Importing the effects -Effect name | Description -----------------|------------- -`parallax-background` | A parallax effect +To use the scroll effects, you must explicitly import them in addition to `app-box`: + +```html + +``` + +#### List of effects + +* **parallax-background** +A simple parallax effect that vertically translates the backgrounds based on a fraction +of the scroll position. For example: + +```css +app-header { + --app-header-background-front-layer: { + background-image: url(...); + }; +} +``` +```html + + App name + +``` + +The fraction determines how far the background moves relative to the scroll position. +This value can be assigned via the `scalar` config value and it is typically a value +between 0 and 1 inclusive. If `scalar=0`, the background doesn't move away from the header. ## Styling Mixin | Description | Default ----------------|-------------|---------- -`--app-box-background-front-layer` | Applies to the front layer of the background | {} \ No newline at end of file +`--app-box-background-front-layer` | Applies to the front layer of the background | {} diff --git a/resources/script/polymer/app-layout/app-box/app-box.html b/resources/script/polymer/app-layout/app-box/app-box.html index da159f419..961270cee 100644 --- a/resources/script/polymer/app-layout/app-box/app-box.html +++ b/resources/script/polymer/app-layout/app-box/app-box.html @@ -24,9 +24,10 @@ ``` -Notice the `background` attribute in the `img` element; this attribute specifies that that image is used as the background. -By adding the background to the light dom, you can compose backgrounds that can change dynamically. -Alternatively, the mixin `--app-box-background-front-layer` allows to style the background. For example: +Notice the `background` attribute in the `img` element; this attribute specifies that that +image is used as the background. By adding the background to the light dom, you can compose +backgrounds that can change dynamically. Alternatively, the mixin `--app-box-background-front-layer` +allows to style the background. For example: ```css .parallaxAppBox { @@ -44,11 +45,36 @@

Sub title

``` -## Scroll effects +#### Importing the effects -Effect name | Description -----------------|------------- -`parallax-background` | A parallax effect +To use the scroll effects, you must explicitly import them in addition to `app-box`: + +```html + +``` + +#### List of effects + +* **parallax-background** +A simple parallax effect that vertically translates the backgrounds based on a fraction +of the scroll position. For example: + +```css +app-header { + --app-header-background-front-layer: { + background-image: url(...); + }; +} +``` +```html + + App name + +``` + +The fraction determines how far the background moves relative to the scroll position. +This value can be assigned via the `scalar` config value and it is typically a value +between 0 and 1 inclusive. If `scalar=0`, the background doesn't move away from the header. ## Styling @@ -67,31 +93,24 @@

Sub title

-
-
-
+ +
+
+ +
POLYMER
+
+ + + +
+ +

Built for Speed

Polymer 1.0 replaces the shadow DOM polyfill with a lightweight shim, uses a new, faster data-binding system, and significantly reduces code size.

- + - +
-
+

Using Web Components

Polymer leverages web components, a new set of standards designed to provide reusable components for the web.

- +
-
+

Create your own elements

The Polymer library makes it easy to create your own powerful elements. Give your element some markup and properties, and then use it on a site. Polymer provides useful features like templating and data binding to reduce the amount of boilerplate you need to write.

- +
-
+ diff --git a/resources/script/polymer/app-layout/app-drawer-layout/app-drawer-layout.html b/resources/script/polymer/app-layout/app-drawer-layout/app-drawer-layout.html index 4cbbe2f1a..6754b0607 100644 --- a/resources/script/polymer/app-layout/app-drawer-layout/app-drawer-layout.html +++ b/resources/script/polymer/app-layout/app-drawer-layout/app-drawer-layout.html @@ -180,19 +180,27 @@ type: Boolean, readOnly: true, notify: true + }, + + /** + * If true, the drawer will initially be opened when in narrow layout mode. + */ + openedWhenNarrow: { + type: Boolean, + value: false } }, - _notifyingResize: false, - listeners: { 'tap': '_tapHandler', + 'app-drawer-attached': '_resetDrawerState', 'app-drawer-reset-layout': 'resetLayout', - 'iron-resize': '_resizeHandler' + 'iron-resize': 'resetLayout' }, observers: [ - 'resetLayout(narrow, isAttached)' + 'resetLayout(narrow, isAttached)', + '_narrowChanged(narrow, isAttached)' ], /** @@ -207,7 +215,10 @@ _tapHandler: function(e) { var target = Polymer.dom(e).localTarget; if (target && target.hasAttribute('drawer-toggle')) { - this.drawer.toggle(); + var drawer = this.drawer; + if (drawer && !drawer.persistent) { + drawer.toggle(); + } } }, @@ -216,17 +227,11 @@ var drawer = this.drawer; var contentContainer = this.$.contentContainer; - if (this.narrow) { - drawer.opened = drawer.persistent = false; - contentContainer.classList.add('narrow'); - + if (this.narrow || !drawer) { contentContainer.style.marginLeft = ''; contentContainer.style.marginRight = ''; } else { - drawer.opened = drawer.persistent = true; - contentContainer.classList.remove('narrow'); - - var drawerWidth = this.drawer.getWidth(); + var drawerWidth = drawer.getWidth(); if (drawer.position == 'right') { contentContainer.style.marginLeft = ''; contentContainer.style.marginRight = drawerWidth + 'px'; @@ -235,17 +240,29 @@ contentContainer.style.marginRight = ''; } } + }); + }, + + _resetDrawerState: function() { + this.debounce('_resetDrawerState', function() { + var drawer = this.drawer; + if (!drawer) { + return; + } - this._notifyingResize = true; - this.notifyResize(); - this._notifyingResize = false; + if (this.narrow) { + drawer.opened = this.openedWhenNarrow; + drawer.persistent = false; + } else { + drawer.opened = drawer.persistent = true; + } }); }, - _resizeHandler: function() { - if (!this._notifyingResize) { - this.resetLayout(); - } + _narrowChanged: function(narrow) { + this.toggleClass('narrow', narrow, this.$.contentContainer); + this._resetDrawerState(); + this.notifyResize(); }, _onQueryMatchesChanged: function(event) { diff --git a/resources/script/polymer/app-layout/app-drawer-layout/test/app-drawer-layout.html b/resources/script/polymer/app-layout/app-drawer-layout/test/app-drawer-layout.html index 4743fbde3..381750ed0 100644 --- a/resources/script/polymer/app-layout/app-drawer-layout/test/app-drawer-layout.html +++ b/resources/script/polymer/app-layout/app-drawer-layout/test/app-drawer-layout.html @@ -65,7 +65,7 @@ - - - - diff --git a/resources/script/polymer/app-layout/app-drawer/app-drawer.html b/resources/script/polymer/app-layout/app-drawer/app-drawer.html index 85db9af85..cbf0b58b6 100644 --- a/resources/script/polymer/app-layout/app-drawer/app-drawer.html +++ b/resources/script/polymer/app-layout/app-drawer/app-drawer.html @@ -63,7 +63,7 @@ visibility: hidden; - transition: visibility 0.2s ease; + transition-property: visibility; } :host([opened]) { @@ -91,7 +91,6 @@ width: var(--app-drawer-width, 256px); padding: 120px 0; - transition: 0.2s ease; transition-property: -webkit-transform; transition-property: transform; -webkit-transform: translate3d(-100%, 0, 0); @@ -140,7 +139,7 @@ bottom: 0; left: 0; - transition: opacity 0.2s ease; + transition-property: opacity; -webkit-transform: translateZ(0); transform: translateZ(0); @@ -195,6 +194,14 @@ reflectToAttribute: true }, + /** + * The transition duration of the drawer in milliseconds. + */ + transitionDuration: { + type: Number, + value: 200 + }, + /** * The alignment of the drawer on the screen ('left', 'right', 'start' or 'end'). * 'start' computes to left and 'end' to right in LTR layout and vice versa in RTL @@ -229,12 +236,22 @@ noFocusTrap: { type: Boolean, value: false + }, + + /** + * Disables swiping on the drawer. + */ + disableSwipe: { + type: Boolean, + value: false } }, observers: [ 'resetLayout(position, isAttached)', - '_resetPosition(align, isAttached)' + '_resetPosition(align, isAttached)', + '_styleTransitionDuration(transitionDuration)', + '_openedPersistentChanged(opened, persistent)' ], _translateOffset: 0, @@ -249,27 +266,29 @@ _lastTabStop: null, - ready: function() { - // Only transition the drawer after its first render (e.g. app-drawer-layout - // may need to set the initial opened state which should not be transitioned). - this._setTransitionDuration('0s'); - }, - attached: function() { // Only transition the drawer after its first render (e.g. app-drawer-layout // may need to set the initial opened state which should not be transitioned). + this._styleTransitionDuration(0); Polymer.RenderStatus.afterNextRender(this, function() { - this._setTransitionDuration(''); + this._styleTransitionDuration(this.transitionDuration); this._boundEscKeydownHandler = this._escKeydownHandler.bind(this); this._resetDrawerState(); - this.addEventListener('transitionend', this._transitionend.bind(this)); + // contentContainer will transition on opened state changed, and scrim will + // transition on persistent state changed when opened - these are the + // transitions we are interested in. + this.$.scrim.addEventListener('transitionend', this._transitionend.bind(this)); + this.$.contentContainer.addEventListener('transitionend', this._transitionend.bind(this)); + this.addEventListener('keydown', this._tabKeydownHandler.bind(this)) // Only listen for horizontal track so you can vertically scroll inside the drawer. this.listen(this, 'track', '_track'); this.setScrollDirection('y'); }); + + this.fire('app-drawer-attached'); }, detached: function() { @@ -342,7 +361,7 @@ }, _track: function(event) { - if (this.persistent) { + if (this.persistent || this.disableSwipe) { return; } @@ -366,7 +385,7 @@ this._drawerState = this._DRAWER_STATE.TRACKING; // Disable transitions since style attributes will reflect user track events. - this._setTransitionDuration('0s'); + this._styleTransitionDuration(0); this.style.visibility = 'visible'; var rect = this.$.contentContainer.getBoundingClientRect(); @@ -417,12 +436,12 @@ this.opened = this.position === 'left'; } - // Trigger app-drawer-transitioned now since there will be no transitionend event. if (isInEndState) { + // Reset drawer state now since there will be no transitionend event. this._resetDrawerState(); } - this._setTransitionDuration(''); + this._styleTransitionDuration(this.transitionDuration); this._resetDrawerTranslate(); this.style.visibility = ''; }, @@ -491,36 +510,30 @@ // Calculate the amount of time needed to finish the transition based on the // initial slope of the timing function. - this._setTransitionDuration((this._FLING_INITIAL_SLOPE * dx / velocity) + 'ms'); - this._setTransitionTimingFunction(this._FLING_TIMING_FUNCTION); + this._styleTransitionDuration(this._FLING_INITIAL_SLOPE * dx / velocity); + this._styleTransitionTimingFunction(this._FLING_TIMING_FUNCTION); this._resetDrawerTranslate(); }, - _transitionend: function(event) { - // contentContainer will transition on opened state changed, and scrim will - // transition on persistent state changed when opened - these are the - // transitions we are interested in. - var target = Polymer.dom(event).rootTarget; - if (target === this.$.contentContainer || target === this.$.scrim) { - - // If the drawer was flinging, we need to reset the style attributes. - if (this._drawerState === this._DRAWER_STATE.FLINGING) { - this._setTransitionDuration(''); - this._setTransitionTimingFunction(''); - this.style.visibility = ''; - } - - this._resetDrawerState(); + _transitionend: function() { + // If the drawer was flinging, we need to reset the style attributes. + if (this._drawerState === this._DRAWER_STATE.FLINGING) { + this._styleTransitionDuration(this.transitionDuration); + this._styleTransitionTimingFunction(''); + this.style.visibility = ''; } + + this._resetDrawerState(); }, - _setTransitionDuration: function(duration) { - this.$.contentContainer.style.transitionDuration = duration; - this.$.scrim.style.transitionDuration = duration; + _styleTransitionDuration: function(duration) { + this.style.transitionDuration = duration + 'ms'; + this.$.contentContainer.style.transitionDuration = duration + 'ms'; + this.$.scrim.style.transitionDuration = duration + 'ms'; }, - _setTransitionTimingFunction: function(timingFunction) { + _styleTransitionTimingFunction: function(timingFunction) { this.$.contentContainer.style.transitionTimingFunction = timingFunction; this.$.scrim.style.transitionTimingFunction = timingFunction; }, @@ -631,6 +644,13 @@ } }, + _openedPersistentChanged: function() { + if (this.transitionDuration === 0) { + // Reset drawer state now since there will be no transitionend event. + this._resetDrawerState(); + } + }, + _MIN_FLING_THRESHOLD: 0.2, _MIN_TRANSITION_VELOCITY: 1.2, @@ -648,6 +668,12 @@ FLINGING: 5 } + /** + * Fired when the layout of app-drawer is attached. + * + * @event app-drawer-attached + */ + /** * Fired when the layout of app-drawer has changed. * diff --git a/resources/script/polymer/app-layout/app-drawer/test/app-drawer.html b/resources/script/polymer/app-layout/app-drawer/test/app-drawer.html index 8cd46e2ee..ccb0a365e 100644 --- a/resources/script/polymer/app-layout/app-drawer/test/app-drawer.html +++ b/resources/script/polymer/app-layout/app-drawer/test/app-drawer.html @@ -17,6 +17,7 @@ + - + + + + + diff --git a/resources/script/polymer/app-layout/app-header/README.md b/resources/script/polymer/app-layout/app-header/README.md index 127b83d96..1cd33a0c1 100644 --- a/resources/script/polymer/app-layout/app-header/README.md +++ b/resources/script/polymer/app-layout/app-header/README.md @@ -5,7 +5,7 @@ app-header is container element for app-toolbars at the top of the screen that can have scroll effects. By default, an app-header moves away from the viewport when scrolling down and -if using `reveals`, the header slides back when scrolling back up. For example, +if using `reveals`, the header slides back when scrolling back up. For example: ```html @@ -118,7 +118,6 @@ Upon scrolling past a threshold, this effect will trigger an opacity transition fade in/out the backgrounds. Compared to the `blend-background` effect, this effect doesn't interpolate the opacity based on scroll position. - * **parallax-background** A simple parallax effect that vertically translates the backgrounds based on a fraction of the scroll position. For example: @@ -139,7 +138,6 @@ app-header { The fraction determines how far the background moves relative to the scroll position. This value can be assigned via the `scalar` config value and it is typically a value between 0 and 1 inclusive. If `scalar=0`, the background doesn't move away from the header. -[More about configuration for scroll effects](/app-scroll-effects#configuring-effects) * **resize-title** Progressively interpolates the size of the title from the element with the `main-title` attribute @@ -195,8 +193,7 @@ Attribute | Description | Default ## Styling Mixin | Description | Default -----------------|-------------|---------- -`--app-header-background-front-layer` | Applies to the front layer of the background | {} -`--app-header-background-rear-layer` | Applies to the rear layer of the background | {} -`--app-header-shadow` | Applies to the shadow | {} - +------|-------------|---------- +`--app-header-background-front-layer` | Applies to the front layer of the background. | {} +`--app-header-background-rear-layer` | Applies to the rear layer of the background. | {} +`--app-header-shadow` | Applies to the shadow. | {} diff --git a/resources/script/polymer/app-layout/app-header/app-header.html b/resources/script/polymer/app-layout/app-header/app-header.html index 86fd819fa..49dfc0dfe 100644 --- a/resources/script/polymer/app-layout/app-header/app-header.html +++ b/resources/script/polymer/app-layout/app-header/app-header.html @@ -220,7 +220,8 @@

App name

@demo app-header/demo/music.html Reveals Demo @demo app-header/demo/no-effects.html Condenses and Reveals Demo @demo app-header/demo/notes.html Fixed with Dynamic Shadow Demo -@demo app-header/demo/custom-sticky-element.html Custom Sticky Element Demo +@demo app-header/demo/custom-sticky-element-1.html Custom Sticky Element Demo 1 +@demo app-header/demo/custom-sticky-element-2.html Custom Sticky Element Demo 2 --> @@ -254,17 +255,15 @@

App name

opacity: 1; } - #contentContainer > ::content [condensed-title] { + ::content [main-title], + ::content [condensed-title] { -webkit-transform-origin: left top; transform-origin: left top; white-space: nowrap; - opacity: 0; } - #contentContainer > ::content [main-title] { - -webkit-transform-origin: left top; - transform-origin: left top; - white-space: nowrap; + ::content [condensed-title] { + opacity: 0; } #background { @@ -483,8 +482,6 @@

App name

* @method resetLayout */ resetLayout: function() { - this.fire('app-header-reset-layout'); - this.debounce('_resetLayout', function() { // noop if the header isn't visible if (this.offsetWidth === 0 && this.offsetHeight === 0) { @@ -503,7 +500,6 @@

App name

if (!firstSetup) { this._updateScrollState(0, true); } - if (this._mayMove()) { this._dHeight = this._stickyEl ? this._height - this._stickyEl.offsetHeight : 0; } else { @@ -521,6 +517,7 @@

App name

} // restore no transition this.disabled = currentDisabled; + this.fire('app-header-reset-layout'); }); }, @@ -647,9 +644,9 @@

App name

*/ _transformHeader: function(y) { this.translate3d(0, (-y) + 'px', 0); - if (this._stickyEl && this.condenses && y >= this._stickyElTop) { - this.translate3d(0, (Math.min(y, this._dHeight) - this._stickyElTop) + 'px', 0, - this._stickyEl); + if (this._stickyEl) { + this.translate3d(0, this.condenses && y >= this._stickyElTop ? + (Math.min(y, this._dHeight) - this._stickyElTop) + 'px' : 0, 0, this._stickyEl); } }, diff --git a/resources/script/polymer/app-layout/app-header/demo/custom-sticky-element.html b/resources/script/polymer/app-layout/app-header/demo/custom-sticky-element-1.html similarity index 94% rename from resources/script/polymer/app-layout/app-header/demo/custom-sticky-element.html rename to resources/script/polymer/app-layout/app-header/demo/custom-sticky-element-1.html index c73ca6c51..aa3c96237 100644 --- a/resources/script/polymer/app-layout/app-header/demo/custom-sticky-element.html +++ b/resources/script/polymer/app-layout/app-header/demo/custom-sticky-element-1.html @@ -43,9 +43,6 @@ height: 132px; color: #fff; background-color: #4285f4; - --app-header-background-rear-layer: { - background-color: #0b8043; - }; } paper-icon-button { @@ -65,7 +62,7 @@ - +

diff --git a/resources/script/polymer/app-layout/app-header/demo/custom-sticky-element-2.html b/resources/script/polymer/app-layout/app-header/demo/custom-sticky-element-2.html new file mode 100644 index 000000000..fd3c7aff7 --- /dev/null +++ b/resources/script/polymer/app-layout/app-header/demo/custom-sticky-element-2.html @@ -0,0 +1,89 @@ + + + + + + + + + + app-header demo + + + + + + + + + + + + + + + + + + + +

+ +
+ + + TAB 1 + TAB 2 + TAB 3 + +
+ + + + + diff --git a/resources/script/polymer/app-layout/app-header/demo/index.html b/resources/script/polymer/app-layout/app-header/demo/index.html index cd31af446..7cf003eef 100644 --- a/resources/script/polymer/app-layout/app-header/demo/index.html +++ b/resources/script/polymer/app-layout/app-header/demo/index.html @@ -39,7 +39,8 @@

app-header demos

Reveals Demo Condenses and Reveals Demo Fixed with Dynamic Shadow Demo - Custom sticky element + Custom sticky element 1 + Custom sticky element 2
diff --git a/resources/script/polymer/app-layout/app-header/test/app-header.html b/resources/script/polymer/app-layout/app-header/test/app-header.html index 224b5e379..780a9187c 100644 --- a/resources/script/polymer/app-layout/app-header/test/app-header.html +++ b/resources/script/polymer/app-layout/app-header/test/app-header.html @@ -458,11 +458,11 @@ test('DOM references', function(done) { flush(function() { - assert.isNotNull(header._getDOMRef('backgroundFrontLayer')); - assert.isNotNull(header._getDOMRef('backgroundRearLayer')); - assert.isNotNull(header._getDOMRef('mainTitle')); - assert.isNotNull(header._getDOMRef('condensedTitle')); - done(); + assert.isNotNull(header._getDOMRef('backgroundFrontLayer')); + assert.isNotNull(header._getDOMRef('backgroundRearLayer')); + assert.isNotNull(header._getDOMRef('mainTitle')); + assert.isNotNull(header._getDOMRef('condensedTitle')); + done(); }); }); }); diff --git a/resources/script/polymer/app-layout/app-scroll-effects/app-scroll-effects-behavior.html b/resources/script/polymer/app-layout/app-scroll-effects/app-scroll-effects-behavior.html index ed78a124a..bc6a2b882 100644 --- a/resources/script/polymer/app-layout/app-scroll-effects/app-scroll-effects-behavior.html +++ b/resources/script/polymer/app-layout/app-scroll-effects/app-scroll-effects-behavior.html @@ -46,7 +46,7 @@ * based on the scroll position. * * A scroll effect definition is an object with `setUp()`, `tearDown()` and `run()` functions. - * + * * To register the effect, you can use `Polymer.AppLayout.registerEffect(effectName, effectDef)` * For example, let's define an effect that resizes the header's logo: * @@ -144,6 +144,29 @@ type: Boolean, reflectToAttribute: true, value: false + }, + + /** + * Allows to set a `scrollTop` threshold. When greater than 0, `thresholdTriggered` + * is true only when the scroll target's `scrollTop` has reached this value. + * + * For example, if `threshold = 100`, `thresholdTriggered` is true when the `scrollTop` + * is at least `100`. + */ + threshold: { + type: Number, + value: 0 + }, + + /** + * True if the `scrollTop` threshold (set in `scrollTopThreshold`) has + * been reached. + */ + thresholdTriggered: { + type: Boolean, + notify: true, + readOnly: true, + reflectToAttribute: true } }, @@ -254,7 +277,7 @@ if ((effectDef = Polymer.AppLayout._scrollEffects[effectName])) { this._effects.push(this._boundEffect(effectDef, effectsConfig[effectName])); } else { - this._warn(this._logf('_effectsChanged', this._getUndefinedMsg(effectName))); + console.warn(this._getUndefinedMsg(effectName)); } } }, this); @@ -341,10 +364,14 @@ */ _scrollHandler: function() { if (!this.disabled) { - this._updateScrollState(this._clampedScrollTop); + var scrollTop = this._clampedScrollTop; + this._updateScrollState(scrollTop); + if (this.threshold > 0) { + this._setThresholdTriggered(scrollTop >= this.threshold); + } } }, - + /** * Override this method to return a reference to a node in the local DOM. * The node is consumed by a scroll effect. @@ -352,7 +379,7 @@ * @param {string} id The id for the node. */ _getDOMRef: function(id) { - this._warn(this._logf('_getDOMRef', '`'+ id +'` is undefined')); + console.warn('_getDOMRef', '`'+ id +'` is undefined'); }, _getUndefinedMsg: function(effectName) { diff --git a/resources/script/polymer/app-layout/app-scroll-effects/effects/resize-snapped-title.html b/resources/script/polymer/app-layout/app-scroll-effects/effects/resize-snapped-title.html index cbe0adc82..6a12e2ad1 100644 --- a/resources/script/polymer/app-layout/app-scroll-effects/effects/resize-snapped-title.html +++ b/resources/script/polymer/app-layout/app-scroll-effects/effects/resize-snapped-title.html @@ -26,11 +26,11 @@ var fx = {}; if (!condensedTitle) { - this._warn(this._logf('effects[resize-snapped-title]', 'undefined `condensed-title`')); + console.warn('Scroll effect `resize-snapped-title`: undefined `condensed-title`'); return false; } if (!title) { - this._warn(this._logf('effects[resize-snapped-title]', 'undefined `main-title`')); + console.warn('Scroll effect `resize-snapped-title`: undefined `main-title`'); return false; } diff --git a/resources/script/polymer/app-layout/app-scroll-effects/effects/resize-title.html b/resources/script/polymer/app-layout/app-scroll-effects/effects/resize-title.html index f758801de..b25e93e20 100644 --- a/resources/script/polymer/app-layout/app-scroll-effects/effects/resize-title.html +++ b/resources/script/polymer/app-layout/app-scroll-effects/effects/resize-title.html @@ -29,11 +29,11 @@ var condensedTitle = this._getDOMRef('condensedTitle'); if (!condensedTitle) { - this._warn(this._logf('effects[resize-title]', 'undefined `condensed-title`')); + console.warn('Scroll effect `resize-title`: undefined `condensed-title`'); return false; } if (!title) { - this._warn(this._logf('effects[resize-title]', 'undefined `main-title`')); + console.warn('Scroll effect `resize-title`: undefined `main-title`'); return false; } diff --git a/resources/script/polymer/app-layout/app-scroll-effects/effects/waterfall.html b/resources/script/polymer/app-layout/app-scroll-effects/effects/waterfall.html index 58b2fc9a0..58f1ae3ec 100644 --- a/resources/script/polymer/app-layout/app-scroll-effects/effects/waterfall.html +++ b/resources/script/polymer/app-layout/app-scroll-effects/effects/waterfall.html @@ -19,7 +19,7 @@ /** * @this Polymer.AppLayout.ElementWithBackground */ - run: function run(p, y) { + run: function run() { this.shadow = this.isOnScreen() && this.isContentBelow(); } }); diff --git a/resources/script/polymer/app-layout/app-scroll-effects/test/app-scroll-effects-behavior.html b/resources/script/polymer/app-layout/app-scroll-effects/test/app-scroll-effects-behavior.html index f17ae74ae..fc3ec4d5d 100644 --- a/resources/script/polymer/app-layout/app-scroll-effects/test/app-scroll-effects-behavior.html +++ b/resources/script/polymer/app-layout/app-scroll-effects/test/app-scroll-effects-behavior.html @@ -181,6 +181,34 @@ ]); }); }); + + test('threshold and threshold-triggered', function(done) { + flush(function() { + assert.isUndefined(container.thresholdTriggered); + assert.equal(container.threshold, 0); + container.threshold = 100; + + scrollTestHelper(container.scrollTarget, [ + { + y: 0, + callback: function() { + assert.isFalse(container.thresholdTriggered); + } + }, { + y: 100, + callback: function() { + assert.isTrue(container.thresholdTriggered); + } + }, { + y: 50, + callback: function() { + assert.isFalse(container.thresholdTriggered); + done(); + } + } + ]); + }); + }); }); diff --git a/resources/script/polymer/app-layout/app-toolbar/app-toolbar.html b/resources/script/polymer/app-layout/app-toolbar/app-toolbar.html index 9305b27f0..9704ad207 100644 --- a/resources/script/polymer/app-layout/app-toolbar/app-toolbar.html +++ b/resources/script/polymer/app-layout/app-toolbar/app-toolbar.html @@ -40,7 +40,7 @@ ### Content attributes -Attribute | Description +Attribute | Description ---------------------|--------------------------------------------------------- `main-title` | The main title element. `condensed-title` | The title element if used inside a condensed app-header. @@ -63,49 +63,45 @@