.restrict({ }) with SVG transform issue
Was trying to figure out how to use the restrict if my SVG canvas is 200 x 200 and i have a %lt;g>roup that is as follows:-
<g id="svg_name" transform="matrix(1,0,0,1,21,19)"> <rect data-index="0" class="edit-rectangle" x="0" y="0" width="100" height="100" stroke-width="1"></rect> </g>
.rectChecker() can be rewritten to pull x=21, y = 19, and height=100, width=100 (ie:resulting in bottom=119 and right=121).
Question: How do I add a .restrict() to keep this rect within the 200x200 SVG?
The interactable.restrict({drag: ..., resize: ..., endOnly: true, ... }) method is deprecated. You should use
interactable.<actionable>({
restrict: {
restriction: ...,
endOnly: true,
...
},
})
To answer your question, it depends on a few things including:
- What
originyou're using. - The svg element's position. At the top-left of the page with no margin, border or padding is the easiest to work with.
It could be enough to use restriction: 'svg' if the parent svg element is at the top-left of the page.
restriction: { x: 0, y: 0, width: 200, height: 200 } should work in either case, I think.
@alkhoo Did you get this working?