最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

微信小程序頁面上下滾動效果

 更新時間:2020年11月18日 09:24:14   作者:a_靖  
這篇文章主要為大家詳細介紹了微信小程序頁面上下滾動效果,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了微信小程序頁面上下滾動的具體代碼,供大家參考,具體內容如下

看圖

源碼

<view class="container container-fill">
 <view class="scroll-fullpage" bindtouchstart="scrollTouchstart" bindtouchmove="scrollTouchmove" bindtouchend="scrollTouchend" style="transform:translateY(-{{scrollindex*100}}%);margin-top: {{margintop}}px">
 <view class="section section01 {{scrollindex==0?'active':''}}" style="background: #3399FF;">
 <text class="section-maintitle">頁面1</text>
 <text class="section-subtitle">我的頁面”1</text>
 </view>
 <view class="section section02 {{scrollindex==1?'active':''}}" style="background: #00CC66;">
 <text class="section-maintitle">頁面2</text>
 <text class="section-subtitle">我的頁面”2</text>
 </view>
 <view class="section section03 {{scrollindex==2?'active':''}}" style="background: #33CCCC;">
 <text class="section-maintitle">頁面3</text>
 <text class="section-subtitle">我的頁面”3</text>
 </view>
 <view class="section section04 {{scrollindex==3?'active':''}}" style="background: #6699FF;">
 <text class="section-maintitle">頁面4</text>
 <text class="section-subtitle">我的頁面”4</text>
 </view>
 <view class="section section05 {{scrollindex==4?'active':''}}" style="background: #9966FF;">
 <text class="section-maintitle">無縫對接雙創(chuàng)服5</text>
 <text class="section-subtitle">我的頁面”5</text>
 </view>
 </view>
</view>

js

Page({
 data: {
 scrollindex:0, //當前頁面的索引值
 totalnum:5, //總共頁面數
 starty:0, //開始的位置x
 endy:0, //結束的位置y
 critical: 100, //觸發(fā)翻頁的臨界值
 margintop:0, //滑動下拉距離
 },
 onLoad: function () {
 },
 scrollTouchstart:function(e){
 let py = e.touches[0].pageY;
 this.setData({
 starty: py
 })
 },
 scrollTouchmove:function(e){
 let py = e.touches[0].pageY;
 let d = this.data;
 this.setData({
 endy: py,
 })
 if(py-d.starty<100 && py-d.starty>-100){ 
 this.setData({
 margintop: py - d.starty
 })
 }
 },
 scrollTouchend:function(e){
 let d = this.data;
 if(d.endy-d.starty >100 && d.scrollindex>0){
 this.setData({
 scrollindex: d.scrollindex-1
 })
 }else if(d.endy-d.starty <-100 && d.scrollindex<this.data.totalnum-1){
 this.setData({
 scrollindex: d.scrollindex+1
 })
 }
 this.setData({
 starty:0,
 endy:0,
 margintop:0
 })
 },
})

css

.container-fill{
 height: 100%;
 overflow: hidden;
}
.scroll-fullpage{
 height: 100%;
 transition: all 0.3s;
}
.section{
 height: 100%;
}
.section-maintitle{
 display: block;
 text-align: center;
 font-size: 50rpx;
 color: #fff;
 font-weight: bold;
 letter-spacing: 10rpx;
 padding-top: 140rpx;
}
.section-subtitle{
 display: block;
 text-align: center;
 font-size: 40rpx;
 color: #fff;
 font-weight: bold;
 letter-spacing: 10rpx;
}
.active .section-maintitle,
.active .section-subtitle{
 animation: mymove 0.8s;
}
@keyframes mymove{
 from {
 transform: translateY(-400rpx) scale(0.5) rotateY(90deg);
 }
 to {
 transform: translateY(0) scale(1) rotateY(0);
 }
}

為大家推薦現(xiàn)在關注度比較高的微信小程序教程一篇:《微信小程序開發(fā)教程》小編為大家精心整理的,希望喜歡。

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關文章

最新評論

思南县| 玛多县| 平乐县| 涟源市| 吉木萨尔县| 乳源| 商河县| 永胜县| 大名县| 林甸县| 洞头县| 肃宁县| 巴里| 广河县| 邯郸市| 文山县| 湖南省| 邵东县| 定兴县| 施甸县| 衡南县| 元氏县| 铜梁县| 孝义市| 南溪县| 鸡西市| 屯昌县| 承德县| 花垣县| 新安县| 青铜峡市| 江永县| 城市| 砀山县| 宣恩县| 板桥市| 阳泉市| 光山县| 林周县| 富蕴县| 本溪|