zoukankan      html  css  js  c++  java
  • 小程序导航栏跟随滑动

    效果图

    .wxml

    <view class='tabBar'>
    <view class='tabItem wx:if="{{tabClick===0?"click":""}}"' bindtap='clickTab' data-index='0'>tab1</view>
    <view class='tabItem wx:if="{{tabClick===1?"click":""}}"' bindtap='clickTab' data-index='1'>tab2 </view>
    <view class='tabItem wx:if="{{tabClick===2?"click":""}}"' bindtap='clickTab' data-index='2'>tab3 </view>
    <view class='underline' animation="{{animationData}}" style='left:{{isLeft}}'></view>
    </view>

    .wxss

    .tabBar{
    height: 80rpx;
    background-color:#50B7EA;
     100%;
    font-size: 28rpx;
    color: rgba(255,255,255,0.50);
    position: fixed;
    top: 0;
    left: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 997;
    }
    .tabItem{
     33.333%;
    display: flex;
    align-content: center;
    justify-content: center;
    position: relative;
    height: 100%;
    font-size: 28rpx;
    }
    .click{
    color: white;
    }
    .underline{
    position: absolute;
    content: '';
     84rpx;
    height: 3px;
    background-color:white;
    bottom: 0;
    }
    

      

    .js

    data:{
    tabClick: 0,
    animationData: {},
     isLeft: '12%'
    },
    
    swiperTab: function (e) {
    var that = this;
    var index = e.detail.current
    console.log(e.detail.current)
    var animation = wx.createAnimation({
    duration: 1000,
    timingFunction: "ease",
    })
    this.animation = animation
    if (index === 0) {
    animation.translate(0, 0).step();
    
    that.setData({
    animationData: animation.export()
    })
    that.setData({
    tabClick: e.detail.current
    });
    } else if (index === 1) {
    var w = wx.getSystemInfoSync().windowWidth;
    w = w * 0.32
    animation.translate(w, 0).step();
    that.setData({
    animationData: animation.export()
    })
    that.setData({
    tabClick: e.detail.current
    });
    } else if(index === 2){
    var w = wx.getSystemInfoSync().windowWidth;
    w = w * 0.65
    animation.translate(w, 0).step();
    that.setData({
    animationData: animation.export()
    })
    that.setData({
    tabClick: e.detail.current
    });
    }
    },
    

      

      

  • 相关阅读:
    IIS 6.0下安装SSL数字证书实现https访问
    使用SQL2005自带扩展函数对字符串进行MD5加密(转)
    Posix多线程编程学习笔记(三)—信号灯(1)--转自湖光倒影
    利用pthread_mutex对多进程上锁
    ObjectiveC中的锁
    Linux内存管理之mmap详解
    cocoa应用程序生命周期
    多线程编程互斥锁
    [New Book]Flex第一步 国内第一本关于Flex的书籍
    ASP.NET中实现二级或多级域名(修改UrlRewrite)
  • 原文地址:https://www.cnblogs.com/zwyboom/p/10819004.html
Copyright © 2011-2022 走看看