简体   繁体   English

如何将nicescroll适合未渲染的元素

[英]How to fit nicescroll to unrendered element

I am using custom version of jQuery NiceScroll in the application I work on. 我正在使用的应用程序中使用jQuery NiceScroll的自定义版本。 The element which holds the scroll-bar has not finished rendering. 包含滚动条的元素尚未完成渲染。 Unfortunately the scroll-bar is not placed in the proper position when the element finishes its rendering. 不幸的是,当元素完成其渲染时,滚动条未放置在正确的位置。

My implementation: 我的实现:

(function (angular) {
    'use strict';

    function myScrollDirective() {
        function linkFunc(scope, element, attrs) {
            var config: any =
                {
                    horizrailenabled: attrs.enableHorizontalScroll ? true : false
                };

            element.niceScroll(config);
        }

        let directive =
            {
                link: linkFunc,
                restrict: 'A'
            };

        return directive;
    }

    angular
        .module('app')
        .directive('myScroll',
        [
            nvScrollDirective
        ]);

})(angular);

在此处输入图片说明

After scrolling a bit the scroll-bar gets to the proper position. 滚动一点后,滚动条将移到正确的位置。

在此处输入图片说明

How can I make the scroll-bar get to the proper position in the first place, after the element has finished rendering? 元素完成渲染后,如何首先使滚动条到达正确的位置?

Thanks in advance 提前致谢

you can try to style it to the position 您可以尝试将其样式设置为合适的位置

.scroll_class {
   position: fixed;
   top: 0;
   right: 0;
   bottom: 0;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM