import {onSelect} from "../services/dom";
+import {Component} from "./component";
/**
* Dropdown
* Provides some simple logic to create simple dropdown menus.
- * @extends {Component}
*/
-class DropDown {
+export class Dropdown extends Component {
setup() {
this.container = this.$el;
if (this.moveMenu) {
this.body.appendChild(this.menu);
this.menu.style.position = 'fixed';
- if (this.direction === 'right') {
- this.menu.style.right = `${(menuOriginalRect.right - menuOriginalRect.width)}px`;
- } else {
- this.menu.style.left = `${menuOriginalRect.left}px`;
- }
this.menu.style.width = `${menuOriginalRect.width}px`;
+ this.menu.style.left = `${menuOriginalRect.left}px`;
heightOffset = dropUpwards ? (window.innerHeight - menuOriginalRect.top - toggleHeight / 2) : menuOriginalRect.top;
}
}
hideAll() {
- for (let dropdown of window.components.dropdown) {
+ for (let dropdown of window.$components.get('dropdown')) {
dropdown.hide();
}
}
this.menu.style.position = '';
this.menu.style[this.direction] = '';
this.menu.style.width = '';
+ this.menu.style.left = '';
this.container.appendChild(this.menu);
}
});
}
-}
-
-export default DropDown;
\ No newline at end of file
+}
\ No newline at end of file