-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(TS): object mixins #8414
chore(TS): object mixins #8414
Conversation
commit f9071cf Author: ShaMan123 <[email protected]> Date: Mon Oct 31 21:52:32 2022 +0200 Update transform_files.mjs commit 6ebf5ff Author: ShaMan123 <[email protected]> Date: Mon Oct 31 20:31:18 2022 +0200 Update transform_files.mjs commit 6433c0b Author: ShaMan123 <[email protected]> Date: Mon Oct 31 20:09:43 2022 +0200 Update transform_files.mjs commit 5793489 Author: ShaMan123 <[email protected]> Date: Mon Oct 31 20:01:55 2022 +0200 Update transform_files.mjs commit 06a12b0 Author: ShaMan123 <[email protected]> Date: Mon Oct 31 19:39:23 2022 +0200 Update transform_files.mjs commit 4111587 Author: ShaMan123 <[email protected]> Date: Mon Oct 31 19:37:41 2022 +0200 Create out.ts commit a2f29c0 Author: ShaMan123 <[email protected]> Date: Mon Oct 31 18:56:48 2022 +0200 Update transform_files.mjs commit 6587d19 Author: ShaMan123 <[email protected]> Date: Mon Oct 31 18:49:32 2022 +0200 Update transform_files.mjs commit c3bf999 Author: ShaMan123 <[email protected]> Date: Mon Oct 31 18:45:46 2022 +0200 Update transform_files.mjs commit 8105167 Author: ShaMan123 <[email protected]> Date: Mon Oct 31 18:37:17 2022 +0200 Update transform_files.mjs commit b8de8aa Author: ShaMan123 <[email protected]> Date: Mon Oct 31 18:34:27 2022 +0200 Update transform_files.mjs commit 2d1d1da Author: ShaMan123 <[email protected]> Date: Mon Oct 31 18:22:47 2022 +0200 Update transform_files.mjs commit 781fe55 Author: ShaMan123 <[email protected]> Date: Mon Oct 31 18:18:01 2022 +0200 Update transform_files.mjs commit daf443f Author: ShaMan123 <[email protected]> Date: Mon Oct 31 18:16:48 2022 +0200 Update transform_files.mjs commit 3c55455 Author: ShaMan123 <[email protected]> Date: Mon Oct 31 17:41:30 2022 +0200 Update transform_files.mjs commit f567fcf Author: ShaMan123 <[email protected]> Date: Mon Oct 31 17:24:54 2022 +0200 Update transform_files.mjs commit 9ab2ea3 Author: ShaMan123 <[email protected]> Date: Mon Oct 31 17:16:13 2022 +0200 Update transform_files.mjs commit b3c73d1 Author: ShaMan123 <[email protected]> Date: Mon Oct 31 17:10:30 2022 +0200 Update transform_files.mjs commit f6d9031 Author: ShaMan123 <[email protected]> Date: Mon Oct 31 16:51:10 2022 +0200 Update transform_files.mjs commit 6208499 Author: ShaMan123 <[email protected]> Date: Mon Oct 31 15:51:00 2022 +0200 Update transform_files.mjs commit 483379a Author: ShaMan123 <[email protected]> Date: Mon Oct 31 13:38:10 2022 +0200 static commit 316ba1a Author: ShaMan123 <[email protected]> Date: Mon Oct 31 13:28:03 2022 +0200 Update transform_files.mjs commit bcb3124 Author: ShaMan123 <[email protected]> Date: Mon Oct 31 12:00:43 2022 +0200 Update transform_files.mjs commit 1d555ad Author: ShaMan123 <[email protected]> Date: Mon Oct 31 11:53:37 2022 +0200 Update transform_files.mjs commit 5a04341 Author: ShaMan123 <[email protected]> Date: Mon Oct 31 11:38:11 2022 +0200 Update transform_files.mjs commit 322c271 Author: ShaMan123 <[email protected]> Date: Mon Oct 31 10:13:37 2022 +0200 Update transform_files.mjs commit 9b7f6f9 Author: ShaMan123 <[email protected]> Date: Mon Oct 31 09:57:55 2022 +0200 Update transform_files.mjs commit e86aa95 Author: ShaMan123 <[email protected]> Date: Mon Oct 31 08:32:27 2022 +0200 Update transform_files.mjs commit f23227f Author: ShaMan123 <[email protected]> Date: Mon Oct 31 08:26:14 2022 +0200 ast!
This reverts commit a1db53e.
Build Stats
|
i have a bunch of questions about the overlap of ancestry and stacking. Does ancestry have any usefulness outside the interactivity with activeSelection and group in general? |
That was a bad attempt I forgot to revert |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ready
src/shapes/fabricObject.class.ts
Outdated
|
||
// TODO somehow we have to make a tree-shakeable import | ||
|
||
applyMixins(InteractiveFabricObject, [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not bad
Though we can chain them with extends... like geometry and interactivity
Or we can make all use this pattern.
) { | ||
constructors.forEach((baseCtor) => { | ||
Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => { | ||
name !== 'constructor' && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed!
No constructor overrides!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Conflicts have been addressed
Does ancestry have any usefulness outside the interactivity with activeSelection and group in general?
I think so. It is useful in some cases. And since Group is now a powerful object I guess more use cases will emerge and with it needs to probe the object tree.
IMO the stacking/ancestry mixins should be part of the prototype chain of FabricObject, perhaps the rest as well. SVG can be left as a dynamic mixin.
But the decision will not be breaking so we can move forward and consolidate it afterwards.
Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
combined animation mixin with straightening since both animate object.
Must say that the animation mixin is a vile piece of work.
src/mixins/object_stacking.mixin.ts
will be removed in #8461 , kept only for tests
|
||
to = to.toString(); | ||
if (!propIsColor) { | ||
if (~to.indexOf('=')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this?
I want to simplify it but I have no idea what it does
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can/should be done in a follow up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the ancestor of to.includes('=')
the tilde is a binary not operator, so bascially since -1
https://wsvincent.com/javascript-tilde/
how old was this line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
// TODO somehow we have to make a tree-shakeable import | ||
|
||
export { InteractiveFabricObject as FabricObject }; | ||
export class FabricObject extends applyMixins(InteractiveFabricObject, [ | ||
FabricObjectSVGExportMixin, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we put the svg mixin in the proto chain as well?
* @param {String} to Value to animate to | ||
* @param {Object} [options] Options object | ||
*/ | ||
_animate<T>(key: string, to: T, options: TAnimationOptions = {}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method is so ugly
Once #8297 is merged I will rework this mixin to use an array animation perhaps... with color somehow
@ShaMan123 i m merging because nothing struck me here. |
Co-authored-by: Andrea Bogazzi <[email protected]>
Motivation
Description
This PR migrates all remaining object mixins.
I had to split files that defined both canvas and object mixins. The canvas mixins were left untouched.
I tried a different approach in this PR, using
applyMixins
.My conclusion is that we should avoid it. It is fragile and TS doesn't stomach it well.
I prefer the approach of collection mixin or chaining classes.
For dynamic protos like with SVG
applyMixins
is fine.Changes
Gist
As long as a mixin doesn't have a constructor or a super class applyMixins works as expected
I had to disable constructor assigning since it overrides the prev.
But I guess there is a way to merge them, I can't think of a mixin which needs it
In Action