# src/scripts/CDP/UI/listview/ScrollerElement.js

## Maintainability

72.37

## Lines of code

110

## Difficulty

36.85

## Estimated Errors

0.79

## Function weight

### By Complexity

### By SLOC

var CDP; (function (CDP) { var UI; (function (UI) { var _Utils = CDP.UI._ListViewUtils; var TAG = "[CDP.UI.ScrollerElement] "; /** * @class ScrollerElement * @brief HTMLElement の Scroller クラス */ var ScrollerElement = /** @class */ (function () { function ScrollerElement(element, options) { this._$target = null; this._$scrollMap = null; this._listviewOptions = null; this._$target = $(element); this._listviewOptions = options; } //! Scroller の型を取得 ScrollerElement.prototype.getType = function () { return ScrollerElement.TYPE; }; //! position 取得 ScrollerElement.prototype.getPos = function () { return this._$target.scrollTop(); }; //! position の最大値を取得 ScrollerElement.prototype.getPosMax = function () { if (null == this._$scrollMap) { this._$scrollMap = this._$target.children().first(); } return _Utils.max(this._$scrollMap.height() - this._$target.height(), 0); }; //! イベント登録 ScrollerElement.prototype.on = function (type, func) { switch (type) { case "scroll": this._$target.on("scroll", func); break; case "scrollstop": this._$target.on("scrollstop", func); break; default: console.warn(TAG + "unsupported type: " + type); break; } }; //! イベント登録解除 ScrollerElement.prototype.off = function (type, func) { switch (type) { case "scroll": this._$target.off("scroll", func); break; case "scrollstop": this._$target.off("scrollstop", func); break; default: console.warn(TAG + "unsupported type: " + type); break; } }; //! スクロール位置を指定 ScrollerElement.prototype.scrollTo = function (pos, animate, time) { if (!this._listviewOptions.enableAnimation || !animate) { this._$target.scrollTop(pos); } else { if (null == time) { time = this._listviewOptions.animationDuration; } this._$target.animate({ scrollTop: pos }, time); } }; //! Scroller の状態更新 ScrollerElement.prototype.update = function () { // noop. }; //! Scroller の破棄 ScrollerElement.prototype.destroy = function () { this._$scrollMap = null; if (this._$target) { this._$target.off(); this._$target = null; } }; Object.defineProperty(ScrollerElement, "TYPE", { //! タイプ定義 get: function () { return "element-overflow"; }, enumerable: true, configurable: true }); //! factory 取得 ScrollerElement.getFactory = function () { var factory = function (element, options) { return new ScrollerElement(element, options); }; // set type signature. factory.type = ScrollerElement.TYPE; return factory; }; return ScrollerElement; }()); UI.ScrollerElement = ScrollerElement; })(UI = CDP.UI || (CDP.UI = {})); })(CDP || (CDP = {})); //# sourceMappingURL=data:application/json;base64,