1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
6 is
: 'viewer-zoom-button',
9 Polymer
.NeonAnimationRunnerBehavior
14 * Icons to be displayed on the FAB. Multiple icons should be separated with
15 * spaces, and will be cycled through every time the FAB is clicked.
20 * Array version of the list of icons. Polymer does not allow array
21 * properties to be set from HTML, so we must use a string property and
22 * perform the conversion manually.
28 computed
: 'computeIconsArray_(icons)'
40 computed
: 'computeAnimationConfig_(delay)'
44 * Index of the icon currently being displayed.
52 * Icon currently being displayed on the FAB.
57 computed
: 'computeVisibleIcon_(icons_, activeIndex)'
61 computeAnimationConfig_: function(delay
) {
64 name
: 'transform-animation',
67 easing
: 'cubic-bezier(0, 0, 0.2, 1)',
71 transformFrom
: 'translateX(100%)'
74 name
: 'transform-animation',
77 easing
: 'cubic-bezier(0.4, 0, 1, 1)',
81 transformTo
: 'translateX(100%)'
86 computeIconsArray_: function(icons
) {
87 return icons
.split(' ');
90 computeVisibleIcon_: function(icons
, activeIndex
) {
91 return icons
[activeIndex
];
95 'neon-animation-finish': '_onAnimationFinished'
98 _onAnimationFinished: function() {
99 this.style
.transform
= this.opened
? 'none' : 'translateX(100%)';
113 toggle_: function() {
114 this.opened
= !this.opened
;
115 this.cancelAnimation();
116 this.playAnimation(this.opened
? 'entry' : 'exit');
119 fireClick: function() {
120 // We cannot attach an on-click to the entire viewer-zoom-button, as this
121 // will include clicks on the margins. Instead, proxy clicks on the FAB
123 this.fire('fabclick');
125 this.activeIndex
= (this.activeIndex
+ 1) % this.icons_
.length
;