zoukankan      html  css  js  c++  java
  • 小程序自定义头部导航栏滑动颜色渐变

    直接粘贴复制就可使用

    index.wxml文件

     
    <view class='header' style="opacity:{{opacityStyle}};height:{{height}}px;z-index:100;"  hidden='{{hiddenModel}}'></view>
     
     
    index.wxss文件
     
    .header{
      position: fixed;
       100%;
      /* z-index: 10000; */
      top: 0;
      left: 0;
      background: #1CAE74;
      /* height: 180rpx; */
    }

    index.js文件

    Page({
      /**
       * 页面的初始数据
       */
      data: {

        height:0,
        hiddenModel:true,
        opacityStyle: 0,
        scrollTop: 0,
      },
     
    onLoad: function (options) {
        if(app.globalData.height < 44){
          this.setData({
            height:app.globalData.height * 2 + 20
          })
          this.setData({
            lineHieght:(app.globalData.height * 2)+44
          })
        }else{
          this.setData({
            height:app.globalData.height * 2
          })

          this.setData({
            lineHieght:(app.globalData.height * 2)+44
          })
        }
      },
     
    //监听头部滚动条
      onPageScroll: function (ev) {
        // console.log(ev,1111)
        var _this = this;
        if (ev.scrollTop > 50) {
          let opacity = ev.scrollTop / 120
          opacity = opacity > 1 ? 1 : opacity
          _this.setData({
            hiddenModel: false,
            opacityStyle: opacity
          })
        } else {
          _this.setData({
            hiddenModel: true
          })
        }
      },
  • 相关阅读:
    servlet遇到的问题
    servlel出现404问题★ 出现不自动映射 设置XML的问题时候
    c3p0的错误mchange.v2.ser.Indirector
    【转】JSON和JSONP
    性能测试理论
    如何解决包冲突问题
    一方包、二方包、三方包是什么?
    利用selenium webdriver点击alert提示框
    采用Spring管理Bean和依赖注入
    Java加载jar文件并调用jar文件当中有参数和返回值的方法
  • 原文地址:https://www.cnblogs.com/wswm/p/15396771.html
Copyright © 2011-2022 走看看