【问题标题】:AngularJS v1 material md-subheader bounces badly when scrolling on mobile devicesAngularJS v1 材质 md-subheader 在移动设备上滚动时弹跳严重
【发布时间】:2017-07-20 09:37:47
【问题描述】:

各位程序员和天才们,大家好,

我正在使用 angularmaterial v1 演示的 md-subheader:

https://material.angularjs.org/latest/demo/subheader

我正在使用它在移动设备中构建一个页面,问题是子标题在它不应该移动时反弹得很厉害。这个问题已经在下面的链接中解决了(带有适当的演示),但我找不到任何解决方案。

https://github.com/angular/material/issues/5862

【问题讨论】:

    标签: javascript angularjs angular-material


    【解决方案1】:

    我遇到了同样的问题,在搜索了一段时间后,我不得不放弃md-subheader,而是在md-content 上方放置了一个div,当md-content 滚动时,它将充当固定标题。然后我有条件地对 div 应用了一个样式,如果有足够的内容可以滚动,它会在滚动条的宽度上碰撞,这样标题就会与内容对齐。

    我通过定义这种风格做到了这一点:

    .invisible-scrollbar {
        overflow-y: scroll;
        scrollbar-3dlight-color: white;
        scrollbar-arrow-color: white;
        scrollbar-base-color: white;
        scrollbar-darkshadow-color: white;
        scrollbar-face-color: white;
        scrollbar-highlight-color: white;
        scrollbar-shadow-color: white;
    }
    .invisible-scrollbar::-webkit-scrollbar {
        opacity: 0;
    }
    

    然后将其应用于标题 div:

    ng-class="{'invisible-scrollbar':vm.resultsCanScroll}"
    

    最后,我检查内容是否在控制器中有滚动条,这对于 md-virtual-repeat 来说有点棘手:

    // Wait until the next digest so the content is bound before checking the scroll height.
    $timeout(function () {
        var scroller = angular.element('#searchResultList .md-virtual-repeat-scroller');
        vm.resultsCanScroll = scroller[0].scrollHeight > scroller.height();
    });
    

    当然,如果您有多个 md-subheader 标签,这对您没有帮助,但这取决于您要做什么。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-08
      • 2016-08-22
      • 1970-01-01
      • 2019-03-14
      • 1970-01-01
      • 2017-05-23
      相关资源
      最近更新 更多