国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 熱點(diǎn) > 微信 > 正文

微信小程序scroll-view組件實(shí)現(xiàn)滾動(dòng)動(dòng)畫

2024-07-22 01:17:14
字體:
供稿:網(wǎng)友

本文實(shí)例為大家分享了scroll-view組件實(shí)現(xiàn)索引列表滾動(dòng)動(dòng)畫效果,供大家參考,具體內(nèi)容如下

效果圖

實(shí)現(xiàn)原理

利用scroll-view的scroll-into-view屬性進(jìn)行定位;
利用scroll-view的scroll-with-animation屬性實(shí)現(xiàn)滾動(dòng)動(dòng)畫過度。

WXML

<view class="right-nav">  <view bindtap="getCurrentCode" class="{{chooseIndex == index ? '.city-list-active' : ''}}" wx:for="{{cityList}}" style="height:{{codeHeight}}px" data-code="{{item.code}}" data-index="{{index}}">  {{item.code}}  </view></view><view class="city-layer {{isShowLayer ? '' : 'layer-hide'}}"> {{codeY}}</view><view class="current-choose-city">當(dāng)前選擇機(jī)場:{{chooseCity}}</view><scroll-view class="city-scroll" scroll-y="true" scroll-into-view="{{codeY}}" scroll-with-animation="true" style="height:{{cityHeight}}px" bindscroll="scroll">  <view class="city-box" wx:for="{{cityList}}" wx:key="{{item.code}}">    <view class="city-code" id="{{item.code}}">{{item.code}}</view>    <view class="city-list" wx:for="{{item.cityList}}" wx:for-item="city" bindtap="getChooseCity" data-city="{{city}}">        {{city}}     </view>   </view></scroll-view>

WXSS

.current-choose-city{ position: fixed; width: 100%; height: 50px; line-height: 50px; padding: 0 10px; top: 0; left: 0; background-color: #fff; z-index: 10;}.right-nav{ width: 30px; color: #888; text-align: center; position: fixed; bottom: 0; right: 0; background-color: rgb(200, 200, 200); z-index: 9;}.city-scroll{padding-top: 50px;}.city-code{ background-color: #f7f7f7;}.city-list,.city-code{ height: 39px; line-height: 40px; padding: 0 30px 0 10px; overflow: hidden; border-bottom: 1px solid #c8c7cc;}.city-list-active{color:#007aff;}/*提示點(diǎn)擊的字母 */.city-layer{ width: 70px; height: 70px; line-height: 70px; text-align: center; border-radius: 50%; color: #fff; background-color: rgba(0, 0, 0, .7); position: fixed; top: calc(50% - 35px); left:calc(50% - 35px); z-index: 11;}.layer-hide{display: none;}

JS

var city_list = require('./city.js');Page({ data: {  cityList: city_list.city,  chooseCity: '您還未選擇機(jī)場!',  isShowLayer: false,  chooseIndex: 0,  codeY: 'A',  codeHeight: null,  cityHeight:null }, onLoad (options) {  var windowHeight = wx.getSystemInfoSync().windowHeight;  this.setData({    codeHeight: (windowHeight - 50) / this.data.cityList.length,   cityHeight: windowHeight - 50,  }); }, getCurrentCode(e){  var self = this;  this.setData({    codeY: e.target.dataset.code,   chooseIndex: e.target.dataset.index,   isShowLayer: true   })  setTimeout(() => {   self.setData({ isShowLayer: false })  },500); }, getChooseCity(e){  this.setData({ chooseCity: e.target.dataset.city }); }})            
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 子长县| 会宁县| 甘南县| 农安县| 濮阳县| 太湖县| 绍兴市| 资中县| 平邑县| 黑龙江省| 昌黎县| 武夷山市| 新竹县| 凤台县| 依兰县| 清徐县| 运城市| 嵩明县| 资中县| 额尔古纳市| 介休市| 拉萨市| 栾城县| 安岳县| 乌海市| 新丰县| 聂荣县| 林周县| 宜阳县| 荥经县| 义马市| 天等县| 观塘区| 高阳县| 元谋县| 扶沟县| 平原县| 临朐县| 漯河市| 丹东市| 唐山市|