Skip to content

Commit

Permalink
fixed conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
asturur committed Jul 30, 2022
2 parents dad9996 + 37d5c9c commit d69e3dd
Show file tree
Hide file tree
Showing 35 changed files with 1,240 additions and 343 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"Buffer": true,
"process": true,
"QUnit": true,
"assert": true
"assert": true,
"AbortController": true
},
"overrides": [
{
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/node-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [14.x, 16.x]
node-version: [16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/visual-node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [14.x, 16.x]
node-version: [16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v2
Expand Down
42 changes: 40 additions & 2 deletions src/canvas.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,42 @@
* @fires dragover
* @fires dragenter
* @fires dragleave
* @fires drop:before before drop event. same native event. This is added to handle edge cases
* @fires drag:enter object drag enter
* @fires drag:leave object drag leave
* @fires drop:before before drop event. Prepare for the drop event (same native event).
* @fires drop
* @fires drop:after after drop event. Run logic on canvas after event has been accepted/declined (same native event).
* @example
* let a: fabric.Object, b: fabric.Object;
* let flag = false;
* canvas.add(a, b);
* a.on('drop:before', opt => {
* // we want a to accept the drop even though it's below b in the stack
* flag = this.canDrop(opt.e);
* });
* b.canDrop = function(e) {
* !flag && this.callSuper('canDrop', e);
* }
* b.on('dragover', opt => b.set('fill', opt.dropTarget === b ? 'pink' : 'black'));
* a.on('drop', opt => {
* opt.e.defaultPrevented // drop occured
* opt.didDrop // drop occured on canvas
* opt.target // drop target
* opt.target !== a && a.set('text', 'I lost');
* });
* canvas.on('drop:after', opt => {
* // inform user who won
* if(!opt.e.defaultPrevented) {
* // no winners
* }
* else if(!opt.didDrop) {
* // my objects didn't win, some other lucky object
* }
* else {
* // we have a winner it's opt.target!!
* }
* })
*
* @fires after:render at the end of the render process, receives the context in the callback
* @fires before:render at start the render process, receives the context in the callback
*
Expand Down Expand Up @@ -1024,6 +1058,7 @@

this._copyCanvasStyle(lowerCanvasEl, upperCanvasEl);
this._applyCanvasStyle(upperCanvasEl);
upperCanvasEl.setAttribute('draggable', 'true');
this.contextTop = upperCanvasEl.getContext('2d');
},

Expand Down Expand Up @@ -1232,7 +1267,7 @@
/**
* This is a private method for now.
* This is supposed to be equivalent to discardActiveObject but without firing
* any events. There is commitment to have this stay this way.
* any selection events ( can still fire object transformation events ). There is commitment to have this stay this way.
* This is the functional part of discardActiveObject.
* @param {Event} [e] Event (passed along when firing "object:deselected")
* @param {Object} object to set as active
Expand All @@ -1246,6 +1281,9 @@
if (obj.onDeselect({ e: e, object: object })) {
return false;
}
if (this._currentTransform && this._currentTransform.target === obj) {
this.endCurrentTransform(e);
}
this._activeObject = null;
}
return true;
Expand Down
8 changes: 5 additions & 3 deletions src/filters/blendimage_filter.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,13 @@
/**
* Create filter instance from an object representation
* @static
* @param {Object} object Object to create an instance from
* @param {object} object Object to create an instance from
* @param {object} [options]
* @param {AbortSignal} [options.signal] handle aborting image loading, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal
* @returns {Promise<fabric.Image.filters.BlendImage>}
*/
fabric.Image.filters.BlendImage.fromObject = function(object) {
return fabric.Image.fromObject(object.image).then(function(image) {
fabric.Image.filters.BlendImage.fromObject = function(object, options) {
return fabric.Image.fromObject(object.image, options).then(function(image) {
return new fabric.Image.filters.BlendImage(Object.assign({}, object, { image: image }));
});
};
Expand Down
9 changes: 7 additions & 2 deletions src/filters/composed_filter.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,16 @@

/**
* Deserialize a JSON definition of a ComposedFilter into a concrete instance.
* @static
* @param {oject} object Object to create an instance from
* @param {object} [options]
* @param {AbortSignal} [options.signal] handle aborting `BlendImage` filter loading, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal
* @returns {Promise<fabric.Image.filters.Composed>}
*/
fabric.Image.filters.Composed.fromObject = function(object) {
fabric.Image.filters.Composed.fromObject = function(object, options) {
var filters = object.subFilters || [];
return Promise.all(filters.map(function(filter) {
return fabric.Image.filters[filter.type].fromObject(filter);
return fabric.Image.filters[filter.type].fromObject(filter, options);
})).then(function(enlivedFilters) {
return new fabric.Image.filters.Composed({ subFilters: enlivedFilters });
});
Expand Down
Loading

0 comments on commit d69e3dd

Please sign in to comment.