Browse Source

feature: combo显隐规则重构下

es6
guy 2 years ago
parent
commit
c09ea7d0ee
  1. 5
      src/base/combination/combo.js
  2. 12
      src/core/4.widget.js
  3. 6
      src/less/base/combo/combo.less

5
src/base/combination/combo.js

@ -48,6 +48,11 @@
}); });
}, },
// 复写visual相关代码,让其通过class实现显隐藏
__setElementVisible: function (visible) {
this.element[visible ? "removeClass" : "addClass"]("bi-combo-hidden");
},
render: function () { render: function () {
var self = this, o = this.options; var self = this, o = this.options;
this._initCombo(); this._initCombo();

12
src/core/4.widget.js

@ -308,7 +308,7 @@
}) : o.invisible; }) : o.invisible;
if (invisible) { if (invisible) {
// 用display属性做显示和隐藏,否则jquery会在显示时将display设为block会覆盖掉display:flex属性 // 用display属性做显示和隐藏,否则jquery会在显示时将display设为block会覆盖掉display:flex属性
this.element.css("display", "none"); this.__setElementVisible(false);
} }
} }
}, },
@ -513,13 +513,17 @@
} }
}, },
__setElementVisible: function (visible) {
this.element.css("display", visible ? "" : "none");
},
_innerSetVisible: function (visible) { _innerSetVisible: function (visible) {
var self = this, o = this.options; var self = this, o = this.options;
var lastVisible = !o.invisible; var lastVisible = !o.invisible;
this._setVisible(visible); this._setVisible(visible);
if (visible === true) { if (visible === true) {
// 用this.element.show()会把display属性改成block // 用this.element.show()会把display属性改成block
this.element.css("display", ""); this.__setElementVisible(true);
this._mount(); this._mount();
if (o.animation && !lastVisible) { if (o.animation && !lastVisible) {
this.element.removeClass(o.animation + "-leave").removeClass(o.animation + "-leave-active").addClass(o.animation + "-enter"); this.element.removeClass(o.animation + "-leave").removeClass(o.animation + "-leave-active").addClass(o.animation + "-enter");
@ -552,10 +556,10 @@
} }
this._animationDuring = setTimeout(function () { this._animationDuring = setTimeout(function () {
self.element.removeClass(o.animation + "-leave").removeClass(o.animation + "-leave-active"); self.element.removeClass(o.animation + "-leave").removeClass(o.animation + "-leave-active");
self.element.css("display", "none"); self.__setElementVisible(false);
}, o.animationDuring); }, o.animationDuring);
} else { } else {
this.element.css("display", "none"); this.__setElementVisible(false);
} }
} }
}, },

6
src/less/base/combo/combo.less

@ -12,9 +12,6 @@
} }
&.bi-combo-popup { &.bi-combo-popup {
display: block !important;
visibility: visible !important;
& > .bi-trigger { & > .bi-trigger {
& .bi-trigger-icon-button { & .bi-trigger-icon-button {
& .x-icon { & .x-icon {
@ -24,6 +21,9 @@
} }
} }
} }
&.bi-combo-hidden:not(.bi-combo-popup) {
display: none !important;
}
&.bi-combo-popup, &.bi-combo-hover, &:hover { &.bi-combo-popup, &.bi-combo-hover, &:hover {
&.bi-border, &.bi-border-bottom { &.bi-border, &.bi-border-bottom {

Loading…
Cancel
Save