zoukankan      html  css  js  c++  java
  • 滚动监听

    //滚动监听
    $(window).scroll(function(event){
    var wScrollY = window.scrollY; // 当前滚动条位置
    //console.log("wScrollY:"+wScrollY);
    //var wInnerH = window.innerHeight; // 设备窗口的高度(不会变)
    //console.log("wInnerH:"+wInnerH);
    //var bScrollH = document.body.scrollHeight; // 滚动条总高度
    //console.log("bScrollH:"+bScrollH);
    /**
    *$(document).height():文档的高度
    *$(window).height():可视域的高度:窗口的大小:根据浏览窗口的大小变化
    *判断底部:文档高度<=滚动条垂直高度+可视窗口的高度
    * */
    //if ($(document).scrollTop() >= $(document).height() - $(window).height()) {
    // console.log("滚动条已经到达底部为" + $(document).scrollTop());
    //}
    //$(document).scrollTop() 获取垂直滚动的距离:最小值为0,最大值:文档高度-可视化窗口高度
    //$(document).scrollLeft() 这是获取水平滚动条的距离
    if (wScrollY>0) {
    $(".up").css("display","block");
    if(winWidth<700){
    console.log("wScrollY:"+wScrollY);
    $(".content .crumb-bar").css({"top":"0px"});
    }
     
    }
    else{
    $(".up").css("display","none");
    if(winWidth<700){
    $(".content .crumb-bar").css({"top":"50px"}); }
     
     
    }
     
    });
     
    //点击向上箭头滚动条向上滚动
    $(".up").click(function(){
    //scroll(0,0);
    //var t = $(window).scrollTop();
    $('body,html').animate({'scrollTop':0},300);
    });
  • 相关阅读:
    Charles:rewrite重写功能
    Vue中provide和inject 用法
    vue中install方法
    vue自定义组件(通过Vue.use()来使用)即install的使用
    Eelectron 中的remote模块
    理解Vue中的Render渲染函数
    Vue.js中this.$nextTick()的使用
    postman请求本地接口Error: connect ECONNREFUSED 127.0.0.1:8083
    1016 Phone Bills (25 分)
    CF842E Nikita and game
  • 原文地址:https://www.cnblogs.com/BlingSun/p/7484196.html
Copyright © 2011-2022 走看看