Jemt / Fit.UI

Fit.UI is a JavaScript based UI framework built on Object Oriented principles
http://fitui.org
GNU Lesser General Public License v3.0
19 stars 7 forks source link

Dialog: Make draggable #144

Closed FlowIT-JIT closed 2 years ago

FlowIT-JIT commented 2 years ago

Make dialog draggable to allow user to reveal content behind it.

Proof of concept:

d = new Fit.Controls.Dialog();
d.Modal(true);
d.Title("Editor output");
d.Width(80, "%");
d.Height(200);
d.Dismissible(true, true);
d.GetContentDomElement().innerHTML = input.Value();
d.Open();

dr = new Fit.DragDrop.Draggable(d.GetDomElement(), d.GetDomElement().querySelector("div.FitUiControlDialogTitle"));

It works as long as one drags it around. Releasing the mouse button causes it to return to the center of the screen. The reason for this can be found here: https://github.com/Jemt/Fit.UI/blob/4344573b10652b501babe4b65cda5480ba37fe1c/Controls/Dialog/Dialog.js#L932

An observer and various functions are responsible for ensuring the dialog remains centered when the size of the content within the dialog changes, which in turn may cause the dialog to change size. Obviously we just need to disable this mechanism the moment the user drags the dialog around for the first time.

Mhbuur commented 2 years ago

+1 This is a great suggestion! My company may be able to fund further development, lets get in touch.

FlowIT-JIT commented 2 years ago

Fixed with commit https://github.com/Jemt/Fit.UI/commit/223fc46148d08fe9309ec3370386c4c63cbe8059