[BUG] slideview show动态改变时有问题

Open
#167 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
55/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
typescript
Domain
frontend

Research direction

Start by locating the slideview implementation and compare the showChange and touchend handlers, especially how each passes duration to showButtons. Reproduce the issue by changing the show property dynamically, then verify that the resulting animation timing matches the touch interaction path.

Written by the indexing model from the issue text.

Description

Bug描述

动态改变slideview show属性 不能按预期弹出右侧按钮,过了很长时间会慢慢的出来
通过调试我发现是在动态设置show为true的时候
这段代码有问题
var showChange = function(newVal, oldVal, ownerInstance, ins) {
var st = ins.getState();
st.show = newVal
if (st.disable) return
if (st.show) {
showButtons(ins, ownerInstance, st.duration) //这里没有除1000导致时间错误,动画时间很长会慢慢的出来
} else {
innerHideButton(ownerInstance)
}
}
这段就没问题
var touchend = function(event, ownerInstance) {
var ins = event.instance
var st = ins.getState()
if (!st.size || !st.isMoving) return
// 左侧45度角为界限,大于45度则允许水平滑动
if (st.firstAngle < 0) {
return
}
var duration = st.duration / 1000 //这里除了1000就没问题
st.isMoving = false
// console.log('touchend', JSON.stringify(event))
var btns = ownerInstance.selectAllComponents('.btn')
var len = btns.length
var i = len - 1
// console.log('len size', len)
if (Math.abs(event.changedTouches[0].pageX - st.startX) < st.throttle || event.changedTouches[0].pageX - st.startX > 0) { // 方向也要控制
st.out = false
ins.setStyle({
'transform': 'translate3d(0px, 0, 0)',
'transition': 'transform ' + (duration) + 's'
})
for (;i >= 0; i--) {
btns[i].setStyle({
'transform': 'translate3d(0px, 0, 0)',
'transition': 'transform ' + (duration) + 's'
})
}
ownerInstance.callMethod('hide')
return
}
showButtons(ins, ownerInstance, duration)
ownerInstance.callMethod('show')
}

复现方式

直接使用都是这样

版本信息

useExtendedLib

Dominant language
TypeScript
Stars
2.4k
Forks
549
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from wechat-miniprogram/weui-miniprogram

All issues in wechat-miniprogram/weui-miniprogram

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.