nuevo refactor a dropDown
This commit is contained in:
parent
5c54550283
commit
7f0dc42500
|
@ -24,7 +24,7 @@ export default class DropDown {
|
|||
|
||||
set show(value) {
|
||||
let oldValue = this.show;
|
||||
// I wait up to 1 second if the dropdown opens but there is no data to show
|
||||
// It wait up to 1 second if the dropdown opens but there is no data to show
|
||||
if (value && !oldValue && !this.itemsFiltered.length && this._tryToShow < 4) {
|
||||
this.$timeout(() => {
|
||||
this._tryToShow++;
|
||||
|
@ -72,11 +72,13 @@ export default class DropDown {
|
|||
_toggleDropDown(value, oldValue) {
|
||||
if (value && !this._focusingFilter && !oldValue && this.filter) {
|
||||
// open dropDown
|
||||
this.$timeout(() => { // wait angular ngIf
|
||||
this._setFocusInFilterInput();
|
||||
this._eventScroll(true);
|
||||
this._eventScroll(value);
|
||||
});
|
||||
} else if (!value && oldValue) {
|
||||
// close dropDown
|
||||
this._eventScroll(false);
|
||||
this._eventScroll(value);
|
||||
}
|
||||
|
||||
this.$timeout(() => {
|
||||
|
@ -86,16 +88,13 @@ export default class DropDown {
|
|||
|
||||
_eventScroll(add) {
|
||||
if (add) {
|
||||
this.$timeout(() => { // wait angular ngIf
|
||||
this.container.addEventListener('scroll', e => this.loadFromScroll(e));
|
||||
});
|
||||
} else {
|
||||
this.container.removeEventListener('scroll', e => this.loadFromScroll(e));
|
||||
}
|
||||
}
|
||||
|
||||
_setFocusInFilterInput(value, oldValue) {
|
||||
this.$timeout(() => {
|
||||
_setFocusInFilterInput() {
|
||||
let inputFilterSearch = this.$element[0].querySelector('input');
|
||||
this._focusingFilter = true;
|
||||
if (inputFilterSearch)
|
||||
|
@ -103,7 +102,6 @@ export default class DropDown {
|
|||
inputFilterSearch.focus();
|
||||
this._focusingFilter = false;
|
||||
}, 250);
|
||||
});
|
||||
}
|
||||
|
||||
_background(create) {
|
||||
|
|
Loading…
Reference in New Issue