mirror of https://github.com/node-red/node-red.git
Add scroll spacer to fix scrollable area at minimum zoom
When at minimum zoom with "cover" behavior, the SVG canvas may be smaller than the viewport in one dimension. This causes the browser's scrollWidth/scrollHeight to be limited by the SVG size rather than the full canvas extent. Added an invisible spacer div that matches the scaled canvas dimensions, ensuring the scrollable area always reflects the actual canvas size. This allows proper scrolling to reach all canvas edges without going beyond canvas boundaries.pan-zoom
parent
f132867a31
commit
cdde99b9ab
|
|
@ -336,6 +336,24 @@ RED.view = (function() {
|
|||
function init() {
|
||||
|
||||
chart = $("#red-ui-workspace-chart");
|
||||
|
||||
// Add invisible spacer div to ensure scrollable area matches canvas dimensions
|
||||
// At minimum zoom with "cover" behavior, SVG may be smaller than viewport in one dimension
|
||||
// This spacer forces the browser to calculate scrollWidth/Height based on full canvas size
|
||||
// Browser's maxScroll = scrollWidth - viewport will then correctly show canvas edges
|
||||
var scrollSpacer = $('<div>')
|
||||
.css({
|
||||
position: 'absolute',
|
||||
top: 0,
|
||||
left: 0,
|
||||
width: space_width + 'px',
|
||||
height: space_height + 'px',
|
||||
pointerEvents: 'none',
|
||||
visibility: 'hidden'
|
||||
})
|
||||
.attr('id', 'red-ui-workspace-scroll-spacer')
|
||||
.appendTo(chart);
|
||||
|
||||
chart.on('contextmenu', function(evt) {
|
||||
if (RED.view.DEBUG) {
|
||||
console.warn("contextmenu", { mouse_mode, event: d3.event });
|
||||
|
|
@ -4969,6 +4987,15 @@ RED.view = (function() {
|
|||
eventLayer.attr("transform","scale("+scaleFactor+")");
|
||||
outer.attr("width", space_width*scaleFactor).attr("height", space_height*scaleFactor);
|
||||
|
||||
// Update scroll spacer to match scaled canvas size
|
||||
// This ensures scrollable area = canvas area
|
||||
// Browser calculates maxScroll = scrollWidth - viewport, which correctly
|
||||
// allows scrolling to see the far edges of canvas without going beyond
|
||||
$('#red-ui-workspace-scroll-spacer').css({
|
||||
width: (space_width * scaleFactor) + 'px',
|
||||
height: (space_height * scaleFactor) + 'px'
|
||||
});
|
||||
|
||||
// Don't bother redrawing nodes if we're drawing links
|
||||
if (showAllLinkPorts !== -1 || mouse_mode != RED.state.JOINING) {
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue