网友真实露脸自拍10p,成人国产精品秘?久久久按摩,国产精品久久久久久无码不卡,成人免费区一区二区三区

小程序模板網

微信小程序 - IOS 仿餓了么"我的",下拉橡皮筋效果

發布時間:2018-04-25 11:04 所屬欄目:小程序開發教程

這個需求是在wepy交流群里有群友提到的. 一個小花樣.

注冊mixins

 

				
  1. /**
  2. * IOS專用 頂部下拉橡皮筋效果
  3. * 安卓的Page在到達頂部的時候,不能繼續下拉...略過
  4. *
  5. * 效果見 餓了么送餐服務 "我的" 頁面 IOS環境 上下拖動
  6. *
  7. * 下拉時, 頂部色塊拉伸,上劃時,頂部色塊收縮.
  8. * wxml :
  9.  
  10. <view style='background-color: #0000ff;min-height:50vh;z-index:-1;height:{{elastic_topHeight||50}}px;width:100%;position:fixed;top:{{elastic_top}}px;'></view>
  11. *
  12. */
  13. var obj = {
  14.  
  15. onLoad(){
  16. /**獲取當前是何種平臺 */
  17. var SystemInfo = getApp().globalData.SystemInfo||{};
  18. this.__IS_IOS = SystemInfo.system && SystemInfo.system.toLowerCase().indexOf("ios")>=0;
  19. },
  20.  
  21. onPageScroll(e) {
  22. //非ios 略過效果
  23. if (!this.__IS_IOS)return;
  24. // console.log(e)
  25. var top = e.scrollTop;
  26. if (top > 0) { //上劃時, 整個view上移 , 避免因為持續上劃,看到 后面的view
  27. this.setData({
  28. elastic_top: -top
  29. });
  30. return;
  31. }
  32. this.setData({ //動態設置 高度
  33. elastic_topHeight: Math.abs(top * 2)+50
  34. });
  35. }
  36.  
  37.  
  38. };
  39. module.exports= obj;

wxml很簡單.在你的最外層增加

 

				
  1. <view style='background-color: #0000ff;min-height:50vh;z-index:-1;height:{{elastic_topHeight||50}}px;width:100%;position:fixed;top:{{elastic_top}}px;'></view>

style中顏色自定義,其他根據需要來

注意,他上拉的時候,背景色還是白色,和頂部顏色并不一樣.

這種方式實現,要求你的 頂級view要有一個背景色,否則這個橡皮筋效果就會暴露出來



易優小程序(企業版)+靈活api+前后代碼開源 碼云倉庫:starfork
本文地址:http://www.xiuhaier.com/wxmini/doc/course/24068.html 復制鏈接 如需定制請聯系易優客服咨詢:800182392 點擊咨詢
QQ在線咨詢
AI智能客服 ×