UNPKG

antd-mini

Version:

antd-mini 是支付宝小程序 UI 组件库,遵循 Ant Design 规范。

32 lines (31 loc) 1.43 kB
import { __assign } from "tslib"; // @ts-nocheck import { Component, getValueFromProps, triggerEventValues, } from '../_util/simply'; import { ConversationsProps } from './props'; var maxTouchMove = 10; Component(ConversationsProps, { onTouchStart: function (e) { // 这里需要通过 Touch 来实现点击效果,因为微信 movable-view 中的内容都不支持Tap var touch = e.touches[0]; this.touchStartX = touch.clientX; this.touchStartY = touch.clientY; }, onItemTap: function (e) { var touchEndX = e.changedTouches[0].clientX; var touchEndY = e.changedTouches[0].clientY; var deltaX = Math.abs(touchEndX - this.touchStartX); var deltaY = Math.abs(touchEndY - this.touchStartY); if (deltaX < maxTouchMove && deltaY < maxTouchMove) { var _a = e.currentTarget.dataset, item = _a.item, index = _a.index; triggerEventValues(this, 'itemTap', [item, index], e); } }, onButtonTap: function (menu, e) { var menus = getValueFromProps(this, 'menus'); var menuInfo, itemInfo; var _a = e.currentTarget.dataset, item = _a.item, index = _a.index; menuInfo = __assign(__assign({}, menus[menu.btnIdx]), { index: menu.btnIdx }); itemInfo = __assign(__assign({}, item), { index: index }); triggerEventValues(this, 'menuItemTap', [menuInfo, itemInfo], e); }, });