IITC-CE / ingress-intel-total-conversion

intel.ingress.com total conversion user script with some new features. Should allow easier extension of the intel map.
https://iitc.app
ISC License
279 stars 105 forks source link

FR: Allow `dialog`s to snap to sidebar #739

Open nexushoratio opened 4 weeks ago

nexushoratio commented 4 weeks ago

TIL that the dialog() wrapper sets up snapping by default. Well, at least to other draggables.

What about defaulting them to also snap to the sidebar?

It looks like the change is simple enough. Change this line: https://github.com/IITC-CE/ingress-intel-total-conversion/blob/199c9f7bdc0acb79db3855f9f5cd7c0cd516ec66/core/code/dialog.js#L238

to read: dialog.dialog().parents('.ui-dialog').draggable('option', 'snap', '.ui-draggable, #sidebar');

(I don't have my test code in my editor still, so the details on the selectors may be wrong, so verify.)

Bonus if someone could figure out how to make them dock instead of just snap so that as the sidebar changes size, the dialogs stay relative. But I did not see anything in my few minutes of checking the jQuery UI documentation.

nexushoratio commented 4 weeks ago

Was doing some more research. Just capturing some thoughts while in my head. May be completely off:

Assume the hand-wavy stuff works, that would probably handle the case when the sidebar changes sizes. But unsure what to do when the sidebar is toggled. (Maybe instead make it possible for a draggable to go into the sidebar as a sortable? Dunno, just making things up at this point. Time for bed.)