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

## Maintainability

72.90

## Lines of code

107

## Difficulty

33.16

## Estimated Errors

0.75

## Function weight

### By Complexity

### By SLOC

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