用setData设scroll-top时,会触发bindscroll的事件,其中得到event.detail.scrollTop的值与设置的值不一致。
大部分情况是对的,偶尔会数值对不上。
<scroll-view bindscroll=“onscroll” scroll-x scroll-y style=“width:{{width}}px;height:{{height}}px;transform:rotate({{rotate}}deg);position:absolute;top:{{top}}px;left:{{left}}px” bindtouchstart=“touchstartCallback” bindtouchmove=“touchmoveCallback” bindtouchend=“touchendCallback” scroll-top="{{offsetY}}" scroll-left="{{offsetX}}">
touchendCallback: function (e) {
。。。。
// setTimeout(function(){
that.setData({
offsetX: ox,
offsetY: oy
});
// },1);
console.log({ox, oy}, h, that.imgh, that.data.toy);
。。。。
}
onscroll: function(e){
this.scrollY = e.detail.scrollTop;
this.scrollX = e.detail.scrollLeft;
console.log(‘onscroll:’, this.scrollY);
},
Object {ox: -44, oy: 520.9999999999999} 452.48038624019307 904.9607724803861 18.608541399914643
onscroll: 521
Object {ox: 165, oy: 1363} 904.9607724803861 452.48038624019307 18.608541399914643
onscroll: 1363
Object {ox: 495, oy: 3047} 1809.9215449607723 904.9607724803861 18.608541399914643
onscroll: 3047
Object {ox: 165, oy: 1362.9999999999998} 904.9607724803861 1809.9215449607723 18.608541399914643
onscroll: 3047 此值错误了!
Object {ox: 77.5, oy: 1362.9999999999998} 452.48038624019307 904.9607724803861 37.217082799829285
onscroll: 1363