Skip to content

Commit

Permalink
docs() Updates to documentation (fabricjs#6726)
Browse files Browse the repository at this point in the history
  • Loading branch information
asturur authored and shanicerae committed Jan 16, 2021
1 parent 18b6b18 commit fea9608
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 35 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
# Changelog

## [4.3.0]

- fix(fabric.Textbox): Do not let splitbygrapheme split text previously unwrapped [#6621](https://github.com/fabricjs/fabric.js/pull/6621)
- feat(fabric.controlsUtils) Move drag to actions to control handlers [#6617](https://github.com/fabricjs/fabric.js/pull/6617)
- feat(fabric.Control): Add custom control size per control. [#6562](https://github.com/fabricjs/fabric.js/pull/6562)
- fix(svg_export): svg export in path with gradient and added tests [#6654](https://github.com/fabricjs/fabric.js/pull/6654)
- fix(fabric.Text): improve compatibility with transformed gradients [#6669](https://github.com/fabricjs/fabric.js/pull/6669)
- feat(fabric.Text): Add ability to put text on paths BETA [#6543](https://github.com/fabricjs/fabric.js/pull/6543)
- fix(fabric.Canvas): rotation handle should take origin into account [#6686](https://github.com/fabricjs/fabric.js/pull/6686)

## [4.2.0]

- fix(fabric.utils): ISSUE-6566 Fix SVGs for special Arc lines [#6571](https://github.com/fabricjs/fabric.js/pull/6571)
- fix(fabric.Canvas): Fix mouse up target when different from action start [#6591](https://github.com/fabricjs/fabric.js/pull/6591)
- added: feat(fabric.controlsUtils): Fire resizing event for textbox width [#6545](https://github.com/fabricjs/fabric.js/pull/6545)
- added: feat(fabric.controlsUtils) Move drag to actions to control handlers [#6617](https://github.com/fabricjs/fabric.js/pull/6617)

## [4.1.0]
- feat(Brushes): add beforePathCreated event [#6492](https://github.com/fabricjs/fabric.js/pull/6492);
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![Build Status](https://secure.travis-ci.org/fabricjs/fabric.js.svg?branch=master)](http://travis-ci.org/#!/kangax/fabric.js)
[![Code Climate](https://d3s6mut3hikguw.cloudfront.net/github/kangax/fabric.js/badges/gpa.svg)](https://codeclimate.com/github/kangax/fabric.js)
[![Coverage Status](https://coveralls.io/repos/fabricjs/fabric.js/badge.png?branch=master)](https://coveralls.io/r/kangax/fabric.js?branch=master)
[![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/fabricjs/fabric.js)
[![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/fabricjs/fabric.js)

<!-- npm, bower, CDNJS versions, downloads -->

Expand Down Expand Up @@ -51,11 +51,12 @@ Fabric.js allows you to easily create simple shapes like rectangles, circles, tr

### Supported browsers

- Firefox 2+
- Safari 3+
- Firefox 4+
- Safari 5+
- Opera 9.64+
- Chrome (all versions)
- IE10, IE11, Edge
- Edge (chromium based, all versions)
- IE11 and Edge legacy, supported but deprecated.

You can [run automated unit tests](http://fabricjs.com/test/unit/) right in the browser.

Expand All @@ -76,7 +77,7 @@ Please follow the instructions located [here](https://github.com/Automattic/node


$ npm install fabric --save


After this, you can import fabric like so:

Expand Down
3 changes: 2 additions & 1 deletion src/canvas.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -637,8 +637,9 @@
}

var pointer = this.getPointer(e), corner = target.__corner,
control = target.controls[corner],
actionHandler = (alreadySelected && corner) ?
target.controls[corner].getActionHandler() : fabric.controlsUtils.dragHandler,
control.getActionHandler(e, target, control) : fabric.controlsUtils.dragHandler,
action = this._getActionFromCorner(alreadySelected, corner, e, target),
origin = this._getOriginFromCorner(target, corner),
altKey = e[this.centeredKey],
Expand Down
41 changes: 22 additions & 19 deletions src/control.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,46 +138,49 @@
* The control actionHandler, provide one to handle action ( control being moved )
* @param {Event} eventData the native mouse event
* @param {Object} transformData properties of the current transform
* @param {fabric.Object} object on which the control is displayed
* @return {Function}
* @param {Number} x x position of the cursor
* @param {Number} y y position of the cursor
* @return {Boolean} true if the action/event modified the object
*/
actionHandler: function(/* eventData, transformData, fabricObject */) { },
actionHandler: function(/* eventData, transformData, x, y */) { },

/**
* The control handler for mouse down, provide one to handle mouse down on control
* @param {Event} eventData the native mouse event
* @param {Object} transformData properties of the current transform
* @param {fabric.Object} object on which the control is displayed
* @return {Function}
* @param {Number} x x position of the cursor
* @param {Number} y y position of the cursor
* @return {Boolean} true if the action/event modified the object
*/
mouseDownHandler: function(/* eventData, transformData, fabricObject */) { },
mouseDownHandler: function(/* eventData, transformData, x, y */) { },

/**
* The control mouseUpHandler, provide one to handle an effect on mouse up.
* @param {Event} eventData the native mouse event
* @param {Object} transformData properties of the current transform
* @param {fabric.Object} object on which the control is displayed
* @return {Function}
* @param {Number} x x position of the cursor
* @param {Number} y y position of the cursor
* @return {Boolean} true if the action/event modified the object
*/
mouseUpHandler: function(/* eventData, transformData, fabricObject */) { },
mouseUpHandler: function(/* eventData, transformData, x, y */) { },

/**
* Returns control actionHandler
* @param {Event} eventData the native mouse event
* @param {Object} transformData properties of the current transform
* @param {fabric.Object} object on which the control is displayed
* @return {Function}
* @param {fabric.Object} fabricObject on which the control is displayed
* @param {fabric.Control} control control for which the action handler is being asked
* @return {Function} the action handler
*/
getActionHandler: function(/* eventData, transformData, fabricObject */) {
getActionHandler: function(/* eventData, fabricObject, control */) {
return this.actionHandler;
},

/**
* Returns control mouseDown handler
* @param {Event} eventData the native mouse event
* @param {Object} transformData properties of the current transform
* @param {fabric.Object} object on which the control is displayed
* @return {Function}
* @param {fabric.Object} fabricObject on which the control is displayed
* @param {fabric.Control} control control for which the action handler is being asked
* @return {Function} the action handler
*/
getMouseDownHandler: function(/* eventData, fabricObject, control */) {
return this.mouseDownHandler;
Expand All @@ -186,9 +189,9 @@
/**
* Returns control mouseUp handler
* @param {Event} eventData the native mouse event
* @param {Object} transformData properties of the current transform
* @param {fabric.Object} object on which the control is displayed
* @return {Function}
* @param {fabric.Object} fabricObject on which the control is displayed
* @param {fabric.Control} control control for which the action handler is being asked
* @return {Function} the action handler
*/
getMouseUpHandler: function(/* eventData, fabricObject, control */) {
return this.mouseUpHandler;
Expand Down
8 changes: 5 additions & 3 deletions src/mixins/canvas_events.mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,8 @@
var control = target.controls[corner],
mouseUpHandler = control && control.getMouseUpHandler(e, target, control);
if (mouseUpHandler) {
mouseUpHandler(e, target, control);
var pointer = this.getPointer(e);
mouseUpHandler(e, transform, pointer.x, pointer.y);
}
target.isMoving = false;
}
Expand Down Expand Up @@ -723,12 +724,13 @@
);
target.__corner = corner;
if (target === this._activeObject && (corner || !shouldGroup)) {
this._setupCurrentTransform(e, target, alreadySelected);
var control = target.controls[corner],
pointer = this.getPointer(e),
mouseDownHandler = control && control.getMouseDownHandler(e, target, control);
if (mouseDownHandler) {
mouseDownHandler(e, target, control);
mouseDownHandler(e, this._currentTransform, pointer.x, pointer.y);
}
this._setupCurrentTransform(e, target, alreadySelected);
}
}
this._handleEvent(e, 'down');
Expand Down
2 changes: 1 addition & 1 deletion src/mixins/object_geometry.mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@
},

/**
* Sets corner position coordinates based on current angle, width and height.
* Sets corner and controls position coordinates based on current angle, width and height, left and top.
* oCoords are used to find the corners
* aCoords are used to quickly find an object on the canvas
* lineCoords are used to quickly find object during pointer events.
Expand Down
10 changes: 7 additions & 3 deletions src/shapes/object.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -1645,11 +1645,15 @@

/**
* Creates an instance of fabric.Image out of an object
* could make use of both toDataUrl or toCanvasElement.
* makes use of toCanvasElement.
* Once this method was based on toDataUrl and loadImage, so it also had a quality
* and format option. toCanvasElement is faster and produce no loss of quality.
* If you need to get a real Jpeg or Png from an object, using toDataURL is the right way to do it.
* toCanvasElement and then toBlob from the obtained canvas is also a good option.
* This method is sync now, but still support the callback because we did not want to break.
* When fabricJS 5.0 will be planned, this will probably be changed to not have a callback.
* @param {Function} callback callback, invoked with an instance as a first argument
* @param {Object} [options] for clone as image, passed to toDataURL
* @param {String} [options.format=png] The format of the output image. Either "jpeg" or "png"
* @param {Number} [options.quality=1] Quality level (0..1). Only used for jpeg.
* @param {Number} [options.multiplier=1] Multiplier to scale by
* @param {Number} [options.left] Cropping left offset. Introduced in v1.2.14
* @param {Number} [options.top] Cropping top offset. Introduced in v1.2.14
Expand Down
7 changes: 5 additions & 2 deletions src/static_canvas.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -1814,10 +1814,13 @@
});

/**
* Returns JSON representation of canvas
* Returns Object representation of canvas
* this alias is provided because if you call JSON.stringify on an instance,
* the toJSON object will be invoked if it exists.
* Having a toJSON method means you can do JSON.stringify(myCanvas)
* @function
* @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output
* @return {String} JSON string
* @return {Object} JSON compatible object
* @tutorial {@link http://fabricjs.com/fabric-intro-part-3#serialization}
* @see {@link http://jsfiddle.net/fabricjs/pec86/|jsFiddle demo}
* @example <caption>JSON without additional properties</caption>
Expand Down

0 comments on commit fea9608

Please sign in to comment.