forked from TimvdLippe/iron-lazy-pages
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathneon-lazy-pages.html
87 lines (77 loc) · 2.23 KB
/
neon-lazy-pages.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<!--
@license
Copyright (C) 2016, Tim van der Lippe
All rights reserved.
This software may be modified and distributed under the terms
of the BSD license. See the LICENSE file for details.
-->
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../neon-animation/neon-animation-runner-behavior.html">
<link rel="import" href="iron-lazy-page.html">
<link rel="import" href="iron-lazy-pages-behavior.html">
<!--
# neon-lazy-pages
[`<neon-animated-pages>`](https://github.com/PolymerElements/neon-aniamation) with lazy-loading functionality.
@group Iron Elements
@element neon-lazy-pages
@demo demo/index.html
@hero hero.svg
-->
<dom-module id="neon-lazy-pages">
<template>
<style>
:host {
display: block;
}
</style>
<content></content>
</template>
<script>
Polymer({
is: 'neon-lazy-pages',
behaviors: [
Polymer.IronLazyPagesBehavior,
Polymer.NeonAnimationRunnerBehavior
],
properties: {
animationConfig: {
type: Object,
value: function() {
return {
'entry': [],
'exit': []
};
}
},
entryAnimation: String,
exitAnimation: String
},
_hide: function(page, cb) {
if (this._isAnimatingOut) {
return;
}
var restamp = this.restamp;
var onEnd = function() {
page._hide(restamp);
this.removeEventListener('neon-animation-finish', onEnd);
if (this._callback) {
var node = this._callback()._contentNode;
this.animationConfig.entry = (node.animationConfig && node.animationConfig.entry) || {
node: node,
name: this.entryAnimation
};
this.playAnimation('entry');
}
this._isAnimatingOut = false;
};
this.animationConfig.exit = (page._contentNode.animationConfig && page._contentNode.animationConfig.exit) || {
node: page._contentNode,
name: this.exitAnimation
};
this._isAnimatingOut = true;
this.addEventListener('neon-animation-finish', onEnd);
this.playAnimation('exit');
}
});
</script>
</dom-module>