teaset
teaset copied to clipboard
SegmentedBar autoScroll=true时 x位置计算存在问题
此函数计算 滚动条位置不正确,相见以下代码 updateIndicator() { if (!this._indicatorX || !this._indicatorWidth) return;
...
if (this.props.autoScroll && this.refs.scrollView) {
let contextWidth = 0;
this._buttonsLayout.map(item => contextWidth += item.width);
let x = indicatorXValue + indicatorWidthValue / 2 - this._scrollViewWidth / 2;
if (x < 0) {
x = 0;
} else if (x > contextWidth - this._scrollViewWidth) {
x = contextWidth - this._scrollViewWidth;
}
line 162:
/*
这里x会存下小于0的情形(contextWidth < this._scrollViewWidth)
在 x 小于0时,滚动条会将内容整体滚动到右侧,用户视觉体验较差。
增加下面的x的判断代码后,就可以正常了:)
/
/
if (x < 0) {
x = 0;
}
// console.log('\n>>>>>>this.refs.scrollView.scrollTo:\n'+JSON.stringify({contextWidth:contextWidth,scrollViewWidth:this._scrollViewWidth,x: x, y: 0, animated: this.props.animated}));
*/
this.refs.scrollView.scrollTo({x: x, y: 0, animated: this.props.animated});
}
}
if (x < 0) { x = 0; } 我看的源码这个已经存在,但晒ios 还是存在滚动调滚动到右侧问题
非常感谢,原来是再添加这一行,完美解决~ 非常感谢。。
:) 希望代码能更新一下,解决这个问题
:) 希望代码能更新一下,解决这个问题
你发一个代码合并不就好了,等作者合并
我们这边遇到的问题是. 数据加载后,x先在0的位置, 后又位移一定数值,
主要原因还是 componentDidUpdate不断调用
我这边粗暴处理了
SegmentedBar.js中添加
组件使用:
这是来自QQ邮箱的假期自动回复邮件。 您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。