-
-
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
patch(TS): canvas patch init 2 #8520
Changes from 21 commits
7c83395
fdf9245
aa0b140
6c02e74
84541aa
135ef2a
54e6351
5ba11af
47d717b
305d6e8
1c577f3
286967c
efcf9f1
644f94f
c31e5d7
281b831
9818c73
143c4cc
a9c7c7a
fe21142
4971d73
2abdf9a
9ca6002
f5e96ca
cba9325
6e1ddc1
359606c
65afac6
b27ac06
fadd45f
95cc420
a1e89a7
1d848ee
15c8bf7
a3caeac
7c4910d
d8557f3
e6148fc
e1ffe0c
9d19204
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -271,10 +271,7 @@ export class StaticCanvas< | |
* in order to return it to original state on dispose | ||
* @type string | ||
*/ | ||
_originalCanvasStyle?: string; | ||
|
||
renderAndResetBound: () => void; | ||
requestRenderAllBound: () => void; | ||
private _originalCanvasStyle?: string; | ||
|
||
_offset: { left: number; top: number }; | ||
protected hasLostContext: boolean; | ||
|
@@ -286,6 +283,22 @@ export class StaticCanvas< | |
kill: (reason?: any) => void; | ||
}; | ||
|
||
constructor(el: string | HTMLCanvasElement, options = {}) { | ||
super(); | ||
this.renderAndReset = this.renderAndReset.bind(this); | ||
this.requestRenderAll = this.requestRenderAll.bind(this); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these were renamed, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes yes i have read everything i was in the middle of things and then i had to go to bed. |
||
this.initElements(el); | ||
this._initOptions(options); | ||
this.calcOffset(); | ||
this._initRetinaScaling(); | ||
this.calcViewportBoundaries(); | ||
} | ||
|
||
protected initElements(el: string | HTMLCanvasElement) { | ||
this._createLowerCanvas(el); | ||
this._originalCanvasStyle = this.lowerCanvasEl.style.cssText; | ||
} | ||
|
||
add(...objects: FabricObject[]) { | ||
const size = super.add(...objects); | ||
objects.length > 0 && this.renderOnAddRemove && this.requestRenderAll(); | ||
|
@@ -332,37 +345,6 @@ export class StaticCanvas< | |
this.renderOnAddRemove && this.requestRenderAll(); | ||
} | ||
|
||
constructor(el: string | HTMLCanvasElement, options = {}) { | ||
super(); | ||
this._init(el, options); | ||
} | ||
|
||
/** | ||
* @private | ||
* @param {HTMLCanvasElement | String} el <canvas> element to initialize instance on | ||
* @param {Object} [options] Options object | ||
*/ | ||
_init(el: string | HTMLCanvasElement, options = {}) { | ||
this.renderAndResetBound = this.renderAndReset.bind(this); | ||
this.requestRenderAllBound = this.requestRenderAll.bind(this); | ||
this._initStatic(el, options); | ||
this._initRetinaScaling(); | ||
this.calcViewportBoundaries(); | ||
} | ||
|
||
/** | ||
* @private | ||
* @param {HTMLCanvasElement | String} el <canvas> element to initialize instance on | ||
* @param {Object} [options] Options object | ||
*/ | ||
_initStatic(el: string | HTMLCanvasElement, options = {}) { | ||
this._objects = []; | ||
this._createLowerCanvas(el); | ||
this._originalCanvasStyle = this.lowerCanvasEl.style.cssText; | ||
this._initOptions(options); | ||
this.calcOffset(); | ||
} | ||
|
||
/** | ||
* @private | ||
*/ | ||
|
@@ -727,7 +709,7 @@ export class StaticCanvas< | |
*/ | ||
requestRenderAll() { | ||
if (!this.nextRenderHandle && !this.disposed && !this.destroyed) { | ||
this.nextRenderHandle = requestAnimFrame(this.renderAndResetBound); | ||
this.nextRenderHandle = requestAnimFrame(this.renderAndReset); | ||
} | ||
} | ||
|
||
|
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.
dropped