Small window/large paper? #2550
-
IntroductionI'm not 100% sure how to even express what I'm trying to do here, but I've cut and pasted a test that illustrates my problem at https://jsfiddle.net/dmb0058/vt5xL4jg/25/. I think my confusion stems from the fact that I don't understand the relationship between the "paper" and the "window" that I'm viewing it in. They start off looking like the same thing, but when I zoom in, it's as if I'm looking at a big paper through a smaller window, if that makes sense. If I click on the background of this application and drag towards the bottom right, the image pans as I would expect. However, the grid moves with the links and elements - the area around the top and left of the image doesn't have the grid displayed. I'm guessing that the bit with the grid is the actual paper as this corresponds to the size I set in the paper constructor, but if that's the case, what is the "non-paper" part of the window? Why doesn't the colour of the 'non-paper' part change? And why can I drag the rectangles 'off the paper'? I think my question is just "how can I prevent elements and links from being dragged off the paper, onto the 'non-paper', whatever that is?". I think the 'non-paper' might be called the gutter? David Steps to reproduceNo response Restrictions & ConstraintsNo response Does your question relate to JointJS or JointJS+. Select both if applicable.JointJS |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 16 replies
-
The issue is there was a breaking change in const panZoom = svgPanZoom(paper.svg, {
viewportSelector: paper.layers,
zoomEnabled: true,
panEnabled: false,
controlIconsEnabled: true,
maxZoom: 2,
minZoom: 0.1,
onUpdatedCTM: (function() {
let currentMatrix = paper.matrix();
return function onUpdatedCTM(matrix){
const { a, d, e, f } = matrix;
const { a: ca, d: cd, e: ce, f: cf } = currentMatrix;
const translateChanged = (e !== ce || f !== cf)
if (translateChanged)
paper.trigger('translate', e - ce, f - cf, {});
const scaleChanged = (a !== ca || d !== cd);
if (scaleChanged)
paper.trigger('scale', a, d, {});
if (scaleChanged || translateChanged) {
paper.trigger('transform', matrix, {});
}
currentMatrix = matrix;
}
})()
}); Here's updated example for version 4. |
Beta Was this translation helpful? Give feedback.
-
Zooming a diagram out must create the padding because the diagram gets smaller but the viewport window stays the same, so you need to fill the space with something (that padding will be either at the bottom or the top). As being said, it was just an example. You can zoom in/out to any point you find useful e.g. paperScroller.zoom(zoom * scale, { min: 0.2, max: 5, ox: 500, oy: 500, absolute: true }); Is there any software you can use as a reference for what you are looking for? |
Beta Was this translation helpful? Give feedback.
The issue is there was a breaking change in
v4
regarding the grid and paper events.In version 4 the grid is updated on
transform
event (not present inv3.7
).