From af930887f9972b7dd21c80599e697e44f5e5a579 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期三, 13 十一月 2024 14:05:04 +0800
Subject: [PATCH] 移除视频相关组件
---
miniprogram_npm/tdesign-miniprogram/indexes/indexes.js | 76 +++++++++++++++++++++-----------------
1 files changed, 42 insertions(+), 34 deletions(-)
diff --git a/miniprogram_npm/tdesign-miniprogram/indexes/indexes.js b/miniprogram_npm/tdesign-miniprogram/indexes/indexes.js
index 0e07ea5..dcb2edf 100644
--- a/miniprogram_npm/tdesign-miniprogram/indexes/indexes.js
+++ b/miniprogram_npm/tdesign-miniprogram/indexes/indexes.js
@@ -30,17 +30,15 @@
type: 'child',
},
};
- this.behaviors = [
- pageScrollMixin(function (event) {
- this.onScroll(event);
- }),
- ];
+ this.behaviors = [pageScrollMixin()];
this.timer = null;
this.groupTop = [];
this.sidebar = null;
+ this.currentTouchAnchor = null;
this.observers = {
indexList(v) {
this.setIndexList(v);
+ this.setHeight(this.data._height);
},
height(v) {
this.setHeight(v);
@@ -48,11 +46,13 @@
};
this.lifetimes = {
ready() {
- var _a;
+ this.timer = null;
+ this.groupTop = [];
+ this.sidebar = null;
if (this.data._height === 0) {
this.setHeight();
}
- if (((_a = this.data._indexList) === null || _a === void 0 ? void 0 : _a.length) === 0) {
+ if (this.data.indexList === null) {
this.setIndexList();
}
},
@@ -128,22 +128,21 @@
}
},
setAnchorByIndex(index) {
- if (this.preIndex != null && this.preIndex === index)
- return;
- const { _indexList } = this.data;
+ const { _indexList, stickyOffset } = this.data;
const activeAnchor = _indexList[index];
+ if (this.data.activeAnchor !== null && this.data.activeAnchor === activeAnchor)
+ return;
const target = this.groupTop.find((item) => item.anchor === activeAnchor);
if (target) {
+ this.currentTouchAnchor = activeAnchor;
+ const scrollTop = target.top - stickyOffset;
wx.pageScrollTo({
- scrollTop: target.top,
+ scrollTop,
duration: 0,
});
- }
- this.preIndex = index;
- this.toggleTips(true);
- this.triggerEvent('select', { index: activeAnchor });
- if (activeAnchor !== this.data.activeAnchor) {
- this.triggerEvent('change', { index: activeAnchor });
+ this.toggleTips(true);
+ this.triggerEvent('select', { index: activeAnchor });
+ this.setData({ activeAnchor });
}
},
onClick(e) {
@@ -178,37 +177,46 @@
if (!this.groupTop) {
return;
}
- const { sticky, stickyOffset } = this.data;
+ const { sticky, stickyOffset, activeAnchor } = this.data;
scrollTop += stickyOffset;
const curIndex = this.groupTop.findIndex((group) => scrollTop >= group.top - group.height && scrollTop <= group.top + group.totalHeight - group.height);
if (curIndex === -1)
return;
const curGroup = this.groupTop[curIndex];
- if (this.data.activeAnchor !== curGroup.anchor) {
+ if (this.currentTouchAnchor !== null) {
this.triggerEvent('change', { index: curGroup.anchor });
+ this.currentTouchAnchor = null;
}
- this.setData({
- activeAnchor: curGroup.anchor,
- });
+ else if (activeAnchor !== curGroup.anchor) {
+ this.triggerEvent('change', { index: curGroup.anchor });
+ this.setData({ activeAnchor: curGroup.anchor });
+ }
if (sticky) {
const offset = curGroup.top - scrollTop;
const betwixt = offset < curGroup.height && offset > 0 && scrollTop > stickyOffset;
this.$children.forEach((child, index) => {
if (index === curIndex) {
- child.setData({
- sticky: scrollTop > stickyOffset,
- active: true,
- style: `height: ${curGroup.height}px`,
- anchorStyle: `transform: translate3d(0, ${betwixt ? offset : 0}px, 0); top: ${stickyOffset}px`,
- });
+ const sticky = scrollTop > stickyOffset;
+ const anchorStyle = `transform: translate3d(0, ${betwixt ? offset : 0}px, 0); top: ${stickyOffset}px`;
+ if (anchorStyle !== child.data.anchorStyle || sticky !== child.data.sticky) {
+ child.setData({
+ sticky,
+ active: true,
+ style: `height: ${curGroup.height}px`,
+ anchorStyle,
+ });
+ }
}
else if (index + 1 === curIndex) {
- child.setData({
- sticky: true,
- active: true,
- style: `height: ${curGroup.height}px`,
- anchorStyle: `transform: translate3d(0, ${betwixt ? offset - curGroup.height : 0}px, 0); top: ${stickyOffset}px`,
- });
+ const anchorStyle = `transform: translate3d(0, ${betwixt ? offset - curGroup.height : 0}px, 0); top: ${stickyOffset}px`;
+ if (anchorStyle !== child.data.anchorStyle) {
+ child.setData({
+ sticky: true,
+ active: true,
+ style: `height: ${curGroup.height}px`,
+ anchorStyle,
+ });
+ }
}
else {
child.setData({ active: false, sticky: false, anchorStyle: '' });
--
Gitblit v1.9.3