Custom scroll angular directives이 있습니다. 나는 또한 당신이 그것의 특정한 목적에 맞게 조정할 수 있다고 생각한다.
한번만 사용하면 ng2-slimscroll이며 1 개의 지시어 만 포함되어 있습니다. 기능을 추가하고 동작을 원하는 버튼을 관리 할 수 있다고 생각합니다.
자바 스크립트의 일반적인 기능을 사용하여 스크롤 높이를 계산하는 것을 볼 수 있습니다. 다음은 barHeight를 계산하는 데 사용하는 함수의 샘플입니다. github 프로젝트 폴더에서 찾을 수 있습니다. ng2-slimscroll/src/directives/slimscroll.directive.ts
getBarHeight(): void {
setTimeout(() => {
let barHeight = Math.max((this.el.offsetHeight/this.el.scrollHeight) * this.el.offsetHeight, 30) + 'px';
let display = parseInt(barHeight, 10) === this.el.offsetHeight ? 'none' : 'block';
this.renderer.setElementStyle(this.bar, 'height', barHeight);
this.renderer.setElementStyle(this.bar, 'display', display);
this.renderer.setElementStyle(this.grid, 'display', display);
}, 1);
}
출처
2017-05-02 22:16:58
Sam