【问题标题】:AngularJS v1 material md-subheader bounces badly when scrolling on mobile devicesAngularJS v1 材质 md-subheader 在移动设备上滚动时弹跳严重
【发布时间】:2017-07-20 09:37:47
【问题描述】:
【问题讨论】:
标签:
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 标签,这对您没有帮助,但这取决于您要做什么。