2 Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
3 This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
4 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
5 The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
6 Code distributed by Google as part of the polymer project is also
7 subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
11 @class paper-menu-button-transition
12 @extends core-transition-css
14 <link href="../polymer/polymer.html" rel="import">
15 <link href="../core-transition/core-transition-css.html" rel="import">
16 <link href="../core-animation/web-animations.html" rel="import">
18 <polymer-element name="paper-menu-button-transition" extends="core-transition-css" attributes="duration transformOrigin">
20 <link no-shim href="paper-menu-button-transition.css" rel="stylesheet">
23 Polymer('paper-menu-button-transition', {
25 baseClass: 'paper-menu-button-transition',
26 revealedClass: 'paper-menu-button-revealed',
27 openedClass: 'paper-menu-button-opened',
28 closedClass: 'paper-menu-button-closed',
32 setup: function(node) {
33 this.super(arguments);
35 var bg = node.querySelector('.paper-menu-button-overlay-bg');
36 bg.style.transformOrigin = this.transformOrigin;
37 bg.style.webkitTransformOrigin = this.transformOrigin;
40 transitionOpened: function(node, opened) {
41 this.super(arguments);
50 var ink = node.querySelector('.paper-menu-button-overlay-ink');
51 var offset = 40 / Math.max(node.cachedSize.width, node.cachedSize.height);
52 anims.push(new Animation(ink, [{
54 'transform': 'scale(0)',
57 'transform': 'scale(1)'
59 duration: this.duration * offset
62 var bg = node.querySelector('.paper-menu-button-overlay-bg');
63 anims.push(new Animation(bg, [{
65 'transform': 'scale(' + 40 / node.cachedSize.width + ',' + 40 / node.cachedSize.height + ')',
68 'transform': 'scale(0.95, 0.5)'
71 'transform': 'scale(1, 1)'
73 delay: this.duration * offset,
74 duration: this.duration * (1 - offset),
78 var nodes = window.ShadowDOMPolyfill ? Platform.queryAllShadows(node.querySelector('core-menu'), 'content').getDistributedNodes() : node.querySelector('core-menu::shadow content').getDistributedNodes().array();
79 var items = nodes.filter(function(n) {
80 return n.nodeType === Node.ELEMENT_NODE;
82 var itemDelay = offset + (1 - offset) / 2;
83 var itemDuration = this.duration * (1 - itemDelay) / items.length;
84 items.forEach(function(item, i) {
85 anims.push(new Animation(item, [{
90 delay: this.duration * itemDelay + itemDuration * i,
91 duration: itemDuration,
96 var shadow = node.querySelector('paper-shadow');
97 anims.push(new Animation(shadow, function(t, target) {
98 if (t > offset * 2 && shadow.z === 0) {
102 duration: this.duration
105 var group = new AnimationGroup(anims, {
106 easing: 'cubic-bezier(0.4, 0, 0.2, 1)'
108 this.player = document.timeline.play(group);
116 <paper-menu-button-transition id="paper-menu-button-transition-top-left" transformOrigin="0% 0%"></paper-menu-button-transition>
117 <paper-menu-button-transition id="paper-menu-button-transition-top-right" transformOrigin="100% 0%"></paper-menu-button-transition>
118 <paper-menu-button-transition id="paper-menu-button-transition-top-right-slow" transformOrigin="100% 0%" duration="10000"></paper-menu-button-transition>