25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

1 line
2.1 KiB

  1. {"ast":null,"code":"import { TrackDirection } from './direction';\nimport { setStyle } from '../utils/';\n\nvar ScrollbarThumb =\n/** @class */\nfunction () {\n function ScrollbarThumb(_direction, _minSize) {\n if (_minSize === void 0) {\n _minSize = 0;\n }\n\n this._direction = _direction;\n this._minSize = _minSize;\n /**\n * Thumb element\n */\n\n this.element = document.createElement('div');\n /**\n * Display size of the thumb\n * will always be greater than `scrollbar.options.thumbMinSize`\n */\n\n this.displaySize = 0;\n /**\n * Actual size of the thumb\n */\n\n this.realSize = 0;\n /**\n * Thumb offset to the top\n */\n\n this.offset = 0;\n this.element.className = \"scrollbar-thumb scrollbar-thumb-\" + _direction;\n }\n /**\n * Attach to track element\n *\n * @param trackEl Track element\n */\n\n\n ScrollbarThumb.prototype.attachTo = function (trackEl) {\n trackEl.appendChild(this.element);\n };\n\n ScrollbarThumb.prototype.update = function (scrollOffset, containerSize, pageSize) {\n // calculate thumb size\n // pageSize > containerSize -> scrollable\n this.realSize = Math.min(containerSize / pageSize, 1) * containerSize;\n this.displaySize = Math.max(this.realSize, this._minSize); // calculate thumb offset\n\n this.offset = scrollOffset / pageSize * (containerSize + (this.realSize - this.displaySize));\n setStyle(this.element, this._getStyle());\n };\n\n ScrollbarThumb.prototype._getStyle = function () {\n switch (this._direction) {\n case TrackDirection.X:\n return {\n width: this.displaySize + \"px\",\n '-transform': \"translate3d(\" + this.offset + \"px, 0, 0)\"\n };\n\n case TrackDirection.Y:\n return {\n height: this.displaySize + \"px\",\n '-transform': \"translate3d(0, \" + this.offset + \"px, 0)\"\n };\n\n default:\n return null;\n }\n };\n\n return ScrollbarThumb;\n}();\n\nexport { ScrollbarThumb };","map":null,"metadata":{},"sourceType":"module"}