1、index.js
import React, { Component } from 'react'
import { ScrollView , View} from '@tarojs/components'
import Taro from '@tarojs/taro'
import './index.less'
export default class Index extends Component {
state = {
animation: '',
startX: 0, // 开始坐标
startY: 0,
}
componentDidMount() {
// 页面渲染完成
// 实例化一个动画
const animation = Taro.createAnimation({
duration: 400,
timingFunction: 'linear',
delay: 100,
transformOrigin: 'left top 0',
success: function (res) {
console.log(res)
},
})
this.setState({
animation: animation,
})
}
// 滑动开始
touchstart(e) {
this.setState({
startX: e.changedTouches[0].clientX,
startY: e.changedTouches[0].clientY,
})
}
// 滑动事件处理 _index当前索引
touchmove(e) {
const that = this
const startX = that.state.startX // 开始X坐标
const startY = t