Skip to content

Commit

Permalink
Made modal draggable (#1822)
Browse files Browse the repository at this point in the history
Co-authored-by: Stefan Forsgren <stefan@[email protected]>
  • Loading branch information
steff-o and Stefan Forsgren authored Sep 22, 2023
1 parent aa9fc5a commit d156d0e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/ui/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Component from './component';
import Element from './element';
import Button from './button';
import { html } from './dom/dom';
import utils from '../utils';

/**
* Creates a modal and displays it. The modal is created as a div tag that is attached to the DOM as a child of the options.target element.
Expand Down Expand Up @@ -93,7 +94,7 @@ export default function Modal(options = {}) {
headerCmps.push(closeButton);

headerEl = Element({
cls: 'flex row justify-end grey-lightest',
cls: 'flex row justify-end grey-lightest draggable',
components: headerCmps
});
const elOptions = { cls: 'o-modal-content' };
Expand Down Expand Up @@ -121,6 +122,8 @@ export default function Modal(options = {}) {
},
onRender() {
modal = document.getElementById(this.getId());
const modalBox = modal.getElementsByClassName('o-modal')[0];
utils.makeElementDraggable(modalBox);
document.getElementById(screenEl.getId()).addEventListener('click', () => {
if (!isStatic) {
closeButton.dispatch('click');
Expand Down

0 comments on commit d156d0e

Please sign in to comment.