Browse Source

grid优化

es6
guy 3 years ago
parent
commit
6d3f0a03ae
  1. 8
      src/base/collection/collection.js
  2. 8
      src/base/grid/grid.js

8
src/base/collection/collection.js

@ -279,14 +279,14 @@ BI.CollectionView = BI.inherit(BI.Widget, {
if (o.items.length > 0) { if (o.items.length > 0) {
this.container.setWidth(this._width); this.container.setWidth(this._width);
this.container.setHeight(this._height); this.container.setHeight(this._height);
this._debounceRelease();
// 元素未挂载时不能设置scrollTop // 元素未挂载时不能设置scrollTop
try { try {
this.element.scrollTop(o.scrollTop); this.element.scrollTop(o.scrollTop);
this.element.scrollLeft(o.scrollLeft); this.element.scrollLeft(o.scrollLeft);
} catch (e) { } catch (e) {
} }
this._debounceRelease();
this._calculateChildrenToRender(); this._calculateChildrenToRender();
} }
}, },
@ -298,8 +298,8 @@ BI.CollectionView = BI.inherit(BI.Widget, {
this._scrollLock = true; this._scrollLock = true;
this.options.scrollLeft = BI.clamp(scrollLeft || 0, 0, this._getMaxScrollLeft()); this.options.scrollLeft = BI.clamp(scrollLeft || 0, 0, this._getMaxScrollLeft());
this._debounceRelease(); this._debounceRelease();
this._calculateChildrenToRender();
this.element.scrollLeft(this.options.scrollLeft); this.element.scrollLeft(this.options.scrollLeft);
this._calculateChildrenToRender();
}, },
setScrollTop: function (scrollTop) { setScrollTop: function (scrollTop) {
@ -309,8 +309,8 @@ BI.CollectionView = BI.inherit(BI.Widget, {
this._scrollLock = true; this._scrollLock = true;
this.options.scrollTop = BI.clamp(scrollTop || 0, 0, this._getMaxScrollTop()); this.options.scrollTop = BI.clamp(scrollTop || 0, 0, this._getMaxScrollTop());
this._debounceRelease(); this._debounceRelease();
this._calculateChildrenToRender();
this.element.scrollTop(this.options.scrollTop); this.element.scrollTop(this.options.scrollTop);
this._calculateChildrenToRender();
}, },
setOverflowX: function (b) { setOverflowX: function (b) {

8
src/base/grid/grid.js

@ -262,14 +262,14 @@ BI.GridView = BI.inherit(BI.Widget, {
if (o.items.length > 0) { if (o.items.length > 0) {
this.container.setWidth(this._getContainerWidth()); this.container.setWidth(this._getContainerWidth());
this.container.setHeight(this._getContainerHeight()); this.container.setHeight(this._getContainerHeight());
// 元素未挂载时不能设置scrollTop // 元素未挂载时不能设置scrollTop
this._debounceRelease();
try { try {
this.element.scrollTop(o.scrollTop); this.element.scrollTop(o.scrollTop);
this.element.scrollLeft(o.scrollLeft); this.element.scrollLeft(o.scrollLeft);
} catch (e) { } catch (e) {
} }
this._debounceRelease();
this._calculateChildrenToRender(); this._calculateChildrenToRender();
} }
}, },
@ -281,8 +281,8 @@ BI.GridView = BI.inherit(BI.Widget, {
this._scrollLock = true; this._scrollLock = true;
this.options.scrollLeft = BI.clamp(scrollLeft || 0, 0, this._getMaxScrollLeft()); this.options.scrollLeft = BI.clamp(scrollLeft || 0, 0, this._getMaxScrollLeft());
this._debounceRelease(); this._debounceRelease();
this._calculateChildrenToRender();
this.element.scrollLeft(this.options.scrollLeft); this.element.scrollLeft(this.options.scrollLeft);
this._calculateChildrenToRender();
}, },
setScrollTop: function (scrollTop) { setScrollTop: function (scrollTop) {
@ -292,8 +292,8 @@ BI.GridView = BI.inherit(BI.Widget, {
this._scrollLock = true; this._scrollLock = true;
this.options.scrollTop = BI.clamp(scrollTop || 0, 0, this._getMaxScrollTop()); this.options.scrollTop = BI.clamp(scrollTop || 0, 0, this._getMaxScrollTop());
this._debounceRelease(); this._debounceRelease();
this._calculateChildrenToRender();
this.element.scrollTop(this.options.scrollTop); this.element.scrollTop(this.options.scrollTop);
this._calculateChildrenToRender();
}, },
setColumnCount: function (columnCount) { setColumnCount: function (columnCount) {

Loading…
Cancel
Save