-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsolid-tabs.tag
More file actions
40 lines (32 loc) · 1.21 KB
/
solid-tabs.tag
File metadata and controls
40 lines (32 loc) · 1.21 KB
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
solid-tabs
div
ul
li(no-reorder each="{ item, index in model.tabs }" style="{ parent.itemWidth() }" class="{ active : active(index) }")
a(href="{ '#' + item.hash }" onclick="{ activate }") { item.label }
.underline(name='underline' style="{ itemWidth() }")
style(scoped type="scss").
@import "node_modules/riot-views/styles/solid-tabs.scss";
script.
var velocity = require('velocity-animate');
this.model = {
activeIndex : 0,
tabs : this.opts.tabs
}
this.callback = this.opts.callback || function() { };
this.itemWidth = itemWidth;
this.activate = activate;
this.active = active;
function itemWidth() {
return 'width : ' + (100 / this.opts.tabs.length) + '%;';
}
function activate() {
this.model.activeIndex = this.index;
velocity(this.underline, {
translateX : this.model.activeIndex * this.underline.offsetWidth
},
"spring");
this.callback(this.model.activeIndex);
}
function active(index) {
return this.model.activeIndex === index;
}