From 087b9f6cea5b4d2eb1c9fa3959ac0dc5b09cf254 Mon Sep 17 00:00:00 2001 From: skyouc Date: 星期五, 08 八月 2025 17:03:59 +0800 Subject: [PATCH] no message --- uni_modules/uni-swipe-action/components/uni-swipe-action-item/mpother.js | 514 ++++++++++++++++++++++++++++---------------------------- 1 files changed, 257 insertions(+), 257 deletions(-) diff --git a/uni_modules/uni-swipe-action/components/uni-swipe-action-item/mpother.js b/uni_modules/uni-swipe-action/components/uni-swipe-action-item/mpother.js index c44adfd..6d886e9 100644 --- a/uni_modules/uni-swipe-action/components/uni-swipe-action-item/mpother.js +++ b/uni_modules/uni-swipe-action/components/uni-swipe-action-item/mpother.js @@ -1,257 +1,257 @@ -let otherMixins = {} - -// #ifndef APP-PLUS|| MP-WEIXIN || H5 -const MIN_DISTANCE = 10; -otherMixins = { - data() { - // TODO 闅忔満鐢熺敓鍏冪礌ID锛岃В鍐崇櫨搴﹀皬绋嬪簭鑾峰彇鍚屼竴涓厓绱犱綅缃俊鎭殑bug - const elClass = `Uni_${Math.ceil(Math.random() * 10e5).toString(36)}` - return { - uniShow: false, - left: 0, - buttonShow: 'none', - ani: false, - moveLeft:'', - elClass - } - }, - watch: { - show(newVal) { - if (this.autoClose) return - this.openState(newVal) - }, - left(){ - this.moveLeft = `translateX(${this.left}px)` - }, - buttonShow(newVal){ - if (this.autoClose) return - this.openState(newVal) - }, - leftOptions() { - this.init() - }, - rightOptions() { - this.init() - } - }, - mounted() { - this.swipeaction = this.getSwipeAction() - if (this.swipeaction.children !== undefined) { - this.swipeaction.children.push(this) - } - this.init() - }, - methods: { - init(){ - clearTimeout(this.timer) - this.timer = setTimeout(() => { - this.getSelectorQuery() - }, 100) - // 绉诲姩璺濈 - this.left = 0 - this.x = 0 - }, - - closeSwipe(e) { - if (!this.autoClose) return - this.swipeaction.closeOther(this) - }, - appTouchStart(e) { - const { - clientX - } = e.changedTouches[0] - this.clientX = clientX - this.timestamp = new Date().getTime() - }, - appTouchEnd(e, index, item, position) { - const { - clientX - } = e.changedTouches[0] - // fixed by xxxx 妯℃嫙鐐瑰嚮浜嬩欢锛岃В鍐� ios 13 鐐瑰嚮鍖哄煙閿欎綅鐨勯棶棰� - let diff = Math.abs(this.clientX - clientX) - let time = (new Date().getTime()) - this.timestamp - if (diff < 40 && time < 300) { - this.$emit('click', { - content: item, - index, - position - }) - } - }, - touchstart(e) { - if (this.disabled) return - this.ani = false - this.x = this.left || 0 - this.stopTouchStart(e) - this.autoClose && this.closeSwipe() - }, - touchmove(e) { - if (this.disabled) return - // 鏄惁鍙互婊戝姩椤甸潰 - this.stopTouchMove(e); - if (this.direction !== 'horizontal') { - return; - } - this.move(this.x + this.deltaX) - return false - }, - touchend() { - if (this.disabled) return - this.moveDirection(this.left) - }, - /** - * 璁剧疆绉诲姩璺濈 - * @param {Object} value - */ - move(value) { - value = value || 0 - const leftWidth = this.leftWidth - const rightWidth = this.rightWidth - // 鑾峰彇鍙粦鍔ㄨ寖鍥� - this.left = this.range(value, -rightWidth, leftWidth); - }, - - /** - * 鑾峰彇鑼冨洿 - * @param {Object} num - * @param {Object} min - * @param {Object} max - */ - range(num, min, max) { - return Math.min(Math.max(num, min), max); - }, - /** - * 绉诲姩鏂瑰悜鍒ゆ柇 - * @param {Object} left - * @param {Object} value - */ - moveDirection(left) { - const threshold = this.threshold - const isopen = this.isopen || 'none' - const leftWidth = this.leftWidth - const rightWidth = this.rightWidth - if (this.deltaX === 0) { - this.openState('none') - return - } - if ((isopen === 'none' && rightWidth > 0 && -left > threshold) || (isopen !== 'none' && rightWidth > 0 && rightWidth + - left < threshold)) { - // right - this.openState('right') - } else if ((isopen === 'none' && leftWidth > 0 && left > threshold) || (isopen !== 'none' && leftWidth > 0 && - leftWidth - left < threshold)) { - // left - this.openState('left') - } else { - // default - this.openState('none') - } - }, - - /** - * 寮�鍚姸鎬� - * @param {Boolean} type - */ - openState(type) { - const leftWidth = this.leftWidth - const rightWidth = this.rightWidth - let left = '' - this.isopen = this.isopen ? this.isopen : 'none' - switch (type) { - case "left": - left = leftWidth - break - case "right": - left = -rightWidth - break - default: - left = 0 - } - - - if (this.isopen !== type) { - this.throttle = true - this.$emit('change', type) - } - - this.isopen = type - // 娣诲姞鍔ㄧ敾绫� - this.ani = true - this.$nextTick(() => { - this.move(left) - }) - // 璁剧疆鏈�缁堢Щ鍔ㄤ綅缃�,鐞嗚涓婂彧瑕佽繘鍏ュ埌杩欎釜鍑芥暟锛岃偗瀹氭槸瑕佹墦寮�鐨� - }, - close() { - this.openState('none') - }, - getDirection(x, y) { - if (x > y && x > MIN_DISTANCE) { - return 'horizontal'; - } - if (y > x && y > MIN_DISTANCE) { - return 'vertical'; - } - return ''; - }, - - /** - * 閲嶇疆婊戝姩鐘舵�� - * @param {Object} event - */ - resetTouchStatus() { - this.direction = ''; - this.deltaX = 0; - this.deltaY = 0; - this.offsetX = 0; - this.offsetY = 0; - }, - - /** - * 璁剧疆婊戝姩寮�濮嬩綅缃� - * @param {Object} event - */ - stopTouchStart(event) { - this.resetTouchStatus(); - const touch = event.touches[0]; - this.startX = touch.clientX; - this.startY = touch.clientY; - }, - - /** - * 婊戝姩涓紝鏄惁绂佹鎵撳紑 - * @param {Object} event - */ - stopTouchMove(event) { - const touch = event.touches[0]; - this.deltaX = touch.clientX - this.startX; - this.deltaY = touch.clientY - this.startY; - this.offsetX = Math.abs(this.deltaX); - this.offsetY = Math.abs(this.deltaY); - this.direction = this.direction || this.getDirection(this.offsetX, this.offsetY); - }, - - getSelectorQuery() { - const views = uni.createSelectorQuery().in(this) - views - .selectAll('.'+this.elClass) - .boundingClientRect(data => { - if(data.length === 0) return - let show = 'none' - if (this.autoClose) { - show = 'none' - } else { - show = this.show - } - this.leftWidth = data[0].width || 0 - this.rightWidth = data[1].width || 0 - this.buttonShow = show - }) - .exec() - } - } -} - -// #endif - -export default otherMixins +let otherMixins = {} + +// #ifndef APP-PLUS|| MP-WEIXIN || H5 +const MIN_DISTANCE = 10; +otherMixins = { + data() { + // TODO 闅忔満鐢熺敓鍏冪礌ID锛岃В鍐崇櫨搴﹀皬绋嬪簭鑾峰彇鍚屼竴涓厓绱犱綅缃俊鎭殑bug + const elClass = `Uni_${Math.ceil(Math.random() * 10e5).toString(36)}` + return { + uniShow: false, + left: 0, + buttonShow: 'none', + ani: false, + moveLeft:'', + elClass + } + }, + watch: { + show(newVal) { + if (this.autoClose) return + this.openState(newVal) + }, + left(){ + this.moveLeft = `translateX(${this.left}px)` + }, + buttonShow(newVal){ + if (this.autoClose) return + this.openState(newVal) + }, + leftOptions() { + this.init() + }, + rightOptions() { + this.init() + } + }, + mounted() { + this.swipeaction = this.getSwipeAction() + if (this.swipeaction.children !== undefined) { + this.swipeaction.children.push(this) + } + this.init() + }, + methods: { + init(){ + clearTimeout(this.timer) + this.timer = setTimeout(() => { + this.getSelectorQuery() + }, 100) + // 绉诲姩璺濈 + this.left = 0 + this.x = 0 + }, + + closeSwipe(e) { + if (!this.autoClose) return + this.swipeaction.closeOther(this) + }, + appTouchStart(e) { + const { + clientX + } = e.changedTouches[0] + this.clientX = clientX + this.timestamp = new Date().getTime() + }, + appTouchEnd(e, index, item, position) { + const { + clientX + } = e.changedTouches[0] + // fixed by xxxx 妯℃嫙鐐瑰嚮浜嬩欢锛岃В鍐� ios 13 鐐瑰嚮鍖哄煙閿欎綅鐨勯棶棰� + let diff = Math.abs(this.clientX - clientX) + let time = (new Date().getTime()) - this.timestamp + if (diff < 40 && time < 300) { + this.$emit('click', { + content: item, + index, + position + }) + } + }, + touchstart(e) { + if (this.disabled) return + this.ani = false + this.x = this.left || 0 + this.stopTouchStart(e) + this.autoClose && this.closeSwipe() + }, + touchmove(e) { + if (this.disabled) return + // 鏄惁鍙互婊戝姩椤甸潰 + this.stopTouchMove(e); + if (this.direction !== 'horizontal') { + return; + } + this.move(this.x + this.deltaX) + return false + }, + touchend() { + if (this.disabled) return + this.moveDirection(this.left) + }, + /** + * 璁剧疆绉诲姩璺濈 + * @param {Object} value + */ + move(value) { + value = value || 0 + const leftWidth = this.leftWidth + const rightWidth = this.rightWidth + // 鑾峰彇鍙粦鍔ㄨ寖鍥� + this.left = this.range(value, -rightWidth, leftWidth); + }, + + /** + * 鑾峰彇鑼冨洿 + * @param {Object} num + * @param {Object} min + * @param {Object} max + */ + range(num, min, max) { + return Math.min(Math.max(num, min), max); + }, + /** + * 绉诲姩鏂瑰悜鍒ゆ柇 + * @param {Object} left + * @param {Object} value + */ + moveDirection(left) { + const threshold = this.threshold + const isopen = this.isopen || 'none' + const leftWidth = this.leftWidth + const rightWidth = this.rightWidth + if (this.deltaX === 0) { + this.openState('none') + return + } + if ((isopen === 'none' && rightWidth > 0 && -left > threshold) || (isopen !== 'none' && rightWidth > 0 && rightWidth + + left < threshold)) { + // right + this.openState('right') + } else if ((isopen === 'none' && leftWidth > 0 && left > threshold) || (isopen !== 'none' && leftWidth > 0 && + leftWidth - left < threshold)) { + // left + this.openState('left') + } else { + // default + this.openState('none') + } + }, + + /** + * 寮�鍚姸鎬� + * @param {Boolean} type + */ + openState(type) { + const leftWidth = this.leftWidth + const rightWidth = this.rightWidth + let left = '' + this.isopen = this.isopen ? this.isopen : 'none' + switch (type) { + case "left": + left = leftWidth + break + case "right": + left = -rightWidth + break + default: + left = 0 + } + + + if (this.isopen !== type) { + this.throttle = true + this.$emit('change', type) + } + + this.isopen = type + // 娣诲姞鍔ㄧ敾绫� + this.ani = true + this.$nextTick(() => { + this.move(left) + }) + // 璁剧疆鏈�缁堢Щ鍔ㄤ綅缃�,鐞嗚涓婂彧瑕佽繘鍏ュ埌杩欎釜鍑芥暟锛岃偗瀹氭槸瑕佹墦寮�鐨� + }, + close() { + this.openState('none') + }, + getDirection(x, y) { + if (x > y && x > MIN_DISTANCE) { + return 'horizontal'; + } + if (y > x && y > MIN_DISTANCE) { + return 'vertical'; + } + return ''; + }, + + /** + * 閲嶇疆婊戝姩鐘舵�� + * @param {Object} event + */ + resetTouchStatus() { + this.direction = ''; + this.deltaX = 0; + this.deltaY = 0; + this.offsetX = 0; + this.offsetY = 0; + }, + + /** + * 璁剧疆婊戝姩寮�濮嬩綅缃� + * @param {Object} event + */ + stopTouchStart(event) { + this.resetTouchStatus(); + const touch = event.touches[0]; + this.startX = touch.clientX; + this.startY = touch.clientY; + }, + + /** + * 婊戝姩涓紝鏄惁绂佹鎵撳紑 + * @param {Object} event + */ + stopTouchMove(event) { + const touch = event.touches[0]; + this.deltaX = touch.clientX - this.startX; + this.deltaY = touch.clientY - this.startY; + this.offsetX = Math.abs(this.deltaX); + this.offsetY = Math.abs(this.deltaY); + this.direction = this.direction || this.getDirection(this.offsetX, this.offsetY); + }, + + getSelectorQuery() { + const views = uni.createSelectorQuery().in(this) + views + .selectAll('.'+this.elClass) + .boundingClientRect(data => { + if(data.length === 0) return + let show = 'none' + if (this.autoClose) { + show = 'none' + } else { + show = this.show + } + this.leftWidth = data[0].width || 0 + this.rightWidth = data[1].width || 0 + this.buttonShow = show + }) + .exec() + } + } +} + +// #endif + +export default otherMixins -- Gitblit v1.9.1