1. 程式人生 > >觸摸函數

觸摸函數

cti ons amp 距離 fse his IE 觸摸 end

bindtouchmove=‘moveFn‘ bindtouchstart=‘startFn‘ bindtouchend=‘endFn‘ startFn: function (e) { let bianChange = this.data.bianChange; let btmChange = this.data.btmChange; let slidChange = this.data.slidChange; // console.log(bianChange) // console.log(slidChange) // console.log(btmChange) let that = this; let startFn = this.data.startFn // console.log(e.touches[0].clientY); that.setData({ startFn: e.touches[0].clientY }) }, moveFn: function (e) { // let nnn=0; let that = this; let btmChe = this.data.btmChe; let btmChange = this.data.btmChange; let bianChe = this.data.bianChe; let bianChange = this.data.bianChange; let slidChe = this.data.slidChe; let slidChange = this.data.slidChange; // 第一點擊數據參數 let startFn = this.data.startFn;
let distance = e.touches[0].clientY; // 鼠標滑過的Y距離 let line = distance - startFn; let sureHave = this.data.sureHave; // console.log(btmChange); // console.log(line ); if (line > 0 && btmChe == 0) {
let che; let query = wx.createSelectorQuery() query.select(‘#sliderla‘).boundingClientRect() query.selectViewport().scrollOffset() query.exec(function (res) { che = res[0].top; // console.log(che) that.setData({ che: che }) if (che == 43 && sureHave) { if (sureHave) { // console.log(che ) that.setData({ sureHave: false, startFn: distance }) } } else { // console.log("****") // console.log(btmChange) // console.log(line) bianChange = -44 + line; slidChange = 44 + line; btmChange = line / 2; // console.log(btmChange) if (bianChange > 0) { bianChange = 0; slidChange = 79; btmChange = 18; } that.setData({ bianChange: bianChange, slidChange: slidChange, btmChange: btmChange, line: line }) } })

} else if (line < 0) { // console.log(bianChange ); // console.log(line); if (bianChange >= -18 && bianChange >= -9) { bianChange = btmChe + line slidChange = slidChe + line; btmChange = line / 2;; // console.log(bianChange) if (bianChange < -18) { bianChange = -79; slidChange = 79; btmChange = 0; } } that.setData({ bianChange: bianChange, slidChange: slidChange, btmChange: btmChange, line: line })
} // console.log(bianChange) // console.log(slidChange) // console.log(btmChange)

}, endFn: function (e) { // console.log(1) let that = this; let line = this.data.line; let bianChange = this.data.bianChange; let slidChange = this.data.slidChange; let btmChange = this.btmChange; if (line < 0) { if (bianChange < -5) { that.setData({ bianChange: -79, slidChange: 44, btmChange: 0, bianChe: -79, slidChe: 44, btmChe: 0, }) } else if (0 > bianChange >= -10) { that.setData({ bianChange: 0, slidChange: 79, btmChange: 18 }) } } else { if (bianChange == 160) { if (bianChange > -44) { that.setData({ bianChange: 0, slidChange: 79, btmChange: 18, bianChe: 0, slidChe: 79, btmChe: 18, sureHave: true, }) } else { that.setData({ bianChange: -79, slidChange: 44, btmChange: 0
})
}
}
}
},

觸摸函數