Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
Canvas
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sc07
Canvas
Commits
ed97f664
Commit
ed97f664
authored
8 months ago
by
Grant
Browse files
Options
Downloads
Patches
Plain Diff
be more aggressive with loading canvas renderer
parent
0282576f
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
packages/client/src/lib/canvas.ts
+13
-5
13 additions, 5 deletions
packages/client/src/lib/canvas.ts
with
13 additions
and
5 deletions
packages/client/src/lib/canvas.ts
+
13
−
5
View file @
ed97f664
...
@@ -36,7 +36,7 @@ export class Canvas extends EventEmitter<CanvasEvents> {
...
@@ -36,7 +36,7 @@ export class Canvas extends EventEmitter<CanvasEvents> {
lastPlace
:
number
|
undefined
;
lastPlace
:
number
|
undefined
;
private
bypassCooldown
=
false
;
private
bypassCooldown
=
false
;
private
_delayedLoad
:
ReturnType
<
typeof
setTimeout
>
;
//
private _delayedLoad: ReturnType<typeof setTimeout>;
constructor
(
canvas
:
HTMLCanvasElement
,
PanZoom
:
PanZoom
)
{
constructor
(
canvas
:
HTMLCanvasElement
,
PanZoom
:
PanZoom
)
{
super
();
super
();
...
@@ -47,7 +47,7 @@ export class Canvas extends EventEmitter<CanvasEvents> {
...
@@ -47,7 +47,7 @@ export class Canvas extends EventEmitter<CanvasEvents> {
this
.
canvas
=
canvas
;
this
.
canvas
=
canvas
;
this
.
PanZoom
=
PanZoom
;
this
.
PanZoom
=
PanZoom
;
this
.
_delayedLoad
=
setTimeout
(()
=>
this
.
delayedLoad
(),
1000
);
this
.
loadRenderer
(
);
this
.
PanZoom
.
addListener
(
"
hover
"
,
this
.
handleMouseMove
.
bind
(
this
));
this
.
PanZoom
.
addListener
(
"
hover
"
,
this
.
handleMouseMove
.
bind
(
this
));
this
.
PanZoom
.
addListener
(
"
click
"
,
this
.
handleMouseDown
.
bind
(
this
));
this
.
PanZoom
.
addListener
(
"
click
"
,
this
.
handleMouseDown
.
bind
(
this
));
...
@@ -63,7 +63,6 @@ export class Canvas extends EventEmitter<CanvasEvents> {
...
@@ -63,7 +63,6 @@ export class Canvas extends EventEmitter<CanvasEvents> {
destroy
()
{
destroy
()
{
getRenderer
().
stopRender
();
getRenderer
().
stopRender
();
getRenderer
().
off
(
"
ready
"
);
getRenderer
().
off
(
"
ready
"
);
if
(
this
.
_delayedLoad
)
clearTimeout
(
this
.
_delayedLoad
);
this
.
PanZoom
.
removeListener
(
"
hover
"
,
this
.
handleMouseMove
.
bind
(
this
));
this
.
PanZoom
.
removeListener
(
"
hover
"
,
this
.
handleMouseMove
.
bind
(
this
));
this
.
PanZoom
.
removeListener
(
"
click
"
,
this
.
handleMouseDown
.
bind
(
this
));
this
.
PanZoom
.
removeListener
(
"
click
"
,
this
.
handleMouseDown
.
bind
(
this
));
...
@@ -75,9 +74,18 @@ export class Canvas extends EventEmitter<CanvasEvents> {
...
@@ -75,9 +74,18 @@ export class Canvas extends EventEmitter<CanvasEvents> {
/**
/**
* React.Strict remounts the main component, causing a quick remount, which then causes errors related to webworkers
* React.Strict remounts the main component, causing a quick remount, which then causes errors related to webworkers
*
* If #useCanvas fails, it's most likely due to that
*/
*/
delayedLoad
()
{
loadRenderer
()
{
getRenderer
().
useCanvas
(
this
.
canvas
,
"
main
"
);
try
{
getRenderer
().
useCanvas
(
this
.
canvas
,
"
main
"
);
}
catch
(
e
)
{
console
.
warn
(
"
[Canvas#loadRenderer] Failed at #useCanvas, this shouldn't be fatal
"
,
e
);
}
}
}
setSize
(
width
:
number
,
height
:
number
)
{
setSize
(
width
:
number
,
height
:
number
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment