Browse Source

KERNEL-13841 refactor:base文件es6化箭头函数和this代码优化

es6
Joker.Wang-王顺 2 years ago
parent
commit
3db612aa38
  1. 24
      src/base/grid/grid.js
  2. 12
      src/base/layer/layer.drawer.js
  3. 16
      src/base/layer/layer.popover.js
  4. 4
      src/base/layer/layer.popup.js
  5. 16
      src/base/layer/layer.searcher.js
  6. 14
      src/base/list/listview.js
  7. 24
      src/base/list/virtualgrouplist.js
  8. 24
      src/base/list/virtuallist.js
  9. 10
      src/base/pager/pager.js
  10. 2
      src/base/single/tip/tip.toast.js
  11. 2
      src/base/single/tip/tip.tooltip.js

24
src/base/grid/grid.js

@ -30,7 +30,7 @@ export default class GridView extends Widget {
scrollLeft: 0, scrollLeft: 0,
scrollTop: 0, scrollTop: 0,
items: [], items: [],
itemFormatter: (item, row, col)=> { itemFormatter: (item, row, col) => {
return item; return item;
}, },
}); });
@ -46,13 +46,13 @@ export default class GridView extends Widget {
this.renderedKeys = []; this.renderedKeys = [];
this.renderRange = {}; this.renderRange = {};
this._scrollLock = false; this._scrollLock = false;
this._debounceRelease = BI.debounce(()=> { this._debounceRelease = BI.debounce(() => {
this._scrollLock = false; this._scrollLock = false;
}, 1000 / 60); }, 1000 / 60);
this.container = BI._lazyCreateWidget({ this.container = BI._lazyCreateWidget({
type: "bi.absolute", type: "bi.absolute",
}); });
this.element.scroll(()=> { this.element.scroll(() => {
if (this._scrollLock === true) { if (this._scrollLock === true) {
return; return;
} }
@ -85,7 +85,7 @@ export default class GridView extends Widget {
scrollx: scrollx, scrollx: scrollx,
items: [this.container], items: [this.container],
}); });
o.items = BI.isFunction(o.items) ? this.__watch(o.items, (context, newValue)=> { o.items = BI.isFunction(o.items) ? this.__watch(o.items, (context, newValue) => {
this.populate(newValue); this.populate(newValue);
}) : o.items; }) : o.items;
if (o.items.length > 0) { if (o.items.length > 0) {
@ -104,7 +104,7 @@ export default class GridView extends Widget {
} }
destroyed() { destroyed() {
BI.each(this.renderedCells, (i, cell)=> { BI.each(this.renderedCells, (i, cell) => {
cell.el._destroy(); cell.el._destroy();
}) })
} }
@ -235,14 +235,14 @@ export default class GridView extends Widget {
} }
// 已存在的, 需要添加的和需要删除的 // 已存在的, 需要添加的和需要删除的
const existSet = {}, addSet = {}, deleteArray = []; const existSet = {}, addSet = {}, deleteArray = [];
BI.each(renderedKeys, (i, key)=> { BI.each(renderedKeys, (i, key) => {
if (this.renderedKeys[i]) { if (this.renderedKeys[i]) {
existSet[i] = key; existSet[i] = key;
} else { } else {
addSet[i] = key; addSet[i] = key;
} }
}); });
BI.each(this.renderedKeys, function (i, key) { BI.each(this.renderedKeys, (i, key) => {
if (existSet[i]) { if (existSet[i]) {
return; return;
} }
@ -251,12 +251,12 @@ export default class GridView extends Widget {
} }
deleteArray.push(key[2]); deleteArray.push(key[2]);
}); });
BI.each(deleteArray, (i, index)=> { BI.each(deleteArray, (i, index) => {
// 性能优化,不调用destroy方法防止触发destroy事件 // 性能优化,不调用destroy方法防止触发destroy事件
this.renderedCells[index].el._destroy(); this.renderedCells[index].el._destroy();
}); });
const addedItems = []; const addedItems = [];
BI.each(addSet, function (index, key) { BI.each(addSet, (index, key) => {
addedItems.push(renderedCells[key[2]]); addedItems.push(renderedCells[key[2]]);
}); });
// 与listview一样, 给上下文 // 与listview一样, 给上下文
@ -370,7 +370,7 @@ export default class GridView extends Widget {
setOverflowX(b) { setOverflowX(b) {
if (this.options.overflowX !== !!b) { if (this.options.overflowX !== !!b) {
this.options.overflowX = !!b; this.options.overflowX = !!b;
BI.nextTick(()=> { BI.nextTick(() => {
this.element.css({ overflowX: b ? "auto" : "hidden" }); this.element.css({ overflowX: b ? "auto" : "hidden" });
}); });
} }
@ -379,7 +379,7 @@ export default class GridView extends Widget {
setOverflowY(b) { setOverflowY(b) {
if (this.options.overflowY !== !!b) { if (this.options.overflowY !== !!b) {
this.options.overflowY = !!b; this.options.overflowY = !!b;
BI.nextTick(()=> { BI.nextTick(() => {
this.element.css({ overflowY: b ? "auto" : "hidden" }); this.element.css({ overflowY: b ? "auto" : "hidden" });
}); });
} }
@ -418,7 +418,7 @@ export default class GridView extends Widget {
} }
restore() { restore() {
BI.each(this.renderedCells, (i, cell)=> { BI.each(this.renderedCells, (i, cell) => {
cell.el._destroy(); cell.el._destroy();
}); });
this._clearChildren(); this._clearChildren();

12
src/base/layer/layer.drawer.js

@ -82,7 +82,7 @@ export default class Drawer extends Widget {
type: "bi.icon_button", type: "bi.icon_button",
cls: "bi-message-close close-font", cls: "bi-message-close close-font",
height: headerHeight, height: headerHeight,
handler: ()=> { handler: () => {
this.close(); this.close();
}, },
} : { } : {
@ -98,7 +98,7 @@ export default class Drawer extends Widget {
type: "bi.vertical", type: "bi.vertical",
scrolly: true, scrolly: true,
cls: "drawer-body", cls: "drawer-body",
ref: (_ref)=> { ref: (_ref) => {
this.body = _ref; this.body = _ref;
}, },
items: [{ items: [{
@ -153,7 +153,7 @@ export default class Drawer extends Widget {
show(callback) { show(callback) {
const { placement } = this.options; const { placement } = this.options;
requestAnimationFrame(()=> { requestAnimationFrame(() => {
const size = this._getSuitableSize(); const size = this._getSuitableSize();
switch (placement) { switch (placement) {
case "right": case "right":
@ -185,7 +185,7 @@ export default class Drawer extends Widget {
hide(callback) { hide(callback) {
const { placement } = this.options; const { placement } = this.options;
requestAnimationFrame(()=> { requestAnimationFrame(() => {
switch (placement) { switch (placement) {
case "right": case "right":
this.element.css({ this.element.css({
@ -215,13 +215,13 @@ export default class Drawer extends Widget {
} }
open() { open() {
this.show(()=> { this.show(() => {
this.fireEvent(Drawer.EVENT_OPEN); this.fireEvent(Drawer.EVENT_OPEN);
}); });
} }
close() { close() {
this.hide(()=> { this.hide(() => {
this.fireEvent(Drawer.EVENT_CLOSE); this.fireEvent(Drawer.EVENT_CLOSE);
}); });
} }

16
src/base/layer/layer.popover.js

@ -47,7 +47,7 @@ export class Popover extends Widget {
this.startX = 0; this.startX = 0;
this.startY = 0; this.startY = 0;
const size = this._calculateSize(); const size = this._calculateSize();
this.tracker = new BI.MouseMoveTracker(function (deltaX, deltaY) { this.tracker = new BI.MouseMoveTracker((deltaX, deltaY) => {
const W = BI.Widget._renderEngine.createElement("body").width(); const W = BI.Widget._renderEngine.createElement("body").width();
const H = BI.Widget._renderEngine.createElement("body").height(); const H = BI.Widget._renderEngine.createElement("body").height();
this.startX += deltaX; this.startX += deltaX;
@ -60,7 +60,7 @@ export class Popover extends Widget {
BI.Resizers._resize({ BI.Resizers._resize({
target: this.element[0], target: this.element[0],
}); });
}, ()=> { }, () => {
this.tracker.releaseMouseMoves(); this.tracker.releaseMouseMoves();
}, _global); }, _global);
const items = [{ const items = [{
@ -70,7 +70,7 @@ export class Popover extends Widget {
items: [{ items: [{
el: { el: {
type: "bi.absolute", type: "bi.absolute",
ref: (_ref)=> { ref: (_ref) => {
this.dragger = _ref; this.dragger = _ref;
}, },
items: [{ items: [{
@ -95,7 +95,7 @@ export class Popover extends Widget {
type: "bi.icon_button", type: "bi.icon_button",
cls: "bi-message-close close-font", cls: "bi-message-close close-font",
height: headerHeight, height: headerHeight,
handler: ()=> { handler: () => {
this.close(); this.close();
}, },
}, },
@ -109,7 +109,7 @@ export class Popover extends Widget {
type: "bi.vertical", type: "bi.vertical",
scrolly: true, scrolly: true,
cls: "popover-body", cls: "popover-body",
ref: (_ref)=> { ref: (_ref) => {
this.body = _ref; this.body = _ref;
}, },
css: { css: {
@ -164,7 +164,7 @@ export class Popover extends Widget {
} }
// mounted之后绑定事件 // mounted之后绑定事件
mounted() { mounted() {
this.dragger.element.mousedown(function (e) { this.dragger.element.mousedown((e) => {
if (this.options.draggable !== false) { if (this.options.draggable !== false) {
this.startX = this.element[0].offsetLeft; this.startX = this.element[0].offsetLeft;
this.startY = this.element[0].offsetTop; this.startY = this.element[0].offsetTop;
@ -258,7 +258,7 @@ export class BarPopover extends Popover {
text: this.options.btns[1], text: this.options.btns[1],
value: 1, value: 1,
level: "ignore", level: "ignore",
handler: (v)=> { handler: (v) => {
this.fireEvent(Popover.EVENT_CANCEL, v); this.fireEvent(Popover.EVENT_CANCEL, v);
this.close(v); this.close(v);
}, },
@ -267,7 +267,7 @@ export class BarPopover extends Popover {
text: this.options.btns[0], text: this.options.btns[0],
warningTitle: warningTitle, warningTitle: warningTitle,
value: 0, value: 0,
handler: (v)=> { handler: (v) => {
this.fireEvent(Popover.EVENT_CONFIRM, v); this.fireEvent(Popover.EVENT_CONFIRM, v);
this.close(v); this.close(v);
}, },

4
src/base/layer/layer.popup.js

@ -80,8 +80,8 @@ export default class PopupView extends Widget {
this.view = this._createView(); this.view = this._createView();
this.toolbar = this._createToolBar(); this.toolbar = this._createToolBar();
this.view.on(BI.Controller.EVENT_CHANGE, (type, ...args)=> { this.view.on(BI.Controller.EVENT_CHANGE, (type, ...args) => {
this.fireEvent.apply(this, [BI.Controller.EVENT_CHANGE, type, args]); this.fireEvent.apply(this, [BI.Controller.EVENT_CHANGE, type, ...args]);
if (type === BI.Events.CLICK) { if (type === BI.Events.CLICK) {
this.fireEvent(PopupView.EVENT_CHANGE); this.fireEvent(PopupView.EVENT_CHANGE);
} }

16
src/base/layer/layer.searcher.js

@ -26,7 +26,7 @@ export default class SearcherView extends Pane {
matcher: { // 完全匹配的构造器 matcher: { // 完全匹配的构造器
type: "bi.button_group", type: "bi.button_group",
behaviors: { behaviors: {
redmark: ()=> { redmark: () => {
return true; return true;
}, },
}, },
@ -38,7 +38,7 @@ export default class SearcherView extends Pane {
searcher: { searcher: {
type: "bi.button_group", type: "bi.button_group",
behaviors: { behaviors: {
redmark: function () { redmark: () => {
return true; return true;
}, },
}, },
@ -56,7 +56,7 @@ export default class SearcherView extends Pane {
type: "bi.button_group", type: "bi.button_group",
chooseType, chooseType,
behaviors: { behaviors: {
redmark: ()=> { redmark: () => {
return true; return true;
}, },
}, },
@ -65,8 +65,8 @@ export default class SearcherView extends Pane {
}], }],
value, value,
}); });
this.matcher.on(BI.Controller.EVENT_CHANGE, (type, val, ob)=> { this.matcher.on(BI.Controller.EVENT_CHANGE, (type, val, ob, ...args) => {
this.fireEvent(BI.Controller.EVENT_CHANGE, arguments); this.fireEvent.apply(this, [BI.Controller.EVENT_CHANGE, type, val, ob, ...args]);
if (type === BI.Events.CLICK) { if (type === BI.Events.CLICK) {
this.fireEvent(SearcherView.EVENT_CHANGE, val, ob); this.fireEvent(SearcherView.EVENT_CHANGE, val, ob);
} }
@ -85,7 +85,7 @@ export default class SearcherView extends Pane {
type: "bi.button_group", type: "bi.button_group",
chooseType, chooseType,
behaviors: { behaviors: {
redmark: ()=> { redmark: () => {
return true; return true;
}, },
}, },
@ -94,8 +94,8 @@ export default class SearcherView extends Pane {
}], }],
value, value,
}); });
this.searcher.on(BI.Controller.EVENT_CHANGE, (type, val, ob)=> { this.searcher.on(BI.Controller.EVENT_CHANGE, (type, val, ob, ...args) => {
this.fireEvent(BI.Controller.EVENT_CHANGE, arguments); this.fireEvent.apply(this, [BI.Controller.EVENT_CHANGE, type, val, ob, ...args]);
if (type === BI.Events.CLICK) { if (type === BI.Events.CLICK) {
this.fireEvent(BI.SearcherView.EVENT_CHANGE, val, ob); this.fireEvent(BI.SearcherView.EVENT_CHANGE, val, ob);
} }

14
src/base/list/listview.js

@ -16,7 +16,7 @@ export default class ListView extends Widget {
scrollTop: 0, scrollTop: 0,
el: {}, el: {},
items: [], items: [],
itemFormatter: (item, index)=> { itemFormatter: (item, index) => {
return item; return item;
}, },
}; };
@ -37,7 +37,7 @@ export default class ListView extends Widget {
items: [BI.extend({ items: [BI.extend({
type: "bi.vertical", type: "bi.vertical",
scrolly: false, scrolly: false,
ref: (_ref)=> { ref: (_ref) => {
this.container = _ref; this.container = _ref;
}, },
}, el)], }, el)],
@ -49,17 +49,17 @@ export default class ListView extends Widget {
mounted() { mounted() {
const o = this.options; const o = this.options;
// 这里无法进行结构,因为存在赋值操作,如果使用结构则this.options的值不会跟随变化 // 这里无法进行结构,因为存在赋值操作,如果使用结构则this.options的值不会跟随变化
o.items = BI.isFunction(o.items) ? this.__watch(o.items, (context, newValue)=> { o.items = BI.isFunction(o.items) ? this.__watch(o.items, (context, newValue) => {
this.populate(newValue); this.populate(newValue);
}) : o.items; }) : o.items;
this._populate(); this._populate();
this.element.scroll((e)=> { this.element.scroll((e) => {
o.scrollTop = this.element.scrollTop(); o.scrollTop = this.element.scrollTop();
this._calculateBlocksToRender(); this._calculateBlocksToRender();
}); });
let lastWidth = this.element.width(), let lastWidth = this.element.width(),
lastHeight = this.element.height(); lastHeight = this.element.height();
BI.ResizeDetector.addResizeListener(this, ()=> { BI.ResizeDetector.addResizeListener(this, () => {
if (!this.element.is(":visible")) { if (!this.element.is(":visible")) {
return; return;
} }
@ -81,14 +81,14 @@ export default class ListView extends Widget {
let cnt = this.renderedIndex + 1; let cnt = this.renderedIndex + 1;
let lastHeight; let lastHeight;
const getElementHeight = ()=> { const getElementHeight = () => {
return this.container.element.height(); return this.container.element.height();
} }
lastHeight = getElementHeight(); lastHeight = getElementHeight();
while ((lastHeight) < minContentHeight && index < items.length) { while ((lastHeight) < minContentHeight && index < items.length) {
const itemsArr = items.slice(index, index + blockSize); const itemsArr = items.slice(index, index + blockSize);
this.container.addItems(itemsArr.map((item, i)=> { this.container.addItems(itemsArr.map((item, i) => {
return itemFormatter(item, index + i); return itemFormatter(item, index + i);
}), this); }), this);
const addedHeight = getElementHeight() - lastHeight; const addedHeight = getElementHeight() - lastHeight;

24
src/base/list/virtualgrouplist.js

@ -18,7 +18,7 @@ export default class VirtualGroupList extends Widget {
rowHeight: "auto", rowHeight: "auto",
items: [], items: [],
el: {}, el: {},
itemFormatter: (item, index)=> { itemFormatter: (item, index) => {
return item; return item;
}, },
}; };
@ -37,13 +37,13 @@ export default class VirtualGroupList extends Widget {
type: "bi.vertical", type: "bi.vertical",
items: [{ items: [{
type: "bi.layout", type: "bi.layout",
ref: ()=> { ref: () => {
this.topBlank = this; this.topBlank = this;
}, },
}, { }, {
type: "bi.virtual_group", type: "bi.virtual_group",
height: rowHeight * items.length, height: rowHeight * items.length,
ref: ()=> { ref: () => {
this.container = this; this.container = this;
}, },
layouts: [BI.extend({ layouts: [BI.extend({
@ -52,7 +52,7 @@ export default class VirtualGroupList extends Widget {
}, el)], }, el)],
}, { }, {
type: "bi.layout", type: "bi.layout",
ref: ()=> { ref: () => {
this.bottomBlank = this; this.bottomBlank = this;
}, },
}], }],
@ -63,22 +63,22 @@ export default class VirtualGroupList extends Widget {
mounted() { mounted() {
// 这里无法进行结构,因为存在赋值操作,如果使用结构则this.options的值不会跟随变化 // 这里无法进行结构,因为存在赋值操作,如果使用结构则this.options的值不会跟随变化
const o = this.options; const o = this.options;
o.items = BI.isFunction(o.items) ? this.__watch(o.items, (context, newValue)=> { o.items = BI.isFunction(o.items) ? this.__watch(o.items, (context, newValue) => {
this.populate(newValue); this.populate(newValue);
}) : o.items; }) : o.items;
this._populate(); this._populate();
this.ticking = false; this.ticking = false;
this.element.scroll(()=> { this.element.scroll(() => {
o.scrollTop = this.element.scrollTop(); o.scrollTop = this.element.scrollTop();
if (!this.ticking) { if (!this.ticking) {
requestAnimationFrame(function () { requestAnimationFrame(() => {
this._calculateBlocksToRender(); this._calculateBlocksToRender();
this.ticking = false; this.ticking = false;
}); });
this.ticking = true; this.ticking = true;
} }
}); });
BI.ResizeDetector.addResizeListener(this, ()=> { BI.ResizeDetector.addResizeListener(this, () => {
if (this.element.is(":visible")) { if (this.element.is(":visible")) {
this._calculateBlocksToRender(); this._calculateBlocksToRender();
} }
@ -95,13 +95,13 @@ export default class VirtualGroupList extends Widget {
const minContentHeight = scrollTop + height + overscanHeight; const minContentHeight = scrollTop + height + overscanHeight;
let index = (this.renderedIndex + 1) * blockSize, cnt = this.renderedIndex + 1; let index = (this.renderedIndex + 1) * blockSize, cnt = this.renderedIndex + 1;
let lastHeight; let lastHeight;
const getElementHeight = ()=> { const getElementHeight = () => {
return this.container.element.height() + this.topBlank.element.height() + this.bottomBlank.element.height(); return this.container.element.height() + this.topBlank.element.height() + this.bottomBlank.element.height();
} }
lastHeight = this.renderedIndex === -1 ? 0 : getElementHeight(); lastHeight = this.renderedIndex === -1 ? 0 : getElementHeight();
while (lastHeight < minContentHeight && index < items.length) { while (lastHeight < minContentHeight && index < items.length) {
const itemsArr = items.slice(index, index + blockSize); const itemsArr = items.slice(index, index + blockSize);
this.container[this.renderedIndex === -1 ? "populate" : "addItems"](itemsArr.map((item, i)=> { this.container[this.renderedIndex === -1 ? "populate" : "addItems"](itemsArr.map((item, i) => {
return itemFormatter(item, index + i); return itemFormatter(item, index + i);
}), this); }), this);
const elementHeight = getElementHeight(); const elementHeight = getElementHeight();
@ -138,7 +138,7 @@ export default class VirtualGroupList extends Widget {
} }
} }
this.bottomBlank.setHeight(this.tree.sumTo(this.renderedIndex) - this.tree.sumTo(Math.min(end, this.renderedIndex)) + "px"); this.bottomBlank.setHeight(this.tree.sumTo(this.renderedIndex) - this.tree.sumTo(Math.min(end, this.renderedIndex)) + "px");
this.container.populate(itemsArr.map((item, i)=> { this.container.populate(itemsArr.map((item, i) => {
return itemFormatter(item, (start < 0 ? 0 : start) * blockSize + i); return itemFormatter(item, (start < 0 ? 0 : start) * blockSize + i);
})); }));
} else { } else {
@ -149,7 +149,7 @@ export default class VirtualGroupList extends Widget {
} }
} }
this.container.element.height(rowHeight * items.length - topHeight); this.container.element.height(rowHeight * items.length - topHeight);
this.container.populate(itemsArr.map((item, i)=> { this.container.populate(itemsArr.map((item, i) => {
return itemFormatter(item, (start < 0 ? 0 : start) * blockSize + i); return itemFormatter(item, (start < 0 ? 0 : start) * blockSize + i);
})); }));
} }

24
src/base/list/virtuallist.js

@ -16,7 +16,7 @@ export default class VirtualList extends Widget {
blockSize: 10, blockSize: 10,
scrollTop: 0, scrollTop: 0,
items: [], items: [],
itemFormatter: (item, index)=> { itemFormatter: (item, index) => {
return item; return item;
}, },
}; };
@ -34,18 +34,18 @@ export default class VirtualList extends Widget {
type: "bi.vertical", type: "bi.vertical",
items: [{ items: [{
type: "bi.layout", type: "bi.layout",
ref: (_ref)=> { ref: (_ref) => {
this.topBlank = _ref; this.topBlank = _ref;
}, },
}, { }, {
type: "bi.vertical", type: "bi.vertical",
scrolly: false, scrolly: false,
ref: (_ref)=> { ref: (_ref) => {
this.container = _ref; this.container = _ref;
}, },
}, { }, {
type: "bi.layout", type: "bi.layout",
ref: (_ref)=> { ref: (_ref) => {
this.bottomBlank = _ref; this.bottomBlank = _ref;
}, },
}], }],
@ -55,15 +55,15 @@ export default class VirtualList extends Widget {
mounted() { mounted() {
// 这里无法进行结构,因为存在赋值操作,如果使用结构则this.options的值不会跟随变化 // 这里无法进行结构,因为存在赋值操作,如果使用结构则this.options的值不会跟随变化
const o = this.options; const o = this.options;
o.items = BI.isFunction(o.items) ? this.__watch(o.items, (context, newValue)=> { o.items = BI.isFunction(o.items) ? this.__watch(o.items, (context, newValue) => {
this.populate(newValue); this.populate(newValue);
}) : o.items; }) : o.items;
this._populate(); this._populate();
this.element.scroll((e)=> { this.element.scroll((e) => {
o.scrollTop = this.element.scrollTop(); o.scrollTop = this.element.scrollTop();
this._calculateBlocksToRender(); this._calculateBlocksToRender();
}); });
BI.ResizeDetector.addResizeListener(this, ()=> { BI.ResizeDetector.addResizeListener(this, () => {
if (this.element.is(":visible")) { if (this.element.is(":visible")) {
this._calculateBlocksToRender(); this._calculateBlocksToRender();
} }
@ -76,13 +76,13 @@ export default class VirtualList extends Widget {
const minContentHeight = scrollTop + height + overscanHeight; const minContentHeight = scrollTop + height + overscanHeight;
let index = (this.renderedIndex + 1) * blockSize, cnt = this.renderedIndex + 1; let index = (this.renderedIndex + 1) * blockSize, cnt = this.renderedIndex + 1;
let lastHeight; let lastHeight;
const getElementHeight = ()=> { const getElementHeight = () => {
return this.container.element.height() + this.topBlank.element.height() + this.bottomBlank.element.height(); return this.container.element.height() + this.topBlank.element.height() + this.bottomBlank.element.height();
} }
lastHeight = getElementHeight(); lastHeight = getElementHeight();
while (lastHeight < minContentHeight && index < items.length) { while (lastHeight < minContentHeight && index < items.length) {
const itemsArr = items.slice(index, index + blockSize); const itemsArr = items.slice(index, index + blockSize);
this.container.addItems(itemsArr.map((item, i)=> { this.container.addItems(itemsArr.map((item, i) => {
return itemFormatter(item, index + i); return itemFormatter(item, index + i);
}), this); }), this);
const addedHeight = getElementHeight() - lastHeight; const addedHeight = getElementHeight() - lastHeight;
@ -158,10 +158,10 @@ export default class VirtualList extends Widget {
this.container.element.append(lastFragment); this.container.element.append(lastFragment);
this.topBlank.setHeight(this.tree.sumTo(Math.max(-1, start - 1)) + "px"); this.topBlank.setHeight(this.tree.sumTo(Math.max(-1, start - 1)) + "px");
this.bottomBlank.setHeight(this.tree.sumTo(this.renderedIndex) - this.tree.sumTo(Math.min(end, this.renderedIndex)) + "px"); this.bottomBlank.setHeight(this.tree.sumTo(this.renderedIndex) - this.tree.sumTo(Math.min(end, this.renderedIndex)) + "px");
BI.each(needMount, (i, child)=> { BI.each(needMount, (i, child) => {
child && child._mount(); child && child._mount();
}); });
BI.each(needDestroyed, (i, child)=> { BI.each(needDestroyed, (i, child) => {
child && child._destroy(); child && child._destroy();
}); });
} }
@ -180,7 +180,7 @@ export default class VirtualList extends Widget {
} }
_clearChildren() { _clearChildren() {
BI.each(this.container._children, (i, cell)=> { BI.each(this.container._children, (i, cell) => {
cell && cell._destroy(); cell && cell._destroy();
}); });
this.container._children = {}; this.container._children = {};

10
src/base/pager/pager.js

@ -23,7 +23,7 @@ export default class Pager extends Widget {
dynamicShowFirstLast: false, // 是否动态显示首页、尾页 dynamicShowFirstLast: false, // 是否动态显示首页、尾页
dynamicShowPrevNext: false, // 是否动态显示上一页、下一页 dynamicShowPrevNext: false, // 是否动态显示上一页、下一页
pages: false, // 总页数 pages: false, // 总页数
curr: function () { curr: () => {
return 1; return 1;
}, // 初始化当前页 }, // 初始化当前页
groups: 0, // 连续显示分页数 groups: 0, // 连续显示分页数
@ -34,7 +34,7 @@ export default class Pager extends Widget {
next: "下一页", next: "下一页",
firstPage: 1, firstPage: 1,
lastPage: ()=> { // 在万不得已时才会调用这个函数获取最后一页的页码, 主要作用于setValue方法 lastPage: () => { // 在万不得已时才会调用这个函数获取最后一页的页码, 主要作用于setValue方法
return 1; return 1;
}, },
hasPrev: BI.emptyFn, // pages不可用时有效 hasPrev: BI.emptyFn, // pages不可用时有效
@ -185,7 +185,7 @@ export default class Pager extends Widget {
this.button_group = BI.createWidget({ this.button_group = BI.createWidget({
type: "bi.button_group", type: "bi.button_group",
element: this, element: this,
items: BI.map(view, (idx, v)=> { items: BI.map(view, (idx, v) => {
v = BI.extend({ v = BI.extend({
cls: "bi-list-item-select bi-border-radius", cls: "bi-list-item-select bi-border-radius",
height: 23, height: 23,
@ -198,7 +198,7 @@ export default class Pager extends Widget {
behaviors, behaviors,
layouts, layouts,
}); });
this.button_group.on(BI.Controller.EVENT_CHANGE, (type, value, obj, ...args)=> { this.button_group.on(BI.Controller.EVENT_CHANGE, (type, value, obj, ...args) => {
// if (self._lock === true) { // if (self._lock === true) {
// return; // return;
// } // }
@ -230,7 +230,7 @@ export default class Pager extends Widget {
this._populate(); this._populate();
this.fireEvent(Pager.EVENT_CHANGE, obj); this.fireEvent(Pager.EVENT_CHANGE, obj);
} }
this.fireEvent.apply(this, [BI.Controller.EVENT_CHANGE, type, value, obj, args]); this.fireEvent.apply(this, [BI.Controller.EVENT_CHANGE, type, value, obj, ...args]);
}); });
this.fireEvent(Pager.EVENT_AFTER_POPULATE); this.fireEvent(Pager.EVENT_AFTER_POPULATE);
} }

2
src/base/single/tip/tip.toast.js

@ -100,7 +100,7 @@ export default class Toast extends Tip {
items.push({ items.push({
type: "bi.icon_button", type: "bi.icon_button",
cls: "close-font toast-icon", cls: "close-font toast-icon",
handler: ()=> { handler: () => {
this.destroy(); this.destroy();
}, },
height: textHeight, height: textHeight,

2
src/base/single/tip/tip.tooltip.js

@ -51,7 +51,7 @@ export default class Tooltip extends Tip {
element: this, element: this,
hgap: this._const.hgap, hgap: this._const.hgap,
innerVgap: this._const.vgap, innerVgap: this._const.vgap,
items: BI.map(texts, function (i, text) { items: BI.map(texts, (i, text) => {
return { return {
type: "bi.label", type: "bi.label",
textAlign: textAlign, textAlign: textAlign,

Loading…
Cancel
Save