-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathsimple-slider.html
72 lines (65 loc) · 2.29 KB
/
simple-slider.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
<link rel="import" href="../polymer/polymer.html">
<script src="../simple-slider/dist/simpleslider.min.js"></script>
<dom-element is="simple-slider">
<script>
Polymer({
is: 'simple-slider',
properties: {
transitionProperty: { type: String },
transitionDuration: { type: Number },
transitionDelay: { type: Number },
transitionStartDelay: { type: Number },
startValue: { type: String },
visibleValue: { type: String },
endValue: { type: String },
noAutoPlay: { type: Boolean },
autoReload: { type: Boolean }
},
attached: function () {
var slider = new window.SimpleSlider(this, {
transitionProperty: this.transitionProperty,
transitionDuration: this.transitionDuration,
transitionDelay: this.transitionDelay,
startValue: this.startValue,
visibleValue: this.visibleValue,
endValue: this.endValue,
autoPlay: !this.noAutoPlay,
onChange: function (prevIndex, nextIndex) {
this.fire('change', {
prevIndex: prevIndex,
nextIndex: nextIndex
});
}.bind(this),
onChangeEnd: function (prevIndex, nextIndex) {
this.fire('change-end', {
prevIndex: prevIndex,
nextIndex: nextIndex
});
}.bind(this)
});
slider.pauseAutoPlay();
this.__resumeAutoPlay = setTimeout(function() {
!this.noAutoPlay && slider.resumeAutoPlay();
}.bind(this), this.transitionStartDelay || 0);
this.slider = slider;
// Reload slider if children nodes are added / removed
var me = this;
Polymer.dom(this).observeNodes(function(info) {
if (me.autoReload) slider.init();
});
},
// Dispose slider on element detach
detached: function () {
this.slider.dispose();
},
// Define slider methods on polymer element
actualIndex: function() { return this.slider.actualIndex; },
change: function(index) { this.slider.change(index); },
next: function() { this.slider.next(); },
prev: function() { this.slider.prev(); },
prevIndex: function() { return this.slider.prevIndex(); },
nextIndex: function() { return this.slider.nextIndex(); },
dispose: function() { this.slider.dispose(); },
});
</script>
</dom-element>