speedview.vue 1.7 KB
<template>
	<view class="speed-wrap-box" @click="speedbgTap" v-show="show">
	  <view :class="showAnim ? 'speed-info-box speed-info-box-show' : 'speed-info-box'">
	    <template v-for="(speedItem, speedIndex) in speedList">
	      <text :key="speedIndex" :class="curIndex === speedIndex ? 'speed-item-txt active':'speed-item-txt'" @click="speedItemClick(speedIndex)"> {{speedItem}} </text>
	    </template>
	    
	  </view>
	</view>
</template>

<script>
	export default {
		name: 'SpeedView',
		data (){
			return {
				show: false,
				showAnim: false,
			    speedList: [0.5, 1.0, 1.25, 1.5, 2.0],
			    curIndex: 1
			}
		},
		methods: {
		    setShow: function () {
		      this.show = true
		      setTimeout(() => {
		        this.showAnim = true
		      })
		    },
		    setHiden: function () {
		      this.showAnim = false
		      setTimeout(() => {
		        this.show = false
		      }, 300)
		    },
		    speedbgTap: function (e) {
		      this.setHiden()
		    },
		    speedItemClick: function (index){
			  this.curIndex = index
		      this.$emit('speedChange', this.speedList[this.curIndex])
			  this.setHiden()
		    }
		}
	}
</script>

<style scoped>
	.speed-info-box{
	  height: 100%;
	  width: 300rpx;
	  background: rgba(0, 0, 0, 0.5);
	  position: absolute;
	  right: -300px;
	  display: flex;
	  flex-direction: column;
	  justify-content: space-evenly;
	  align-items: center;
	  color: white;
	  font-size: 10pt;
	  transition: right 0.3s linear 0s;
	
	}
	
	.speed-wrap-box{
	  pointer-events: all;
	  width: 100%;
	  height: 100%;
	}
	
	.speed-item-txt{
	  color: #fff;
	  font-size: 10pt;
	  padding: 10rpx;
	}
	.active{
	  color: #12d2f6;
	}
	
	.speed-info-box-show{
	  right: 0px;
	}
</style>