Comparing version 4.1.0 to 4.2.0-browser
/*! Fabric.js Copyright 2008-2015, Printio (Juriy Zaytsev, Maxim Chernyak) */ | ||
var fabric = fabric || { version: '4.1.0' }; | ||
var fabric = fabric || { version: '4.2.0' }; | ||
if (typeof exports !== 'undefined') { | ||
@@ -76,2 +76,3 @@ exports.fabric = fabric; | ||
fabric.reNum = '(?:[-+]?(?:\\d+|\\d*\\.\\d+)(?:[eE][-+]?\\d+)?)'; | ||
fabric.commaWsp = '(?:\\s+,?\\s*|,\\s*)' | ||
fabric.rePathCommand = /([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:[eE][-+]?\d+)?)/ig; | ||
@@ -78,0 +79,0 @@ fabric.reNonWord = /[ \n\.,;!\?\-]/; |
161
package.json
{ | ||
"name": "fabric", | ||
"description": "Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.", | ||
"homepage": "http://fabricjs.com/", | ||
"version": "4.1.0", | ||
"author": "Juriy Zaytsev <kangax@gmail.com>", | ||
"contributors": [ | ||
{ | ||
"name": "Andrea Bogazzi", | ||
"email": "andreabogazzi79@gmail.com" | ||
} | ||
], | ||
"keywords": [ | ||
"canvas", | ||
"graphic", | ||
"graphics", | ||
"SVG", | ||
"node-canvas", | ||
"parser", | ||
"HTML5", | ||
"object model" | ||
], | ||
"browser": { | ||
"canvas": false, | ||
"fs": false, | ||
"jsdom": false, | ||
"jsdom/lib/jsdom/living/generated/utils": false, | ||
"jsdom/lib/jsdom/utils": false, | ||
"http": false, | ||
"https": false, | ||
"xmldom": false, | ||
"url": false | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/fabricjs/fabric.js" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/fabricjs/fabric.js/issues" | ||
}, | ||
"license": "MIT", | ||
"scripts": { | ||
"build": "node build.js modules=ALL requirejs exclude=gestures,accessors", | ||
"build:fast": "node build.js modules=ALL requirejs fast exclude=gestures,accessors", | ||
"build:watch": "onchange 'src/**/**' 'HEADER.js' 'lib/**/**' -- npm run build_export", | ||
"link:watch": "onchange 'src/**/**' 'HEADER.js' 'lib/**/**' -- npm link", | ||
"build_with_gestures": "node build.js modules=ALL exclude=accessors", | ||
"build_export": "npm run build:fast && npm run export_dist_to_site && npm run build_with_gestures && npm run export_gesture_to_site", | ||
"test:single": "qunit test/node_test_setup.js test/lib", | ||
"test": "nyc qunit test/node_test_setup.js test/lib test/unit", | ||
"test:visual": "qunit test/node_test_setup.js test/lib test/visual", | ||
"test:visual:single": "qunit test/node_test_setup.js test/lib", | ||
"test:all": "npm run test && npm run test:visual", | ||
"lint": "eslint --config .eslintrc.json src", | ||
"lint_tests": "eslint test/unit --config .eslintrc_tests && eslint test/visual --config .eslintrc_tests", | ||
"export_gesture_to_site": "cp dist/fabric.js ../fabricjs.com/lib/fabric_with_gestures.js", | ||
"export_dist_to_site": "cp dist/fabric.js ../fabricjs.com/lib/fabric.js && cp package.json ../fabricjs.com/lib/package.json && cp -r src HEADER.js lib ../fabricjs.com/build/files/", | ||
"export_tests_to_site": "cp test/unit/*.js ../fabricjs.com/test/unit && cp -r test/visual/* ../fabricjs.com/test/visual && cp -r test/fixtures/* ../fabricjs.com/test/fixtures && cp -r test/lib/* ../fabricjs.com/test/lib", | ||
"all": "npm run build && npm run test && npm run test:visual && npm run lint && npm run lint_tests && npm run export_dist_to_site && npm run export_tests_to_site", | ||
"testem": "testem .", | ||
"testem:visual": "testem --file testem-visual.json", | ||
"testem:ci": "testem ci" | ||
}, | ||
"optionalDependencies": { | ||
"canvas": "^2.6.1", | ||
"jsdom": "^15.2.1" | ||
}, | ||
"devDependencies": { | ||
"eslint": "4.18.x", | ||
"nyc": "13.3.x", | ||
"onchange": "^3.x.x", | ||
"qunit": "2.9.2", | ||
"testem": "^1.18.4", | ||
"uglify-js": "3.3.x", | ||
"pixelmatch": "^4.0.2", | ||
"chalk": "^2.4.1" | ||
}, | ||
"engines": { | ||
"node": ">=8.0.0" | ||
}, | ||
"main": "./dist/fabric.js", | ||
"dependencies": {} | ||
} | ||
"name": "fabric", | ||
"description": "Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.", | ||
"homepage": "http://fabricjs.com/", | ||
"version": "4.2.0-browser", | ||
"author": "Juriy Zaytsev <kangax@gmail.com>", | ||
"contributors": [ | ||
{ | ||
"name": "Andrea Bogazzi", | ||
"email": "andreabogazzi79@gmail.com" | ||
} | ||
], | ||
"keywords": [ | ||
"canvas", | ||
"graphic", | ||
"graphics", | ||
"SVG", | ||
"node-canvas", | ||
"parser", | ||
"HTML5", | ||
"object model" | ||
], | ||
"browser": { | ||
"canvas": false, | ||
"fs": false, | ||
"jsdom": false, | ||
"jsdom/lib/jsdom/living/generated/utils": false, | ||
"jsdom/lib/jsdom/utils": false, | ||
"http": false, | ||
"https": false, | ||
"xmldom": false, | ||
"url": false | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/fabricjs/fabric.js" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/fabricjs/fabric.js/issues" | ||
}, | ||
"license": "MIT", | ||
"scripts": { | ||
"build": "node build.js modules=ALL requirejs exclude=gestures,accessors", | ||
"build:fast": "node build.js modules=ALL requirejs fast exclude=gestures,accessors", | ||
"build:watch": "onchange 'src/**/**' 'HEADER.js' 'lib/**/**' -- npm run build_export", | ||
"link:watch": "onchange 'src/**/**' 'HEADER.js' 'lib/**/**' -- npm link", | ||
"build_with_gestures": "node build.js modules=ALL exclude=accessors", | ||
"build_export": "npm run build:fast && npm run export_dist_to_site && npm run build_with_gestures && npm run export_gesture_to_site", | ||
"test:single": "qunit test/node_test_setup.js test/lib", | ||
"test": "nyc qunit test/node_test_setup.js test/lib test/unit", | ||
"test:visual": "qunit test/node_test_setup.js test/lib test/visual", | ||
"test:visual:single": "qunit test/node_test_setup.js test/lib", | ||
"test:all": "npm run test && npm run test:visual", | ||
"lint": "eslint --config .eslintrc.json src", | ||
"lint_tests": "eslint test/unit --config .eslintrc_tests && eslint test/visual --config .eslintrc_tests", | ||
"export_gesture_to_site": "cp dist/fabric.js ../fabricjs.com/lib/fabric_with_gestures.js", | ||
"export_dist_to_site": "cp dist/fabric.js ../fabricjs.com/lib/fabric.js && cp package.json ../fabricjs.com/lib/package.json && cp -r src HEADER.js lib ../fabricjs.com/build/files/", | ||
"export_tests_to_site": "cp test/unit/*.js ../fabricjs.com/test/unit && cp -r test/visual/* ../fabricjs.com/test/visual && cp -r test/fixtures/* ../fabricjs.com/test/fixtures && cp -r test/lib/* ../fabricjs.com/test/lib", | ||
"all": "npm run build && npm run test && npm run test:visual && npm run lint && npm run lint_tests && npm run export_dist_to_site && npm run export_tests_to_site", | ||
"testem": "testem .", | ||
"testem:visual": "testem --file testem-visual.json", | ||
"testem:ci": "testem ci" | ||
}, | ||
"optionalDependencies": {}, | ||
"devDependencies": { | ||
"chalk": "^2.4.1", | ||
"eslint": "4.18.x", | ||
"nyc": "^15.1.0", | ||
"onchange": "^3.x.x", | ||
"pixelmatch": "^4.0.2", | ||
"qunit": "2.9.2", | ||
"testem": "^3.2.0", | ||
"uglify-js": "3.3.x" | ||
}, | ||
"engines": { | ||
"node": ">=8.0.0" | ||
}, | ||
"main": "./dist/fabric.js", | ||
"dependencies": {} | ||
} |
@@ -18,6 +18,2 @@ (function() { | ||
* @fires object:modified at the end of a transform or any change when statefull is true | ||
* @fires object:rotated at the end of a rotation transform | ||
* @fires object:scaled at the end of a scale transform | ||
* @fires object:moved at the end of translation transform | ||
* @fires object:skewed at the end of a skew transform | ||
* @fires object:rotating while an object is being rotated from the control | ||
@@ -52,2 +48,7 @@ * @fires object:scaling while an object is being scaled by controls | ||
* | ||
* the following events are deprecated: | ||
* @fires object:rotated at the end of a rotation transform | ||
* @fires object:scaled at the end of a scale transform | ||
* @fires object:moved at the end of translation transform | ||
* @fires object:skewed at the end of a skew transform | ||
*/ | ||
@@ -274,3 +275,7 @@ fabric.Canvas = fabric.util.createClass(fabric.StaticCanvas, /** @lends fabric.Canvas.prototype */ { | ||
/** | ||
* When true, target detection is skipped when hovering over canvas. This can be used to improve performance. | ||
* When true, target detection is skipped. Target detection will return always undefined. | ||
* click selection won't work anymore, events will fire with no targets. | ||
* if something is selected before setting it to true, it will be deselected at the first click. | ||
* area selection will still work. check the `selection` property too. | ||
* if you deactivate both, you should look into staticCanvas. | ||
* @type Boolean | ||
@@ -642,3 +647,4 @@ * @default | ||
var pointer = this.getPointer(e), corner = target.__corner, | ||
actionHandler = !!corner && target.controls[corner].getActionHandler(), | ||
actionHandler = (alreadySelected && corner) ? | ||
target.controls[corner].getActionHandler() : fabric.controlsUtils.dragHandler, | ||
action = this._getActionFromCorner(alreadySelected, corner, e, target), | ||
@@ -687,22 +693,2 @@ origin = this._getOriginFromCorner(target, corner), | ||
/** | ||
* Translates object by "setting" its left/top | ||
* @private | ||
* @param {Number} x pointer's x coordinate | ||
* @param {Number} y pointer's y coordinate | ||
* @return {Boolean} true if the translation occurred | ||
*/ | ||
_translateObject: function (x, y) { | ||
var transform = this._currentTransform, | ||
target = transform.target, | ||
newLeft = x - transform.offsetX, | ||
newTop = y - transform.offsetY, | ||
moveX = !target.get('lockMovementX') && target.left !== newLeft, | ||
moveY = !target.get('lockMovementY') && target.top !== newTop; | ||
moveX && target.set('left', newLeft); | ||
moveY && target.set('top', newTop); | ||
return moveX || moveY; | ||
}, | ||
/** | ||
* Set the cursor type of the canvas element | ||
@@ -709,0 +695,0 @@ * @param {String} value Cursor type of the canvas element. |
@@ -34,4 +34,5 @@ (function(global) { | ||
canvas = target.canvas, | ||
canasOptions = Object.assign({}, options, { target: target }); | ||
canvas && canvas.fire('object:' + eventName, canasOptions); | ||
canvasOptions = fabric.util.object.clone(options); | ||
canvasOptions.target = target; | ||
canvas && canvas.fire('object:' + eventName, canvasOptions); | ||
target.fire(eventName, options); | ||
@@ -144,3 +145,3 @@ } | ||
/** | ||
* Inspect event , control and fabricObject to return the correct action name | ||
* Inspect event, control and fabricObject to return the correct action name | ||
* @param {Event} eventData the javascript event that is causing the scale | ||
@@ -191,3 +192,3 @@ * @param {fabric.Control} control the control that is interested in the action | ||
* Wrap an action handler with saving/restoring object position on the transform. | ||
* this is the code that permits to obects to keep their position while transforming. | ||
* this is the code that permits to objects to keep their position while transforming. | ||
* @param {Function} actionHandler the function to wrap | ||
@@ -249,10 +250,10 @@ * @return {Function} a function with an action handler signature | ||
/** | ||
* Utility function to componsate the scale factor when skew is applied on both axes | ||
* Utility function to compensate the scale factor when skew is applied on both axes | ||
* @private | ||
*/ | ||
function compensateScaleForSkew(target, oppositeSkew, scaleToCompoensate, axis, reference) { | ||
function compensateScaleForSkew(target, oppositeSkew, scaleToCompensate, axis, reference) { | ||
if (target[oppositeSkew] !== 0) { | ||
var newDim = target._getTransformedDimensions()[axis]; | ||
var newValue = reference / newDim * target[scaleToCompoensate]; | ||
target.set(scaleToCompoensate, newValue); | ||
var newValue = reference / newDim * target[scaleToCompensate]; | ||
target.set(scaleToCompensate, newValue); | ||
} | ||
@@ -502,3 +503,3 @@ } | ||
/** | ||
* Basic scaling logic, reused with differnt constrain for scaling X,Y, freely or equally. | ||
* Basic scaling logic, reused with different constrain for scaling X,Y, freely or equally. | ||
* Needs to be wrapped with `wrapWithFixedAnchor` to be effective | ||
@@ -688,7 +689,35 @@ * @param {Event} eventData javascript event that is doing the transform | ||
multiplier = isTransformCentered(transform) ? 2 : 1, | ||
oldWidth = target.width, hasResized, | ||
newWidth = Math.abs(localPoint.x * multiplier / target.scaleX) - strokePadding; | ||
target.set('width', Math.max(newWidth, 0)); | ||
return true; | ||
hasResized = oldWidth !== newWidth; | ||
if (hasResized) { | ||
fireEvent('resizing', commonEventInfo(eventData, transform, x, y)); | ||
} | ||
return hasResized; | ||
} | ||
/** | ||
* Action handler | ||
* @private | ||
* @param {Event} eventData javascript event that is doing the transform | ||
* @param {Object} transform javascript object containing a series of information around the current transform | ||
* @param {number} x current mouse x position, canvas normalized | ||
* @param {number} y current mouse y position, canvas normalized | ||
* @return {Boolean} true if the translation occurred | ||
*/ | ||
function dragHandler(eventData, transform, x, y) { | ||
var target = transform.target, | ||
newLeft = x - transform.offsetX, | ||
newTop = y - transform.offsetY, | ||
moveX = !target.get('lockMovementX') && target.left !== newLeft, | ||
moveY = !target.get('lockMovementY') && target.top !== newTop; | ||
moveX && target.set('left', newLeft); | ||
moveY && target.set('top', newTop); | ||
if (moveX || moveY) { | ||
fireEvent('moving', commonEventInfo(eventData, transform, x, y)); | ||
} | ||
return moveX || moveY; | ||
} | ||
controls.scaleCursorStyleHandler = scaleCursorStyleHandler; | ||
@@ -706,2 +735,3 @@ controls.skewCursorStyleHandler = skewCursorStyleHandler; | ||
controls.skewHandlerY = skewHandlerY; | ||
controls.dragHandler = dragHandler; | ||
controls.scaleOrSkewActionName = scaleOrSkewActionName; | ||
@@ -708,0 +738,0 @@ controls.rotationStyleHandler = rotationStyleHandler; |
@@ -176,3 +176,3 @@ (function() { | ||
// side effects we added to it. | ||
if (!this.currentTransform && !this.findTarget(e)) { | ||
if (!this._currentTransform && !this.findTarget(e)) { | ||
this.fire('mouse:over', { target: null, e: e }); | ||
@@ -528,2 +528,6 @@ this._hoveredTarget = null; | ||
}; | ||
if (eventType === 'up') { | ||
options.currentTarget = this.findTarget(e); | ||
options.currentSubTargets = this.targets; | ||
} | ||
this.fire('mouse:' + eventType, options); | ||
@@ -549,2 +553,3 @@ target && target.fire('mouse' + eventType, options); | ||
transform: transform, | ||
action: transform.action, | ||
}; | ||
@@ -560,2 +565,4 @@ | ||
if (transform.actionPerformed) { | ||
// this is not friendly to the new control api. | ||
// is deprecated. | ||
eventName = this._addEventOptions(options, transform); | ||
@@ -571,2 +578,3 @@ this._fire(eventName, options); | ||
* @private | ||
* @deprecated since 4.2.0 | ||
* @param {Object} options to mutate | ||
@@ -938,20 +946,11 @@ * @param {Object} transform to inspect action from | ||
actionPerformed = false, | ||
actionHandler = transform.actionHandler, | ||
actionHandler = transform.actionHandler; | ||
// this object could be created from the function in the control handlers | ||
options = { | ||
target: transform.target, | ||
e: e, | ||
transform: transform, | ||
pointer: pointer | ||
}; | ||
if (action === 'drag') { | ||
actionPerformed = this._translateObject(x, y); | ||
if (actionPerformed) { | ||
this._fire('moving', options); | ||
this.setCursor(options.target.moveCursor || this.moveCursor); | ||
} | ||
if (actionHandler) { | ||
actionPerformed = actionHandler(e, transform, x, y); | ||
} | ||
else if (actionHandler) { | ||
(actionPerformed = actionHandler(e, transform, x, y)) && this._fire(action, options); | ||
if (action === 'drag' && actionPerformed) { | ||
this.setCursor(transform.target.moveCursor || this.moveCursor); | ||
} | ||
@@ -958,0 +957,0 @@ transform.actionPerformed = transform.actionPerformed || actionPerformed; |
@@ -249,3 +249,3 @@ (function(global) { | ||
commaWsp = '(?:\\s+,?\\s*|,\\s*)', | ||
commaWsp = fabric.commaWsp, | ||
@@ -252,0 +252,0 @@ skewX = '(?:(skewX)\\s*\\(\\s*(' + number + ')\\s*\\))', |
@@ -593,2 +593,8 @@ (function() { | ||
re = fabric.rePathCommand, | ||
rNumber = '[-+]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][-+]?\\d+)?\\s*', | ||
rNumberCommaWsp = '(' + rNumber + ')' + fabric.commaWsp, | ||
rFlagCommaWsp = '([01])' + fabric.commaWsp + '?', | ||
rArcSeq = rNumberCommaWsp + '?' + rNumberCommaWsp + '?' + rNumberCommaWsp + rFlagCommaWsp + rFlagCommaWsp + | ||
rNumberCommaWsp + '?(' + rNumber + ')', | ||
regArcArgumentSequence = new RegExp(rArcSeq, 'g'), | ||
match, | ||
@@ -609,8 +615,19 @@ coordsStr, | ||
while ((match = re.exec(coordsStr))) { | ||
coords.push(match[0]); | ||
var command = currentPath.charAt(0); | ||
coordsParsed = [command]; | ||
if (command.toLowerCase() === 'a') { | ||
// arcs have special flags that apparently don't require spaces so handle special | ||
for (var args; (args = regArcArgumentSequence.exec(coordsStr));) { | ||
for (var j = 1; j < args.length; j++) { | ||
coords.push(args[j]); | ||
} | ||
} | ||
} | ||
else { | ||
while ((match = re.exec(coordsStr))) { | ||
coords.push(match[0]); | ||
} | ||
} | ||
coordsParsed = [currentPath.charAt(0)]; | ||
for (var j = 0, jlen = coords.length; j < jlen; j++) { | ||
@@ -623,4 +640,3 @@ parsed = parseFloat(coords[j]); | ||
var command = coordsParsed[0], | ||
commandLength = commandLengths[command.toLowerCase()], | ||
var commandLength = commandLengths[command.toLowerCase()], | ||
repeatedCommand = repeatedCommands[command] || command; | ||
@@ -627,0 +643,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
2445290
0
57196
2