高仿闪电报销app查看图片效果的实现
生活随笔
收集整理的這篇文章主要介紹了
高仿闪电报销app查看图片效果的实现
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
2019獨角獸企業重金招聘Python工程師標準>>>
圖一為進入頁面時展示的狀態,圖二,圖三為向下拉content內容時圖片放大顯示
圖四位當content內容區域拉動到一定范圍時content內容去向下滑走,圖片完全的展示出來。
這里主要是通過jquery去實現的,其中加入了animation.css動畫。
主要思路:
核心代碼:
前端頁面:
其中分兩塊,contentDiv和imgDiv
Css部分:
Controller代碼部分:
var?top?=?"";//記錄拉動是上邊距離 var?backgroundSize?=?150;//背景大小 var?last?=?0.001; var?top?=?"130px"; //展示contentDiv $scope.disPlayContent?=?true; //圖片 var?img?=?document.createElement("img"); img.src?=?"img/keepAccounts/autoScan/test.png";//點擊圖片的方法 $scope.checkImg?=?function(){//展示圖片if($scope.disPlayContent){$(".contentDiv").addClass("fadeOutDownBig");$scope.disPlayContent?=false;//圖片展示$(".imgDiv").animate({height:img.height},"fast");$(".imgDiv").animate({backgroundSize:"100%"},"fast");top?=?"130px";}else{//$(".contentDiv").removeClass("fadeOutDownBig");$scope.disPlayContent?=?true;$(".imgDiv").animate({height:"18em"},"fast");$(".imgDiv").animate({backgroundSize:"150%"},"fast");top?=?"130px";} };$scope.touchEnd?=?function?()?{backgroundSize?=?150;//$(".contentDiv").css("top","130px");//var?nowTop?=?$(".contentDiv").css("top");手機上取不到這個距離,取值為autotop?=?top.substring(0,?top.length?-?2);//松開手時頂部距離console.log(top);if(top<235){$(".contentDiv").animate({top:"130px"},"fast");$(".imgDiv").animate({backgroundSize:"150%"},"fast");}else{$(".contentDiv").addClass("fadeOutDownBig");$scope.disPlayContent?=false;//圖片展示$(".imgDiv").animate({height:img.height},"fast");$(".imgDiv").animate({backgroundSize:"100%"},"fast");} };$scope.onTouch?=?function?($event)?{if(rootConfig){console.log("touch");}$(".imgDiv").css("backgroundSize","150%"); };$scope.onDrag?=?function?($event)?{var?el?=?$event.target,dy?=?$event.gesture.deltaY;//last手機上第一次也取不到這個值,取值為autoif(dy>last){backgroundSize++;}else?if(dy<last){backgroundSize--;}last?=?dy;el.style.top?=?dy?+?130?+?"px";top?=??el.style.top;$(".contentDiv").css("top",?el.style.top);$(".imgDiv").css('background-size',?backgroundSize?+?"%"); };注意這里的全局變量,因為手機端的差異,取css樣式top總是為auto,所以這是了全局變量,在onDrag上不斷的設置top變量。同理兩外兩個變量的值。
轉載于:https://my.oschina.net/Nealyang/blog/552955
總結
以上是生活随笔為你收集整理的高仿闪电报销app查看图片效果的实现的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: SitePoint播客#25:WordP
- 下一篇: 20201110提莫攻击