Created
July 24, 2015 03:08
-
-
Save VandeurenGlenn/1999422dc7c25185810f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script> | |
| var BasicElements = BasicElements || {}; | |
| /** | |
| * @demo demo/index.html | |
| * @polymerBehavior BasicElements.pageSelectedBehavior | |
| */ | |
| BasicElements.pageSelectedBehaviorImpl = { | |
| properties: { | |
| animate: { | |
| type: Boolean, | |
| value: false | |
| }, | |
| hidden: { | |
| type: Boolean, | |
| reflectToAttribute: true, | |
| value: true | |
| }, | |
| /** | |
| * Used to delay the animation to show after the element is ready. | |
| * | |
| * **Control delay time using the 'loadTime' property.** | |
| * > *<my-element load-time="1000" delay-on-load></my-element>* | |
| */ | |
| delayOnLoad: { | |
| type: Boolean, | |
| value: false | |
| }, | |
| loaded: Boolean | |
| }, | |
| observers: ['_animate(animate, loaded)'], | |
| ready: function () { | |
| if (this.delayOnLoad) { | |
| this.async(function () { | |
| this.loaded = true; | |
| }, this.loadTime); | |
| } else { | |
| this.loaded = true; | |
| } | |
| }, | |
| /** | |
| * Performs a exit-animation when animate is false, | |
| * Performs a entry-animation when animate is true, | |
| */ | |
| _animate: function (animate, loaded) { | |
| if (this.animate && this.loaded) { | |
| // show the element when animation & loading is finished. | |
| this.hidden = false; | |
| // Play entry animation | |
| this.playAnimation('entry'); | |
| } else if(!this.animate && this.loaded){ | |
| // Hide the element after the animation has finished | |
| this.async(function () { | |
| this.hidden = true; | |
| }, this.animationTiming); | |
| // Play exit animation | |
| this.playAnimation('exit'); | |
| } | |
| } | |
| }; | |
| /** @polymerBehavior BasicElements.pageSelectedBehavior */ | |
| BasicElements.pageSelectedBehavior = [ | |
| BasicElements.singlePageProperties, | |
| BasicElements.pageSelectedBehaviorImpl, | |
| Polymer.NeonAnimationRunnerBehavior | |
| ] | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment