5 // create some basic transition styling data.
6 var transitions
= CoreStyle
.g
.transitions
= CoreStyle
.g
.transitions
|| {};
7 transitions
.duration
= '500ms';
8 transitions
.heroDelay
= '50ms';
9 transitions
.scaleDelay
= '500ms';
10 transitions
.cascadeFadeDuration
= '250ms';
12 Polymer('core-transition-pages',{
16 * This class will be applied to the scope element in the `prepare` function.
17 * It is removed in the `complete` function. Used to activate a set of CSS
18 * rules that need to apply before the transition runs, e.g. a default opacity
19 * or transform for the non-active pages.
21 * @attribute scopeClass
28 * This class will be applied to the scope element in the `go` function. It is
29 * remoived in the `complete' function. Generally used to apply a CSS transition
30 * rule only during the transition.
32 * @attribute activeClass
39 * Specifies which CSS property to look for when it receives a `transitionEnd` event
40 * to determine whether the transition is complete. If not specified, the first
41 * transitionEnd event received will complete the transition.
43 * @attribute transitionProperty
47 transitionProperty
: ''
51 * True if this transition is complete.
53 * @attribute completed
59 prepare: function(scope
, options
) {
60 this.boundCompleteFn
= this.complete
.bind(this, scope
);
61 if (this.scopeClass
) {
62 scope
.classList
.add(this.scopeClass
);
66 go: function(scope
, options
) {
67 this.completed
= false;
68 if (this.activeClass
) {
69 scope
.classList
.add(this.activeClass
);
71 scope
.addEventListener('transitionend', this.boundCompleteFn
, false);
74 setup: function(scope
) {
75 if (!scope
._pageTransitionStyles
) {
76 scope
._pageTransitionStyles
= {};
79 var name
= this.calcStyleName();
81 if (!scope
._pageTransitionStyles
[name
]) {
82 this.installStyleInScope(scope
, name
);
83 scope
._pageTransitionStyles
[name
] = true;
87 calcStyleName: function() {
88 return this.id
|| this.localName
;
91 installStyleInScope: function(scope
, id
) {
92 if (!scope
.shadowRoot
) {
93 scope
.createShadowRoot().innerHTML
= '<content></content>';
95 var root
= scope
.shadowRoot
;
96 var scopeStyle
= document
.createElement('core-style');
97 root
.insertBefore(scopeStyle
, root
.firstChild
);
98 scopeStyle
.applyRef(id
);
101 complete: function(scope
, e
) {
102 // TODO(yvonne): hack, need to manage completion better
103 if (e
.propertyName
!== 'box-shadow' && (!this.transitionProperty
|| e
.propertyName
.indexOf(this.transitionProperty
) !== -1)) {
104 this.completed
= true;
105 this.fire('core-transitionend', this, scope
);
109 // TODO(sorvell): ideally we do this in complete.
110 ensureComplete: function(scope
) {
111 scope
.removeEventListener('transitionend', this.boundCompleteFn
, false);
112 if (this.scopeClass
) {
113 scope
.classList
.remove(this.scopeClass
);
115 if (this.activeClass
) {
116 scope
.classList
.remove(this.activeClass
);