1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- const scrollevents = {
- sourceUp:function(e){
- var obj = {
- scrolltop:0,
- distance:0,
- startdot:""
- }
- this.setData({
- scrollsource:Object.assign(this.data.scrollsource,obj)
- })
- },
- sourceScroll:function(e){
- var scrolltop = e.detail.scrollTop;
- var obj = {scrolltop:scrolltop};
- if(scrolltop&&this.data.scrollsource.startdot){
- obj.startdot = "";
- obj.distance = 0;
- obj.scrolltop = 0
- this.setData({
- scrollsource:Object.assign(this.data.scrollsource,obj)
- })
- }else{
- this.setData({
- scrollsource:Object.assign(this.data.scrollsource,{
- scrolltop:scrolltop
- })
- })
- }
- },
- sourceMove:function(e){
- var source = this.data.scrollsource
- if(e.timeStamp-source.timeStamp>200){
- if(source.startdot){
- var startdot = source.startdot;
- var enddot = e.changedTouches[0];
- var distance = enddot.pageY-startdot.pageY;
- this.setData({
- scrollsource:Object.assign(source,{distance:distance})
- })
- }else if(!source.scrolltop){
- var startdot = e.changedTouches[0];
- this.setData({
- scrollsource:Object.assign(source,{
- startdot:startdot,
- timeStamp:e.timeStamp
- }),
- })
- }
- }
- //console.log("consoleMove",e)
- },
- sourceStart:function(e){
- //console.log("sourceStart",e)
- var startdot = e.changedTouches[0];
- this.setData({
- scrollsource:Object.assign(this.data.scrollsource,{
- startdot:startdot,
- timeStamp:e.timeStamp
- })
- });
- },
- sourceEnd:function(e){
- this.setData({
- scrollsource:Object.assign(this.data.scrollsource,{
- distance:0,
- startdot:""
- })
- })
- //console.log("consoleEnd",e)
- }
- }
- export default function(item){
- item.setData({
- scrollsource:{
- scrolltop:0
- }
- })
- Object.assign(item,scrollevents);
- }
|