From 3f8202499a966ffd3988fbe65f94071d10d411a6 Mon Sep 17 00:00:00 2001 From: guy Date: Fri, 28 Oct 2022 13:59:57 +0800 Subject: [PATCH] =?UTF-8?q?KERNEL-13158:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/base/collection/collection.js | 36 +++++++++++++++++++++++++++-- src/base/grid/grid.js | 38 ++++++++++++++++++++++++++++--- 2 files changed, 69 insertions(+), 5 deletions(-) diff --git a/src/base/collection/collection.js b/src/base/collection/collection.js index d7f83a0f5..8d26825d5 100644 --- a/src/base/collection/collection.js +++ b/src/base/collection/collection.js @@ -280,12 +280,44 @@ BI.CollectionView = BI.inherit(BI.Widget, { } }, + _isOverflowX: function () { + var o = this.options; + // 兼容一下 + var scrollable = o.scrollable, scrollx = o.scrollx; + if (o.overflowX === false) { + return false; + } + if (scrollx) { + return true; + } + if (scrollable === true || scrollable === "x") { + return true; + } + return false; + }, + + _isOverflowY: function () { + var o = this.options; + // 兼容一下 + var scrollable = o.scrollable, scrolly = o.scrolly; + if (o.overflowX === false) { + return false; + } + if (scrolly) { + return true; + } + if (scrollable === true || scrollable === "x") { + return true; + } + return false; + }, + _getMaxScrollLeft: function () { - return Math.max(0, this._width - this.options.width + (this.options.overflowX ? BI.DOM.getScrollWidth() : 0)); + return Math.max(0, this._width - this.options.width + (this._isOverflowX() ? BI.DOM.getScrollWidth() : 0)); }, _getMaxScrollTop: function () { - return Math.max(0, this._height - this.options.height + (this.options.overflowY ? BI.DOM.getScrollWidth() : 0)); + return Math.max(0, this._height - this.options.height + (this._isOverflowY() ? BI.DOM.getScrollWidth() : 0)); }, _populate: function (items) { diff --git a/src/base/grid/grid.js b/src/base/grid/grid.js index d1385e4a1..f37201f73 100644 --- a/src/base/grid/grid.js +++ b/src/base/grid/grid.js @@ -96,7 +96,7 @@ BI.GridView = BI.inherit(BI.Widget, { this.element.scrollLeft(o.scrollLeft); } }, - + destroyed: function () { BI.each(this.renderedCells, function(i, cell) { cell.el._destroy(); @@ -262,12 +262,44 @@ BI.GridView = BI.inherit(BI.Widget, { } }, + _isOverflowX: function () { + var o = this.options; + // 兼容一下 + var scrollable = o.scrollable, scrollx = o.scrollx; + if (o.overflowX === false) { + return false; + } + if (scrollx) { + return true; + } + if (scrollable === true || scrollable === "x") { + return true; + } + return false; + }, + + _isOverflowY: function () { + var o = this.options; + // 兼容一下 + var scrollable = o.scrollable, scrolly = o.scrolly; + if (o.overflowX === false) { + return false; + } + if (scrolly) { + return true; + } + if (scrollable === true || scrollable === "x") { + return true; + } + return false; + }, + _getMaxScrollLeft: function () { - return Math.max(0, this._getContainerWidth() - this.options.width + (this.options.overflowX ? BI.DOM.getScrollWidth() : 0)); + return Math.max(0, this._getContainerWidth() - this.options.width + (this._isOverflowX() ? BI.DOM.getScrollWidth() : 0)); }, _getMaxScrollTop: function () { - return Math.max(0, this._getContainerHeight() - this.options.height + (this.options.overflowY ? BI.DOM.getScrollWidth() : 0)); + return Math.max(0, this._getContainerHeight() - this.options.height + (this._isOverflowY() ? BI.DOM.getScrollWidth() : 0)); }, _getContainerWidth: function () {