Browse Source

将indicator放到slide组件里面

pull/19/head
zyronon 4 years ago
parent
commit
d68d704b52
  1. 8
      src/main.js
  2. 199
      src/pages/home/Index.vue
  3. 7
      src/pages/home/Me.vue
  4. 533
      src/pages/home/Me2.vue
  5. 259
      src/pages/home/SlideList.vue

8
src/main.js

@ -18,6 +18,7 @@ import BaseHeader from "./components/BaseHeader.vue" @@ -18,6 +18,7 @@ import BaseHeader from "./components/BaseHeader.vue"
import MyCollect from "./pages/me/MyCollect.vue";
import BaseSlideList from "./components/BaseSlideList.vue";
import BaseSlideItem from "./components/BaseSlideItem.vue";
import Me2 from "./pages/home/Me2";
// 我们后面再讨论嵌套路由。
const routes = [
@ -27,6 +28,7 @@ const routes = [ @@ -27,6 +28,7 @@ const routes = [
{path: '/attention', component: Attention},
{path: '/message', component: Message},
{path: '/me', component: Me},
{path: '/me2', component: Me2},
{path: '/music', component: Music},
{path: '/countryChoose', component: countryChoose},
{path: '/MyCard', component: MyCard},
@ -41,7 +43,9 @@ const store = Vuex.createStore({ @@ -41,7 +43,9 @@ const store = Vuex.createStore({
state: {
pageAnim: 'none',
playDuration: 60,
currentVideoId:null
currentVideoId: null,
bodyHeight: document.body.clientHeight,
bodyWidth: document.body.clientWidth
},
mutations: {
setPageAnim(state, states) {
@ -123,7 +127,7 @@ const myMixin = { @@ -123,7 +127,7 @@ const myMixin = {
}
}
const app = Vue.createApp(App)
app.provide('mitt',mitt())
app.provide('mitt', mitt())
app.component('BaseHeader', BaseHeader)
app.component('BaseSlideList', BaseSlideList)

199
src/pages/home/Index.vue

@ -2,66 +2,13 @@ @@ -2,66 +2,13 @@
<div id="home-index">
<SlideList v-model:active-index="baseActiveIndex">
<SlideItem>
<div class="toolbar-ctn">
<div class="toolbar" :style="toolbarStyle">
<div class="left">直播</div>
<div class="tab-ctn">
<div class="tabs" ref="tabs">
<div class="tab"><span>双流</span></div>
<div class="tab"><span>关注</span></div>
<div class="tab"><span>推荐</span></div>
</div>
<div class="index" :style="tabIndexStyle"></div>
</div>
<div class="right" :style="{opacity:loading ? 0 : 1}">搜索</div>
</div>
<div class="notice" :style="noticeStyle"><span>下拉刷新内容</span></div>
<div class="loading" :style="loadingStyle">AA</div>
</div>
<SlideList v-model:active-index="activeIndex"
<SlideList
v-model:active-index="activeIndex"
:showIndicator="true"
:useHomeLoading="true"
>
<SlideItem style="overflow:auto;">
<div>
<p>同城页</p>
<p>同城页</p>
<p>同城页</p>
<p>同城页</p>
<p>同城页</p>
<p>同城页</p>
<p>同城页</p>
<p>同城页</p>
<p>同城页</p>
<p>同城页</p>
<p>同城页</p>
<p>同城页</p>
<p>同城页</p>
<p>同城页</p>
<p>同城页</p>
<p>同城页</p>
<p>同城页</p>
<p>同城页</p>
<p>同城页</p>
<p>同城页</p>
<p>同城页</p>
<p>同城页</p>
<p>同城页</p>
<p>同城页</p>
<p>同城页</p>
<p>同城页</p>
<p>同城页</p>
<p>同城页</p>
<p>同城页</p>
<p>同城页</p>
<p>同城页</p>
<p>同城页</p>
<p>同城页</p>
<p>同城页</p>
</div>
</SlideItem>
<SlideItem>
<SlideList direction="column"
@end="end"
@first="first"
>
<SlideItem style="background: tan">
<p>111111111111</p>
@ -143,14 +90,13 @@ @@ -143,14 +90,13 @@
</SlideList>
</SlideItem>
<SlideItem>
<SlideList direction="column"
ref="slideList"
v-model:active-index="videoActiveIndex"
:virtual="true"
:total="total"
@end="end"
@first="first"
@slide="slide">
<SlideList
direction="column"
ref="slideList"
v-model:active-index="videoActiveIndex"
:virtual="true"
:total="total"
@slide="slide">
<SlideItem :style="itemTop" v-for="(item,index) of videos">
<Video
:disabled="videoActiveIndex !== addCount + index"
@ -220,7 +166,7 @@ import Comment from '../../components/Comment.vue' @@ -220,7 +166,7 @@ import Comment from '../../components/Comment.vue'
import Other from '../../components/Other.vue'
import Share from '../../components/Share.vue'
import Footer from "../../components/Footer.vue"
import mp41 from '../../assets/video/10.mp4'
import mp41 from '../../assets/video/1.mp4'
import mp42 from '../../assets/video/2.mp4'
import mp43 from '../../assets/video/3.mp4'
import mp44 from '../../assets/video/4.mp4'
@ -293,7 +239,7 @@ export default { @@ -293,7 +239,7 @@ export default {
isCommenting: false,
isSharing: false,
baseActiveIndex: 0,
activeIndex: 2,
activeIndex: 1,
videoActiveIndex: 0,
tabWidth: 30,
@ -310,69 +256,12 @@ export default { @@ -310,69 +256,12 @@ export default {
itemTop() {
return {top: this.addCount * 812 + 'px'}
},
tabIndexStyle() {
return {
width: `${this.tabWidth * 0.7}px`,
//slide emitmoveX
transform: `translate3d(${this.tabIndexRelationActiveIndexLefts[this.activeIndex]}px, 0, 0)`,
'transition-duration': '300ms',
}
},
toolbarStyle() {
return {
opacity: 1 - this.slideMoveYDistance / 20,
'transition-duration': this.toolbarStyleTransitionDuration + 'ms',
transform: `translate3d(0, ${this.slideMoveYDistance > 60 ? 60 : this.slideMoveYDistance}px, 0)`,
}
},
noticeStyle() {
return {
opacity: this.slideMoveYDistance / 60,
'transition-duration': this.toolbarStyleTransitionDuration + 'ms',
transform: `translate3d(0, ${this.slideMoveYDistance > 60 ? 60 : this.slideMoveYDistance}px, 0)`,
}
},
loadingStyle() {
if (this.loading) {
return {
opacity: 1,
'transition-duration': '300ms',
}
}
if (this.slideMoveYDistance !== 0) {
return {
opacity: this.slideMoveYDistance / 60,
'transition-duration': this.toolbarStyleTransitionDuration + 'ms',
transform: `translate3d(0, ${this.slideMoveYDistance > 60 ? 60 : this.slideMoveYDistance}px, 0)`,
}
}
}
},
mounted() {
let tabs = this.$refs.tabs
// let tabWidth = this.$getCss(tabs, 'width')
for (let i = 0; i < tabs.children.length; i++) {
let item = tabs.children[i]
this.tabWidth = this.$getCss(item, 'width')
this.tabIndexRelationActiveIndexLefts.push(
item.getBoundingClientRect().x - tabs.children[0].getBoundingClientRect().x + this.tabWidth * 0.15)
}
this.height = document.body.clientHeight
this.width = document.body.clientWidth
},
methods: {
end() {
if (this.slideMoveYDistance > 60) {
this.getData()
}
this.slideMoveYDistance = 0;
this.toolbarStyleTransitionDuration = 300
},
first(e) {
if (this.loading) return
this.slideMoveYDistance = e
this.toolbarStyleTransitionDuration = 0
},
getData() {
this.loading = true
setTimeout(() => {
@ -412,67 +301,5 @@ export default { @@ -412,67 +301,5 @@ export default {
height: 100%;
width: 100%;
position: relative;
.toolbar-ctn {
position: fixed;
font-size: 1.6rem;
top: 0;
left: 0;
height: 60px;
z-index: 2;
width: 100%;
color: white;
.notice {
opacity: 0;
top: 0;
position: absolute;
width: 100vw;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
}
.loading {
opacity: 0;
top: 20px;
right: 15px;
position: absolute;
}
.toolbar {
position: relative;
color: white;
//background: #fff;
width: 100%;
height: 100%;
box-sizing: border-box;
padding: 0 15px;
display: flex;
justify-content: space-between;
align-items: center;
//display: none;
.tab-ctn {
width: 40%;
position: relative;
.tabs {
display: flex;
justify-content: space-between;
}
.index {
position: absolute;
bottom: -8px;
height: 3px;
background: #fff;
border-radius: 5px;
}
}
}
}
}
</style>

7
src/pages/home/Me.vue

@ -27,7 +27,7 @@ @@ -27,7 +27,7 @@
<p>我页面</p>
<p>我页面</p>
<p>我页面</p>
<SlideList key1="父" style="width: 100vw;">
<SlideList style="width: 100vw;" :active-index="contentIndex">
<SlideItem>
1
</SlideItem>
@ -35,7 +35,7 @@ @@ -35,7 +35,7 @@
2
</SlideItem>
<SlideItem>
<div>
<div class="content">
<p>喜欢</p>
<p>喜欢</p>
<p>喜欢</p>
@ -142,7 +142,8 @@ export default { @@ -142,7 +142,8 @@ export default {
data() {
return {
serviceEl: {},
serviceHeight: 0
serviceHeight: 0,
contentIndex:0
}
},
}

533
src/pages/home/Me2.vue

@ -1,23 +1,255 @@ @@ -1,23 +1,255 @@
<template>
<div className="Me">
<SlideList key1="父" style="width: 100vw;">
<SlideItem>
</SlideItem>
</SlideList>
<div class="Me" >
<div class="wrapper">
<div class="left">
<header>
<img src="../../assets/img/icon/next.svg" alt="" @click="$emit('back')">
<img src="../../assets/img/icon/more.svg" alt="">
</header>
<div class="detail">
<div class="head">
<img src="../../assets/img/icon/head-image.jpeg" class="head-image">
<div class="other-buttons" v-if="false">
<div class="attention">
关注
</div>
<div class="more-attention">
-
</div>
</div>
<div class="my-buttons ">
<div class="collect">
<img src="../../assets/img/icon/collect-white.svg" alt="">
<span class="mr5p">收藏</span>
</div>
<div class="add-friend">
<img src="../../assets/img/icon/add-friend-white.svg" alt="">
</div>
<div class="qr-code">
<img src="../../assets/img/icon/qr-code-white.svg" alt="">
</div>
</div>
</div>
<div class="description">
<p class="name f22 mt5p mb5p">ttentau</p>
<div class="number mb10p">
<span>抖音号605128307</span>
<div class="jrtt">
<img src="../../assets/img/icon/sina.svg" alt="">
<span>头条主页</span>
<img src="../../assets/img/icon/next.svg" alt="">
</div>
</div>
<div class="signature f12 mb10p">
<span>填写个性签名更容易获得别人关注哦</span>
</div>
<div class="info f10 mb10p">
<div class="age">
<img src="../../assets/img/icon/person.svg" alt="">
<span>22</span>
</div>
<div class="location">
<span>上海</span>
</div>
<div class="school">
四川理工大学
</div>
</div>
<div class="heat">
<span>8获赞</span>
<span>38关注</span>
<span>42粉丝</span>
</div>
</div>
</div>
<div class="indicator-ctn">
<div class="tabs-text-ctn">
<div class="tab-text active">作品1</div>
<div class="tab-text">作品1</div>
<div class="tab-text">作品1</div>
</div>
<div class="indicator"></div>
</div>
<div class="tabs-ctn">
<div class="tabs">
<div class="tab tab1">
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
</div>
<div class="tab tab2">
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
</div>
<div class="tab tab3">
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
<p>12</p>
</div>
</div>
</div>
<my-footer v-bind:init-tab="5"></my-footer>
</div>
<div class="right">
<ul>
<li @click="nav('MyCard')">
<img src="../../assets/img/icon/card-gray.png" alt="">
<span>个人名片</span>
</li>
<li @click="nav('MyCollect')">
<img src="../../assets/img/icon/collect-gray.png" alt="">
<span>我的收藏</span>
</li>
<div class="line"></div>
<li>
<img src="../../assets/img/icon/wallet-gray.png" alt="">
<span>钱包</span>
</li>
<li>
<img src="../../assets/img/icon/order-gray.png" alt="">
<span>订单</span>
</li>
<li class="exception" @click="toggleService()">
<div class="d-flex align-items-center">
<img src="../../assets/img/icon/category-gray.png" alt="">
<span>服务</span>
</div>
<div class="triangle"></div>
</li>
<div class="service">
<li>
<img src="../../assets/img/icon/order-gray.png" alt="" class="op0">
<span>购物助手</span>
</li>
<li>
<img src="../../assets/img/icon/order-gray.png" alt="" class="op0">
<span>生活服务订单</span>
</li>
<li>
<img src="../../assets/img/icon/order-gray.png" alt="" class="op0">
<span>DOU+ 上热门</span>
</li>
<li>
<img src="../../assets/img/icon/order-gray.png" alt="" class="op0">
<span>彩铃服务</span>
</li>
<li>
<img src="../../assets/img/icon/order-gray.png" alt="" class="op0">
<span>免流量看抖音</span>
</li>
</div>
<div class="line"></div>
<li>
<img src="../../assets/img/icon/link-gray.png" alt="">
<span>小程序</span>
</li>
<li>
<img src="../../assets/img/icon/juan-gray.png" alt="">
<span>卡卷</span>
</li>
<div class="line"></div>
<li>
<img src="../../assets/img/icon/umbrella-gray.png" alt="">
<span>未成年保护工具</span>
</li>
<div class="line"></div>
<li>
<img src="../../assets/img/icon/setting-gray.png" alt="">
<span>设置</span>
</li>
</ul>
</div>
</div>
</div>
</template>
<script>
import Footer from '../../components/Footer.vue'
import Comment from "../../components/Comment";
import Share from "../../components/Share";
import Other from "../../components/Other";
import SlideList from "./SlideList";
import SlideItem from "./SlideItem";
import Footer from '../../components/Footer'
export default {
name: "Me",
components: {Footer, Comment, Share, Other, SlideList, SlideItem},
components: { 'my-footer': Footer },
data() {
return {
serviceEl: {},
@ -442,7 +674,7 @@ export default { @@ -442,7 +674,7 @@ export default {
console.log(this.serviceEl.style.height)
if (this.serviceEl.style.height === this.serviceHeight + 'px') {
this.serviceEl.style.height = 0
} else {
}else {
this.serviceEl.style.height = this.serviceHeight + 'px'
}
}
@ -454,8 +686,279 @@ export default { @@ -454,8 +686,279 @@ export default {
$left-bg-color: #333;
$right-bg-color: #2e3244;
.Me {
position: fixed;
font-size: 1.6rem;
height: 100%;
width: 100%;
height: 100%;
overflow: hidden;
.wrapper {
position: relative;
display: flex;
width: 100%;
height: 100%;
.left {
left: 0;
top: 0;
position: absolute;
height: 100%;
width: 100%;
background: $left-bg-color;
overflow-y: scroll;
header {
height: 150px;
/* background-image: url('./imgs/header2.jpg'); */
background-image: url('data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxAQEBAQEBAPEBAPEBAPDw8QDw8NEA8OFRIWFhURFRUYHSggGBolGxUVITEhJSkrLi4uFx8zODMtNygtLisBCgoKDg0OGBAQGC0dHR0tLS0rKy0tLS0tLS0tKy0tKy0tLSstLS0tLS0tLSstLSstLS0tKy0tLS0tLS0tLisrN//AABEIAKgBLAMBIgACEQEDEQ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AAWCwAAWCwAAWAugAAIoAAA00MZJaPVD8RWzJW4czn2G0arXQG1E0VTGOzFyNM4GQAWGqAABosmFypITF6cuI+lO1zOmTGYXGmVUTJlc5VzBV7ipE5irCYZFi5PUkgEi8XoWzC0wuXU8V2yLlAGr4r3C5QBpgAAMNgAAAAAAAAAAAAAAAAAAAAAAAAACYAAAoAAAAAAAAAJgAACgAAAAAAAAAAAAJgAABj/2Q==');
background-size: cover;
background-position: center;
background-repeat: no-repeat;
display: flex;
justify-content: space-between;
/*background: url("../../assets/img/icon/top-bg.jpg");*/
padding: 20px;
img {
border-radius: 50%;
padding: 5px;
background: #524a4a;
height: 20px;
width: 20px;
&:nth-child(1) {
transform: rotate(180deg);
}
}
}
.detail {
background: $left-bg-color;
padding: 0 20px;
.head {
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
box-sizing: border-box;
transform: translateY(-20px);
.head-image {
background: black;
padding: 5px;
border-radius: 50%;
width: 80px;
height: 80px;
}
.my-buttons {
div {
display: flex;
align-items: center;
float: left;
border-radius: 2px;
background: #676767;
margin-right: 5px;
img {
padding: 6px;
height: 20px;
}
span {
color: #cdcdcd;
}
}
}
}
.description {
color: white;
transform: translateY(-20px);
.number {
padding-bottom: 10px;
border-bottom: 1px solid gray;
.jrtt {
float: right;
img {
height: 10px;
width: 10px;
}
span {
margin: 0 5px;
}
}
}
.info {
display: flex;
align-items: center;
div {
display: flex;
align-items: center;
float: left;
border-radius: 2px;
background: #676767;
margin-right: 5px;
padding: 2px 4px;
img {
height: 10px;
margin-right: 3px;
}
span {
color: #cdcdcd;
}
}
}
.heat {
span {
margin-right: 10px;
}
}
}
}
.tabs-ctn {
height: 100%;
width: 100%;
overflow: hidden;
}
.tabs {
left: 0;
transition: all 0.3s ease 0s;
height: 100%;
width: 100%;
position: relative;
}
.tab {
left: 0;
top: 0;
position: absolute;
width: 100%;
background: red;
overflow-y: scroll;
}
.tab:nth-child(2) {
left: 100%;
background: gold;
}
.tab:nth-child(3) {
left: 200%;
background: blue;
}
.indicator-ctn {
top: 0;
left: 0;
right: 0;
z-index: 999;
background: #333;
}
.indicator-ctn.fixed {
position: fixed;
}
.indicator {
height: 2px;
background: gold;
width: 30%;
margin-left: 1.5%;
transition: all .3s;
}
.tabs-text-ctn {
height: 40px;
display: flex;
justify-content: space-around;
align-items: center;
color: gray;
}
.tab-text.active {
color: white;
}
}
.right {
top: 0;
left: 100%;
position: absolute;
height: 100%;
width: 70%;
color: white;
background: $right-bg-color;
ul {
height: 100%;
overflow: auto;
padding: 0;
.line {
height: 1px;
background: #cccccc;
opacity: .1;
margin: 5px 20px;
}
.service {
transition: all .3s;
overflow: hidden;
}
li {
background: $right-bg-color;
padding: 20px;
list-style: none;
display: flex;
align-items: center;
&:active {
background: #454b65;
}
img {
height: 30px;
width: 30px;
margin-right: 20px;
}
&.exception {
justify-content: space-between;
.triangle {
transform: translateY(3px);
width: 0;
height: 0;
border-top: 7px solid #cccccc;
border-right: 7px solid transparent;
border-bottom: 7px solid transparent;
border-left: 7px solid transparent;
}
}
}
}
}
}
}
</style>

259
src/pages/home/SlideList.vue

@ -1,5 +1,25 @@ @@ -1,5 +1,25 @@
<template>
<div id="base-slide-wrapper" ref="slideWrapper">
<div class="toolbar-ctn" v-if="showIndicator">
<div class="notice" :style="noticeStyle"><span>下拉刷新内容</span></div>
<div class="toolbar" ref="toolbar" :style="toolbarStyle">
<div class="left">直播</div>
<div class="tab-ctn">
<div class="tabs" ref="tabs">
<div class="tab"
:class="currentSlideItemIndex === 0?'active':''"
@click="changeIndex(false,0)">
<span>关注</span></div>
<div class="tab"
:class="currentSlideItemIndex === 1?'active':''"
@click="changeIndex(false,1)"><span>推荐</span></div>
</div>
<div class="indicator" ref="indicator"></div>
</div>
<div class="right" :style="{opacity:loading ? 0 : 1}">搜索</div>
</div>
<div class="loading" :style="loadingStyle">AA</div>
</div>
<div id="base-slide-list" ref="slideList"
:style="{'flex-direction':direction}"
@touchstart="touchStart($event)"
@ -18,6 +38,14 @@ export default { @@ -18,6 +38,14 @@ export default {
type: String,
default: () => 'row'
},
showIndicator: {
type: Boolean,
default: () => false
},
useHomeLoading: {
type: Boolean,
default: () => false
},
virtual: {
type: Boolean,
default: () => false
@ -30,22 +58,50 @@ export default { @@ -30,22 +58,50 @@ export default {
type: Number,
default: () => 0
},
// slideMoveXDistance: {
// type: Number,
// default: () => 0
// }
},
computed: {
toolbarStyle() {
if (!this.useHomeLoading) return
return {
opacity: 1 - this.homeLoadingMoveYDistance / 20,
'transition-duration': this.toolbarStyleTransitionDuration + 'ms',
transform: `translate3d(0, ${this.homeLoadingMoveYDistance > 60 ? 60 : this.homeLoadingMoveYDistance}px, 0)`,
}
},
noticeStyle() {
if (!this.useHomeLoading) return
return {
opacity: this.homeLoadingMoveYDistance / 60,
'transition-duration': this.toolbarStyleTransitionDuration + 'ms',
transform: `translate3d(0, ${this.homeLoadingMoveYDistance > 60 ? 60 : this.homeLoadingMoveYDistance}px, 0)`,
}
},
loadingStyle() {
if (!this.useHomeLoading) return
if (this.loading) {
return {
opacity: 1,
'transition-duration': '300ms',
}
}
if (this.homeLoadingMoveYDistance !== 0) {
return {
opacity: this.homeLoadingMoveYDistance / 60,
'transition-duration': this.toolbarStyleTransitionDuration + 'ms',
transform: `translate3d(0, ${this.homeLoadingMoveYDistance > 60 ? 60 : this.homeLoadingMoveYDistance}px, 0)`,
}
}
}
},
data() {
return {
loading: false,
wrapperWidth: 0,
wrapperHeight: 0,
startLocationX: 0,
startLocationY: 0,
lastLocationX: 0,
lastLocationY: 0,
moveXDistance: 0,
moveYDistance: 0,
@ -61,42 +117,59 @@ export default { @@ -61,42 +117,59 @@ export default {
slideList: null,
slideItems: null,
indicatorRef: null,
slideItemsWidths: [],
slideItemsHeights: [],
tabIndicatorRelationActiveIndexLefts: [],//slideItemindexleft,
indicatorSpace: 0,//indicator
toolbarStyleTransitionDuration: 0,
homeLoadingMoveYDistance: 0,//homeLoadingMoveYDistanceMoveYDistance
//toolbarMoveYDistancedirection = row
}
},
watch: {
activeIndex() {
this.currentSlideItemIndex = this.activeIndex
this.$setCss(this.slideList, 'transition-duration', `300ms`)
if (this.direction === 'row') {
this.$setCss(this.slideList, 'transform', `translate3d(${-this.getWidth(this.currentSlideItemIndex)}px, 0px, 0px)`)
} else {
this.$setCss(this.slideList, 'transform', `translate3d(0px, ${-this.getHeight(this.currentSlideItemIndex)}px, 0px)`)
}
}
this.changeIndex()
},
},
mounted() {
this.checkChildren(true)
this.currentSlideItemIndex = this.activeIndex
if (this.direction === 'row') {
this.$setCss(this.slideList, 'transform', `translate3d(${-this.getWidth(this.currentSlideItemIndex) + this.moveXDistance}px, 0px, 0px)`)
} else {
this.$setCss(this.slideList, 'transform', `translate3d(0px, ${-this.getHeight(this.currentSlideItemIndex) + this.moveYDistance}px, 0px)`)
}
this.showIndicator && this.initTabs()
this.changeIndex(true)
},
methods: {
// emitMoveXDistance: _.throttle(function () {
// // this.$emit('moveXDistance', this.moveXDistance)
// this.$emit('update:test', this.moveXDistance)
// }, 500),
changeIndex(init = false, index = null) {
this.currentSlideItemIndex = index !== null ? index : this.activeIndex
!init && this.$setCss(this.slideList, 'transition-duration', `300ms`)
if (this.direction === 'row') {
this.$setCss(this.slideList, 'transform', `translate3d(${-this.getWidth(this.currentSlideItemIndex) + this.moveXDistance}px, 0px, 0px)`)
if (this.showIndicator) {
this.$setCss(this.indicatorRef, 'left', this.tabIndicatorRelationActiveIndexLefts[this.currentSlideItemIndex] + 'px')
}
} else {
this.$setCss(this.slideList, 'transform', `translate3d(0px, ${-this.getHeight(this.currentSlideItemIndex) + this.moveYDistance}px, 0px)`)
}
},
initTabs() {
let tabs = this.$refs.tabs
this.indicatorRef = this.$refs.indicator
for (let i = 0; i < tabs.children.length; i++) {
let item = tabs.children[i]
this.tabWidth = this.$getCss(item, 'width')
this.tabIndicatorRelationActiveIndexLefts.push(
item.getBoundingClientRect().x - tabs.children[0].getBoundingClientRect().x + this.tabWidth * 0.15)
}
this.indicatorSpace = this.tabIndicatorRelationActiveIndexLefts[1] - this.tabIndicatorRelationActiveIndexLefts[0]
if (this.showIndicator) {
this.$setCss(this.indicatorRef, 'transition-duration', `300ms`)
this.$setCss(this.indicatorRef, 'left', this.tabIndicatorRelationActiveIndexLefts[this.currentSlideItemIndex] + 'px')
}
},
checkChildren(init) {
this.slideList = this.$refs.slideList
this.slideItems = this.slideList.children
this.wrapperWidth = this.$getCss(this.slideList, 'width')
this.wrapperHeight = this.$getCss(this.slideList, 'height')
// console.log(this.wrapperWidth)
// console.log(this.wrapperHeight)
for (let i = 0; i < this.slideItems.length; i++) {
let el = this.slideItems[i]
@ -106,42 +179,44 @@ export default { @@ -106,42 +179,44 @@ export default {
},
touchStart(e) {
this.$setCss(this.slideList, 'transition-duration', `0ms`)
this.showIndicator && this.$setCss(this.indicatorRef, 'transition-duration', `0ms`)
this.toolbarStyleTransitionDuration = 0
this.startLocationX = e.touches[0].pageX
this.startLocationY = e.touches[0].pageY
// console.log('this.startLocationX', this.startLocationX)
// console.log('this.startLocationY', this.startLocationY)
this.startTime = Date.now()
},
touchMove(e) {
// console.log(e)
this.lastLocationX = e.touches[0].pageX
this.lastLocationY = e.touches[0].pageY
this.moveXDistance = this.lastLocationX - this.startLocationX
this.moveYDistance = this.lastLocationY - this.startLocationY
this.moveXDistance = e.touches[0].pageX - this.startLocationX
this.moveYDistance = e.touches[0].pageY - this.startLocationY
// console.log(this.key)
// console.log(this.direction + ' moveXDistance', this.moveXDistance)
// console.log(this.direction + ' moveYDistance', this.moveYDistance)
// console.log('currentSlideItemIndex', this.currentSlideItemIndex)
this.isDrawRight = this.moveXDistance < 0
this.isDrawDown = this.moveYDistance < 0
this.checkDirection()
//this.isCanDownWiping toolbar
//slideitem使moveYDistance
if (this.useHomeLoading && this.isCanDownWiping && !this.loading) {
this.homeLoadingMoveYDistance = this.moveYDistance
}
if (this.direction === 'row') {
if (this.isCanRightWiping) {
// //index=0
if (this.currentSlideItemIndex === 0 && !this.isDrawRight) return
//
if (this.currentSlideItemIndex === this.slideItems.length - 1 && this.isDrawRight) return
// this.$attrs['onUpdate:slideMoveXDistance'] && this.$emit('update:slideMoveXDistance', this.moveXDistance)
this.stop(e)
this.$stopPropagation(e)
this.$setCss(this.slideList, 'transform', `translate3d(${-this.getWidth(this.currentSlideItemIndex) + this.moveXDistance}px, 0px, 0px)`)
this.showIndicator && this.$setCss(this.indicatorRef, 'left',
this.tabIndicatorRelationActiveIndexLefts[this.currentSlideItemIndex] -
this.moveXDistance / (this.$store.state.bodyWidth / this.indicatorSpace) + 'px')
}
} else {
if (this.isCanDownWiping) {
if (this.currentSlideItemIndex === 0 && !this.isDrawDown) {
if (this.currentSlideItemIndex === 0 && !this.isDrawDown) {//item
this.$attrs['onFirst'] && this.$emit('first', this.moveYDistance)
return
}
@ -151,15 +226,28 @@ export default { @@ -151,15 +226,28 @@ export default {
if (this.currentSlideItemIndex === this.slideItems.length - 1 && this.isDrawDown) return
}
// this.$attrs.moveYDistance && this.$emit('moveYDistance', this.moveYDistance)
this.stop(e)
this.$stopPropagation(e)
this.$setCss(this.slideList, 'transform', `translate3d(0px, ${-this.getHeight(this.currentSlideItemIndex) + this.moveYDistance}px, 0px)`)
}
}
},
getData() {
this.loading = true
setTimeout(() => {
this.loading = false
}, 1500)
},
touchEnd(e) {
// console.log(this.$attrs)
this.$attrs['onEnd'] && this.$emit('end')
if (this.useHomeLoading) {
if (this.homeLoadingMoveYDistance > 60) {
this.getData()
}
this.toolbarStyleTransitionDuration = 300
this.homeLoadingMoveYDistance = 0
}
this.$setCss(this.slideList, 'transition-duration', `300ms`)
this.showIndicator && this.$setCss(this.indicatorRef, 'transition-duration', `300ms`)
let endTime = Date.now()
let gapTime = endTime - this.startTime
// console.log(gapTime)
@ -177,6 +265,9 @@ export default { @@ -177,6 +265,9 @@ export default {
}
}
this.$setCss(this.slideList, 'transform', `translate3d(${-this.getWidth(this.currentSlideItemIndex)}px, 0px, 0px)`)
if (this.showIndicator) {
this.$setCss(this.indicatorRef, 'left', this.tabIndicatorRelationActiveIndexLefts[this.currentSlideItemIndex] + 'px')
}
} else {
if (this.currentSlideItemIndex === 0 && !this.isDrawDown) return
//
@ -211,11 +302,6 @@ export default { @@ -211,11 +302,6 @@ export default {
this.moveXDistance = 0
this.moveYDistance = 0
},
stop(e) {
e.stopImmediatePropagation()
e.stopPropagation()
e.preventDefault()
},
getWidth(index) {
return this.slideItemsWidths.reduce((p, c, i) => {
if (i < index) {
@ -257,9 +343,7 @@ export default { @@ -257,9 +343,7 @@ export default {
this.isCanDownWiping = false
this.isCanRightWiping = true
this.isNeedCheck = false
return
}
return;
}
}
}
@ -277,6 +361,79 @@ export default { @@ -277,6 +361,79 @@ export default {
width: 100%;
position: relative;
}
.toolbar-ctn {
position: fixed;
font-size: 1.6rem;
top: 0;
left: 0;
height: 60px;
z-index: 2;
width: 100%;
color: white;
.notice {
opacity: 0;
top: 0;
position: absolute;
width: 100vw;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
}
.loading {
opacity: 0;
top: 20px;
right: 15px;
position: absolute;
}
.toolbar {
position: relative;
color: white;
width: 100%;
height: 100%;
box-sizing: border-box;
padding: 0 15px;
display: flex;
justify-content: space-between;
align-items: center;
.tab-ctn {
width: 30%;
position: relative;
.tabs {
display: flex;
justify-content: space-between;
font-weight: bold;
.tab {
transition: color .3s;
color: gray;
&.active {
color: white;
}
}
}
.indicator {
//transition: left .3s;
position: absolute;
bottom: -8px;
height: 3px;
width: 20px;
background: #fff;
border-radius: 5px;
}
}
}
}
}
</style>
Loading…
Cancel
Save