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