Skip to content

Instantly share code, notes, and snippets.

@stijn1989
Last active May 25, 2022 07:41
Show Gist options
  • Save stijn1989/884cd3c5e634a852f4fcd1e30545b59a to your computer and use it in GitHub Desktop.
Save stijn1989/884cd3c5e634a852f4fcd1e30545b59a to your computer and use it in GitHub Desktop.
JointJS 3.5 resize tool for element
const ResizeTool = joint.elementTools.Control.extend({
getPosition: function(view) {
const model = view.model;
if(model.attr('root/originalSize') === void 0) {
model.attr('root/originalSize', model.attributes.size);
}
return {x: model.attributes.size.width, y: model.attributes.size.height};
},
setPosition: function(view, coordinates) {
view.model.resize(coordinates.x, coordinates.y);
},
resetPosition: function(view) {
const original = model.attr('root/originalSize') || {width: 0, height: 0};
model.resize(original.width, original.height);
}
});
@stijn1989
Copy link
Author

resize

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment