|
1 | 1 | import { settings, internals, browser, gStyle, isObject, isFunc, isStr, clTGaxis, nsSVG, kInspect, getDocument } from '../core.mjs'; |
2 | | -import { rgb as d3_rgb, select as d3_select } from '../d3.mjs'; |
| 2 | +import { rgb as d3_rgb, select as d3_select, drag as d3_drag, pointer as d3_pointer } from '../d3.mjs'; |
3 | 3 | import { selectgStyle, saveSettings, readSettings, saveStyle, getColorExec, changeObjectMember } from './utils.mjs'; |
4 | 4 | import { getColor } from '../base/colors.mjs'; |
5 | 5 | import { TAttMarkerHandler } from '../base/TAttMarkerHandler.mjs'; |
@@ -1576,32 +1576,42 @@ class StandaloneMenu extends JSRootMenu { |
1576 | 1576 | d3_select(`#${dlg_id}`).remove(); |
1577 | 1577 | d3_select(`#${dlg_id}_block`).remove(); |
1578 | 1578 |
|
1579 | | - const w = Math.min(args.width || 450, Math.round(0.9 * browser.screenWidth)); |
1580 | | - modal.block = d3_select('body').append('div') |
1581 | | - .attr('id', `${dlg_id}_block`) |
1582 | | - .attr('class', 'jsroot_dialog_block') |
1583 | | - .attr('style', 'z-index: 100000; position: absolute; left: 0px; top: 0px; bottom: 0px; right: 0px; opacity: 0.2; background-color: white'); |
1584 | | - modal.element = d3_select('body') |
1585 | | - .append('div') |
1586 | | - .attr('id', dlg_id) |
1587 | | - .attr('class', 'jsroot_dialog') |
1588 | | - .style('position', 'absolute') |
1589 | | - .style('width', `${w}px`) |
1590 | | - .style('left', '50%') |
1591 | | - .style('top', '50%') |
1592 | | - .style('z-index', 100001) |
1593 | | - .attr('tabindex', '0'); |
| 1579 | + const w = Math.min(args.width || 450, Math.round(0.9 * browser.screenWidth)), |
| 1580 | + b = d3_select('body'); |
| 1581 | + modal.block = b.append('div') |
| 1582 | + .attr('id', `${dlg_id}_block`) |
| 1583 | + .attr('class', 'jsroot_dialog_block') |
| 1584 | + .attr('style', 'z-index: 100000; position: absolute; left: 0px; top: 0px; bottom: 0px; right: 0px; opacity: 0.2; background-color: white'); |
| 1585 | + modal.element = b.append('div') |
| 1586 | + .attr('id', dlg_id) |
| 1587 | + .attr('class', 'jsroot_dialog') |
| 1588 | + .style('position', 'absolute') |
| 1589 | + .style('width', `${w}px`) |
| 1590 | + .style('left', '50%') |
| 1591 | + .style('top', '50%') |
| 1592 | + .style('z-index', 100001) |
| 1593 | + .attr('tabindex', '0'); |
1594 | 1594 |
|
1595 | 1595 | modal.element.html( |
1596 | 1596 | '<div style=\'position: relative; left: -50%; top: -50%; border: solid green 3px; padding: 5px; display: flex; flex-flow: column; background-color: white\'>' + |
1597 | | - `<div style='flex: 0 1 auto; padding: 5px'>${title}</div>` + |
| 1597 | + `<div style='flex: 0 1 auto; padding: 5px; cursor: pointer;' class='jsroot_dialog_title'>${title}</div>` + |
1598 | 1598 | `<div class='jsroot_dialog_content' style='flex: 1 1 auto; padding: 5px'>${main_content}</div>` + |
1599 | 1599 | '<div class=\'jsroot_dialog_footer\' style=\'flex: 0 1 auto; padding: 5px\'>' + |
1600 | 1600 | `<button class='jsroot_dialog_button' style='float: right; width: fit-content; margin-right: 1em'>${args.Ok}</button>` + |
1601 | 1601 | (args.btns ? '<button class=\'jsroot_dialog_button\' style=\'float: right; width: fit-content; margin-right: 1em\'>Cancel</button>' : '') + |
1602 | 1602 | '</div></div>' |
1603 | 1603 | ); |
1604 | 1604 |
|
| 1605 | + const drag_move = d3_drag().on('start', () => { modal.y0 = 0; }).on('drag', evnt => { |
| 1606 | + if (!modal.y0) |
| 1607 | + modal.y0 = d3_pointer(evnt, modal.element.node())[1]; |
| 1608 | + let p0 = Math.max(0, d3_pointer(evnt, b.node())[1] - modal.y0); |
| 1609 | + if (b.node().clientHeight) |
| 1610 | + p0 = Math.min(p0, 0.8 * b.node().clientHeight); |
| 1611 | + modal.element.style('top', `${p0}px`); |
| 1612 | + }); |
| 1613 | + modal.element.select('.jsroot_dialog_title').call(drag_move); |
| 1614 | + |
1605 | 1615 | modal.done = function(res) { |
1606 | 1616 | if (this._done) |
1607 | 1617 | return; |
|
0 commit comments