Skip to content
This repository was archived by the owner on Jul 30, 2020. It is now read-only.

Commit ae0db78

Browse files
committed
首页栏目切换动画
1 parent 5e85cf1 commit ae0db78

File tree

2 files changed

+35
-22
lines changed

2 files changed

+35
-22
lines changed

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"python.linting.enabled": false
3+
}

src/pages/index/index.vue

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
<template>
22
<div class='container'>
33
<div class='header'>
4-
<div :class='{ active: tab==="all" }' @click.stop='changeTab($event)' data-tab='all'>全部</div>
5-
<div :class='{ active: tab==="good" }' @click.stop='changeTab($event)' data-tab='good'>精华</div>
6-
<div :class='{ active: tab==="share" }' @click.stop='changeTab($event)' data-tab='share'>分享</div>
7-
<div :class='{ active: tab==="job" }' @click.stop='changeTab($event)' data-tab='job'>招聘</div>
8-
<div :class='{ active: tab==="ask" }' @click.stop='changeTab($event)' data-tab='ask'>问答</div>
4+
<div :class='{ active: tab==="all" }' @click.stop='changeTab($event)' data-tab='all' :data-offset='0'>全部</div>
5+
<div :class='{ active: tab==="good" }' @click.stop='changeTab($event)' data-tab='good' :data-offset='1'>精华</div>
6+
<div :class='{ active: tab==="share" }' @click.stop='changeTab($event)' data-tab='share' :data-offset='2'>分享</div>
7+
<div :class='{ active: tab==="job" }' @click.stop='changeTab($event)' data-tab='job' :data-offset='3'>招聘</div>
8+
<div :class='{ active: tab==="ask" }' @click.stop='changeTab($event)' data-tab='ask' :data-offset='4'>问答</div>
99
</div>
10-
<div v-for='(listItem,listIndex) in list' :key='listIndex' v-show="listItem===tab">
11-
<scroll-view scroll-y class='scroll-container' @scrolltolower='getMore'>
12-
<div v-for='item in cardData[listItem]' :key='item.id'>
13-
<card :item='item'></card>
14-
</div>
15-
</scroll-view>
10+
<div class="containers" :animation='animation'>
11+
<div v-for='(listItem,listIndex) in list' :key='listIndex'>
12+
<scroll-view scroll-y class='scroll-container' @scrolltolower='getMore'>
13+
<div v-for='item in cardData[listItem]' :key='item.id'>
14+
<card :item='item'></card>
15+
</div>
16+
</scroll-view>
17+
</div>
1618
</div>
1719
</div>
1820
</template>
@@ -34,12 +36,8 @@ export default {
3436
ask: []
3537
},
3638
isLoading: false,
37-
list: ["all", "good", "share", "job", "ask"]
38-
// all: [],
39-
// good: [],
40-
// share: [],
41-
// job: [],
42-
// ask: []
39+
list: ["all", "good", "share", "job", "ask"],
40+
animation: {}
4341
};
4442
},
4543
components: {
@@ -64,8 +62,6 @@ export default {
6462
if (res.data.success) {
6563
if (this.cardData[tab].length > 0 && page === 0) {
6664
// 下拉刷新
67-
console.log("新的", res.data.data, tab);
68-
6965
this.cardData[tab] = res.data.data;
7066
// res.data.data;
7167
} else {
@@ -89,13 +85,23 @@ export default {
8985
},
9086
changeTab(e) {
9187
const currentTab = e.target.dataset.tab;
88+
const offset = e.target.dataset.offset;
9289
this.tab = currentTab;
9390
this.page = 0;
9491
this.getData(currentTab, 0);
92+
this.animation = wx
93+
.createAnimation({
94+
duration: 1000,
95+
timingFunction: "ease"
96+
})
97+
.left(`-${offset * 100}vw`)
98+
.step()
99+
.export();
95100
}
96101
}
97102
};
98103
</script>
104+
99105
<style lang="scss" scoped>
100106
.container {
101107
background-color: rgb(245, 245, 249);
@@ -111,11 +117,15 @@ export default {
111117
line-height: 86rpx;
112118
}
113119
}
114-
.scroll-container {
115-
height: 90vh;
120+
.containers {
121+
display: flex;
122+
position: relative;
123+
.scroll-container {
124+
height: 90vh;
125+
width: 100vw;
126+
}
116127
}
117128
}
118-
119129
.header .header > div + .header > div {
120130
border-left: 2rpx solid white;
121131
}

0 commit comments

Comments
 (0)