调整大小时重启功能滚动

时间:2018-03-01 09:30:43

标签: javascript scroll vue.js resize

我试图在桌面上运行滚动功能。我执行计算以根据用户的屏幕尺寸在页面上定位块。

我向四面八方看,当我调整屏幕大小重启功能时,我看不出怎么做。

methods: {
  handleScroll: function() {
    let hW = $(window).height();
    let WW = $(window).width();

    let position = $(window).scrollTop();

    $(window).scroll(function() {
      let scroll = $(window).scrollTop();
      if (
          scroll > position
          &&  WW >= 768
      ){
       // thing...
        console.log('down');
      } else if(
          scroll < position
          && WW >= 768
       // thing...

      ){
       // thing...
        console.log('up')
      }
      position = scroll;
    });
  }
},
mounted () {
  this.handleScroll();
}

0 个答案:

没有答案