Browse Source

refactor: 改为css控制

es6
iapyang 4 years ago
parent
commit
237a003e4f
  1. 16
      src/base/layer/layer.popover.js
  2. 17
      src/less/base/layer/layer.popover.less

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

@ -31,6 +31,7 @@ BI.Popover = BI.inherit(BI.Widget, {
var self = this; var o = this.options; var self = this; var o = this.options;
this.startX = 0; this.startX = 0;
this.startY = 0; this.startY = 0;
var size = this._calculateSize();
this.tracker = new BI.MouseMoveTracker(function (deltaX, deltaY) { this.tracker = new BI.MouseMoveTracker(function (deltaX, deltaY) {
var W = BI.Widget._renderEngine.createElement("body").width(); var W = BI.Widget._renderEngine.createElement("body").width();
var H = BI.Widget._renderEngine.createElement("body").height(); var H = BI.Widget._renderEngine.createElement("body").height();
@ -98,7 +99,7 @@ BI.Popover = BI.inherit(BI.Widget, {
tgap: 10, tgap: 10,
items: [{ items: [{
el: BI.extend({}, o.body, { el: BI.extend({}, o.body, {
extraCls: "dynamic-height-limit-layout", extraCls: "dynamic-height-limit-layout-" + size.type,
}), }),
}], }],
} : { } : {
@ -129,15 +130,12 @@ BI.Popover = BI.inherit(BI.Widget, {
}); });
} }
var size = this._calculateSize();
return BI.extend({ return BI.extend({
type: o.logic.dynamic ? "bi.vertical" : "bi.vtape", type: o.logic.dynamic ? "bi.vertical" : "bi.vtape",
items: items, items: items,
width: size.width, width: size.width,
}, o.logic.dynamic ? { }, o.logic.dynamic ? {
type: "bi.vertical", type: "bi.vertical",
extraCls: "dynamic-layout",
scrolly: false, scrolly: false,
} : { } : {
type: "bi.vtape", type: "bi.vtape",
@ -153,12 +151,6 @@ BI.Popover = BI.inherit(BI.Widget, {
self.startY = pos.top; self.startY = pos.top;
self.tracker.captureMouseMoves(e); self.tracker.captureMouseMoves(e);
}); });
if (o.logic.dynamic) {
var size = this._calculateSize();
var height = this.element.height();
var compareHeight = BI.clamp(height, size.height, o.logic.maxHeight || 600) - (o.footer ? o.footerHeight + o.headerHeight : o.headerHeight);
this.body.element.height(compareHeight);
}
}, },
_calculateSize: function () { _calculateSize: function () {
@ -169,20 +161,24 @@ BI.Popover = BI.inherit(BI.Widget, {
case this._constant.SIZE.SMALL: case this._constant.SIZE.SMALL:
size.width = 450; size.width = 450;
size.height = 200; size.height = 200;
size.type = "small";
break; break;
case this._constant.SIZE.BIG: case this._constant.SIZE.BIG:
size.width = 900; size.width = 900;
size.height = 500; size.height = 500;
size.type = "big";
break; break;
default: default:
size.width = 550; size.width = 550;
size.height = 500; size.height = 500;
size.type = "default";
} }
} }
return { return {
width: o.width || size.width, width: o.width || size.width,
height: o.height || size.height, height: o.height || size.height,
type: size.type || "default",
}; };
}, },

17
src/less/base/layer/layer.popover.less

@ -1,5 +1,18 @@
@maxHeight: 600px;
.bi-popover { .bi-popover {
.dynamic-height-limit-layout { .dynamic-height-limit-layout-small {
max-height: 100%; min-height: 200px;
max-height: @maxHeight;
}
.dynamic-height-limit-layout-big {
min-height: 500px;
max-height: @maxHeight;
}
.dynamic-height-limit-layout-small {
min-height: 500px;
max-height: @maxHeight;
} }
} }

Loading…
Cancel
Save