// components/page-scroll/page-scroll.js Component({ /** * 组件的属性列表 */ properties: { "className":{ value:"", type:String }, "styleSheet":{ value:"", type:String }, "upper-threshold":{ value:5, type:Number }, "scroll-into-view":{ value:"", type:String }, "bgcolor":{ value:"", type:String } }, /** * 组件的初始数据 */ data: { height:0, upper:true }, ready:function(){ }, methods: { scrollLower:function(e){ this.triggerEvent("scrolltolower",e.detail); }, scrollUpper:function(e){ this.triggerEvent("scrolltoupper",e.detail); }, scroll:function(e){ if(this.data.upper){ if(e.detail.scrollTop>this.data["upper-threshold"]){ this.setData({ upper:false, height:0 }) } }else{ if(e.detail.scrollTop<this.data["upper-threshold"]){ this.setData({ upper:true }) } } this.triggerEvent("scroll",{scrollTop:e.detail.scrollTop,isuper:this.data.upper}); }, changeHeight:function(e){ var _self=this; if(this.data.starttop){ this.setData({ height:(e.touches[0].pageY-this.data.starttop)/2 }) this.triggerEvent("topheight",this.data.height); }else{ this.setData({ starttop:e.touches[0].pageY }) } }, endChange:function(e){ var obj = { starttop:0 } if(this.data.height){ obj.height=0; } this.setData(obj); this.triggerEvent("topheight",this.data.height); } } })