-
Notifications
You must be signed in to change notification settings - Fork 53
/
slider.js
75 lines (65 loc) · 1.85 KB
/
slider.js
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
import { bindable, customElement, inlineView } from 'aurelia-templating';
import { bindingMode } from 'aurelia-binding';
import { inject } from 'aurelia-dependency-injection';
import { getBooleanFromAttributeValue } from '../common/attributes';
import { getLogger } from 'aurelia-logging';
@customElement('md-slider')
@inject(Element)
@inlineView(`
<template class="slider">
<require from="./slider.css"></require>
<ul class="slides">
<slot></slot>
</ul>
</template>
`)
export class MdSlider {
@bindable({ defaultBindingMode: bindingMode.oneTime }) mdFillContainer = false;
@bindable({ defaultBindingMode: bindingMode.oneTime }) mdHeight = 400;
@bindable() mdIndicators = true;
@bindable({ defaultBindingMode: bindingMode.oneTime }) mdInterval = 6000;
@bindable({ defaultBindingMode: bindingMode.oneTime }) mdTransition = 500;
constructor(element) {
this.element = element;
this.log = getLogger('md-slider');
}
attached() {
if (getBooleanFromAttributeValue(this.mdFillContainer)) {
this.element.classList.add('fullscreen');
}
this.refresh();
}
pause() {
$(this.element).slider('pause');
}
start() {
$(this.element).slider('start');
}
next() {
$(this.element).slider('next');
}
prev() {
$(this.element).slider('prev');
}
refresh() {
let options = {
height: parseInt(this.mdHeight, 10),
indicators: getBooleanFromAttributeValue(this.mdIndicators),
interval: parseInt(this.mdInterval, 10),
transition: parseInt(this.mdTransition, 10)
};
this.log.debug('refreshing slider, params:', options);
$(this.element).slider(options);
}
mdIndicatorsChanged() {
this.refresh();
}
// commented since that leads to strange effects
// mdIntervalChanged() {
// this.refresh();
// }
//
// mdTransitionChanged() {
// this.refresh();
// }
}