UNPKG

1.83 kBPlain TextView Raw
1<template>
2 <section class="z-list">
3 <div v-for="(item, index) in $zircle.getCurrentPage()" :key="item[0] + '-' + index">
4 <slot v-bind="item" :index=index></slot>
5 </div>
6 <z-pagination v-if="$zircle.getNumberOfPages() > 1"
7 v-for="(page, index) in $zircle.getNumberOfPages()"
8 :key="index + '_page'"
9 :index="index"
10 :distance="112"
11 :angle="(180 - (180 - ($zircle.getNumberOfPages() * 10))) / $zircle.getNumberOfPages() * ($zircle.getNumberOfPages() - index) + ((180 - (180 - (180 - ($zircle.getNumberOfPages() * 10)))) - ((180 - (180 - ($zircle.getNumberOfPages() * 10))) / $zircle.getNumberOfPages())) / 2"
12 :active="$zircle.getCurrentPageIndex()"
13 @mouseover.native = "$zircle.allowBackwardNavigation(true)"
14 @mouseleave.native = "$zircle.allowBackwardNavigation(false)"
15 @click.native="$zircle.setCurrentPageIndex(index)"/>
16 </section>
17</template>
18
19<script>
20import ZPagination from './child-components/z-pagination'
21function chunk (myArray, chunkSize) {
22 var res = []
23 while (myArray.length) {
24 res.push(myArray.splice(0, chunkSize))
25 }
26 return res
27}
28export default {
29 name: 'z-list',
30 props: {
31 size: {
32 type: String,
33 default: 'xxl'
34 },
35 items: {
36 type: Array,
37 required: true
38 },
39 perPage: {
40 type: [Number],
41 default: 5
42 }
43 },
44 inject: ['view'],
45 components: {
46 ZPagination
47 },
48 data () {
49 return {
50 componentType: this.$options.name // fix
51 }
52 },
53 computed: {
54 position () {
55 return this.$zircle.calcViewPosition(this.$parent.fullView)
56 },
57 collectionCopy () {
58 return this.items.slice(0)
59 }
60 },
61 mounted () {
62 this.$zircle.setPages(chunk(this.collectionCopy, this.perPage))
63 },
64 created () {
65 this.$zircle.setCurrentPageIndex(0)
66 }
67}
68</script>