feat(Rate): improve touchmove gesture (#2088)

This commit is contained in:
ShuaiKang Zhang 2019-09-24 13:11:12 +08:00 committed by neverland
parent f3c063ae0d
commit 89bcab7b09

View File

@ -91,19 +91,13 @@ VantComponent({
const { touchable } = this.data; const { touchable } = this.data;
if (!touchable) return; if (!touchable) return;
const { clientX, clientY } = event.touches[0]; const { clientX } = event.touches[0];
this.getRect('.van-rate__icon', true).then( this.getRect('.van-rate__icon', true).then(
(list: WechatMiniprogram.BoundingClientRectCallbackResult[]) => { (list: WechatMiniprogram.BoundingClientRectCallbackResult[]) => {
const target = list const target = list
.sort(item => item.right - item.left) .sort(item => item.right - item.left)
.find( .find(item => clientX >= item.left && clientX <= item.right);
item =>
clientX >= item.left &&
clientX <= item.right &&
clientY >= item.top &&
clientY <= item.bottom
);
if (target != null) { if (target != null) {
this.onSelect({ this.onSelect({
...event, ...event,