-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
BasicPager.vue
57 lines (54 loc) · 1.64 KB
/
BasicPager.vue
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
<template>
<Page>
<ActionBar>
<NavigationButton text="Back" android.systemIcon="ic_menu_back" />
<Label text="Basic Pager" />
</ActionBar>
<GridLayout class="page" rows="*,auto">
<Pager ref="pager" for="item in items" height="100%" peaking="30" spacing="10" pagesCount="3">
<v-template>
<GridLayout :backgroundColor="item.color">
<Label :text="item.title" />
</GridLayout>
</v-template>
</Pager>
<StackLayout orientation="horizontal" row="1">
<Button text="moveTo0" @tap="moveTo0"></Button>
<Button text="moveTo3" @tap="moveTo3"></Button>
</StackLayout>
</GridLayout>
</Page>
</template>
<script lang="ts">
import { Pager } from '@nativescript-community/ui-pager';
export default {
data() {
return {
items: [
{ title: 'First', color: '#e67e22' },
{ title: 'Second', color: '#3498db' },
{ title: 'Third', color: '#e74c3c' },
{ title: 'Fourth', color: '#9b59b6' }
]
};
},
methods: {
moveTo3() {
(this.$refs.pager.nativeView as Pager).scrollToIndexAnimated(3, true);
},
moveTo0() {
(this.$refs.pager.nativeView as Pager).scrollToIndexAnimated(0, false);
}
}
};
</script>
<style lang="scss" scoped>
.page Label {
font-size: 35;
text-align: center;
width: 100%;
vertical-alignment: center;
color: #ffffff;
text-transform: uppercase;
}
</style>