Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let curZoom = this.zoomFactor;
let cursor, delta;
if (zoomIn) {
cursor = 'zoom-in';
delta = 1.1;
//this.scalePoints(.95);
} else {
cursor = 'zoom-out';
delta = .95
//this.scalePoints(1.1);
}
this.zoomFactor *= delta;
console.log(cursor);
// canvas.defaultCursor = cursor;
// canvas.hoverCursor = cursor;
canvas.zoomToPoint(new fabric.Point(
e.e.offsetX, e.e.offsetY), this.zoomFactor);
//this.resetCursors();
// let obj = e.target;
// if (obj !== undefined
// && obj !== null
// && this.polygonClicks.length > 0
// && obj === this.polygonClicks[0]) {
// obj.set({
// stroke: 'green',
// fill: 'green',
// });
// canvas.renderAll();
// }
},
resetZoom: function() {
this.zoomFactor = 1 ;
console.log(canvas.width, canvas.height);
canvas.setZoom(this.zoomFactor);
canvas.zoomToPoint(new fabric.Point(
canvas.width/2, canvas.height/2), this.zoomFactor);
},
handleGrabMove: function(e) {
console.log("handling grab move", e.e);
var delta = new fabric.Point(e.e.movementX, e.e.movementY) ;
canvas.relativePan(delta);
},
canvas.on('mouse:up', function(o){
var objectFound = false;
var clickPoint = new fabric.Point(o.e.offsetX, o.e.offsetY);
canvas.forEachObject(function (obj) {
if (!objectFound && obj.containsPoint(clickPoint)) {
objectFound = true;
if (composition_mode === 'free'){
note_start = Math.floor(obj.path[0][1] / (time_step * 4)) + 1
note_end = Math.floor(obj.path[obj.path.length -1][1] / (time_step * 4))
}
else{
note_start = Math.floor(Math.min(obj.x1,obj.x2) / (time_step * 4))
note_end = Math.floor(Math.max(obj.x1,obj.x2) / (time_step * 4)) + 1
}
console.log(note_start)
console.log(note_end)
send_notes(note_start, note_end, composition_mode)
;}
canvas.forEachObject((obj) => {if (!(typeof(obj) === 'undefined') && !(obj === line)) {
let point_tl = new fabric.Point(obj.x1, 0);
let point_br = new fabric.Point(obj.x2, canvas.height);
if (line.intersectsWithRect(point_tl, point_br) || line.isContainedWithinRect(point_tl, point_br)) {canvas.remove(line).renderAll()}
}
});
});
canvas.forEachObject((obj) => {if (!(typeof(obj) === 'undefined') && !(obj === path)) {
let point_tl = new fabric.Point(obj.path[0][1], 0);
let point_br = new fabric.Point(obj.path[obj.path.length -1][1], canvas.height);
if (path.intersectsWithRect(point_tl, point_br) || path.isContainedWithinRect(point_tl, point_br)) {canvas.remove(path).renderAll();}
}
})
}
canvas.forEachObject((obj) => {if (!(typeof(obj) === 'undefined') && !(obj === line)) {
let point_tl = new fabric.Point(obj.x1, 0);
let point_br = new fabric.Point(obj.x2, canvas.height);
if (line.intersectsWithRect(point_tl, point_br) || line.isContainedWithinRect(point_tl, point_br)) {canvas.remove(line).renderAll()}
}
});
});
canvas.forEachObject((obj) => {if (!(typeof(obj) === 'undefined') && !(obj === path)) {
let point_tl = new fabric.Point(obj.path[0][1], 0);
let point_br = new fabric.Point(obj.path[obj.path.length -1][1], canvas.height);
if (path.intersectsWithRect(point_tl, point_br) || path.isContainedWithinRect(point_tl, point_br)) {canvas.remove(path).renderAll();}
}
})
}