|
|
|
@ -333,30 +333,28 @@ export default {
|
|
|
|
|
|
|
|
|
|
|
|
// 触摸移动事件
|
|
|
|
// 触摸移动事件
|
|
|
|
onTouchMove(e) {
|
|
|
|
onTouchMove(e) {
|
|
|
|
if (!this.isTouching) return;
|
|
|
|
if (!this.isTouching) return;
|
|
|
|
|
|
|
|
|
|
|
|
if (e.touches && e.touches.length > 0) {
|
|
|
|
if (e.touches && e.touches.length > 0) {
|
|
|
|
this.moveY = e.touches[0].pageY;
|
|
|
|
this.moveY = e.touches[0].pageY;
|
|
|
|
const moveDistance = this.moveY - this.startY;
|
|
|
|
const moveDistance = this.moveY - this.startY;
|
|
|
|
|
|
|
|
|
|
|
|
// 只有向下移动(moveDistance > 0)时才触发下拉效果
|
|
|
|
// 只有向下移动(moveDistance > 0)且移动距离合理时才触发下拉效果
|
|
|
|
if (moveDistance > 0) {
|
|
|
|
if (moveDistance > 0 && moveDistance < 200) { // 限制最大下拉距离
|
|
|
|
const query = uni.createSelectorQuery().in(this);
|
|
|
|
const query = uni.createSelectorQuery().in(this);
|
|
|
|
query.select('.scroll-container').boundingClientRect(data => {
|
|
|
|
query.select('.scroll-container').boundingClientRect(data => {
|
|
|
|
if (data) {
|
|
|
|
if (data) {
|
|
|
|
const scrollTop = data.scrollTop || 0;
|
|
|
|
const scrollTop = data.scrollTop || 0;
|
|
|
|
// 只有在滚动到顶部且向下拉动时才执行缩放
|
|
|
|
// 只有在滚动到顶部且向下拉动时才执行缩放
|
|
|
|
if (scrollTop <= 0) {
|
|
|
|
if (scrollTop <= 0) {
|
|
|
|
// 根据移动距离计算缩放值,使效果更自然
|
|
|
|
// 根据移动距离计算缩放值,使效果更自然
|
|
|
|
// 可以调整 divisor(这里是80)来改变缩放的灵敏度
|
|
|
|
this.backgroundScale = Math.min(moveDistance * 0.05, 10); // 限制最大缩放值
|
|
|
|
const scaleValue = Math.min(moveDistance / 40, 1); // 限制最大缩放值
|
|
|
|
this.mtScroll = Math.min(moveDistance * 0.05, 10);
|
|
|
|
this.backgroundScale = scaleValue;
|
|
|
|
}
|
|
|
|
this.mtScroll = scaleValue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}).exec();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}).exec();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
// 触摸结束事件
|
|
|
|
// 触摸结束事件
|
|
|
|
|