Open wojtek-krysiak opened 10 years ago
i implemented this outside of fabricjs-viewport using hammer. i can post, if interested
yes , please
I used Hammer 1.x because I had some blocker with 2. There is definitely room for improvement.
I chose not to implement pan, but it should be relatively easy with hammer.
var gestureTransformActive = false; // used to disable long-tap context menu
$(document).on('transform', $.throttle(50, function(evt) {
console.log('document:transform', evt);
var $this = $(this)
, canvas = stage.getActiveCanvas();
$(document).trigger('dragcancel');
gestureTransformActive = true;
if (stage.selectionActive()) {
var selection = canvas.getActiveGroup() || canvas.getActiveObject();
selection.scale(evt.gesture.scale);
selection.set('angle', evt.gesture.rotation);
}
else canvas.setZoom(evt.gesture.scale);
$(document).one('transformend', function(evt) {
gestureTransformActive = false;
});
}));
Are (multi-)touch gestures for canvas zoom & pan already supported?
Pan canvas (canvas is larger than screen) Zoom canvas with pinch-to-zoom gesture Both gestures are 1-2 finger gestures supported by the already integrated gestures module & event.js