mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-09-22 08:50:56 +02:00
Compare commits
5 Commits
dependabot
...
zsviczian-
Author | SHA1 | Date | |
---|---|---|---|
![]() |
60a3584e86 | ||
![]() |
fa0e653236 | ||
![]() |
16de3d9243 | ||
![]() |
c65d6506f7 | ||
![]() |
a249f332a2 |
@@ -91,7 +91,7 @@ export class LaserPathManager {
|
|||||||
private collaboratorsState: Map<string, CollabolatorState> = new Map();
|
private collaboratorsState: Map<string, CollabolatorState> = new Map();
|
||||||
|
|
||||||
private rafId: number | undefined;
|
private rafId: number | undefined;
|
||||||
private lastUpdate = 0;
|
private isDrawing = false;
|
||||||
private container: SVGSVGElement | undefined;
|
private container: SVGSVGElement | undefined;
|
||||||
|
|
||||||
constructor(private app: App) {
|
constructor(private app: App) {
|
||||||
@@ -100,12 +100,19 @@ export class LaserPathManager {
|
|||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
this.stop();
|
this.stop();
|
||||||
this.lastUpdate = 0;
|
this.isDrawing = false;
|
||||||
this.ownState = instantiateCollabolatorState();
|
this.ownState = instantiateCollabolatorState();
|
||||||
this.collaboratorsState = new Map();
|
this.collaboratorsState = new Map();
|
||||||
}
|
}
|
||||||
|
|
||||||
startPath(x: number, y: number) {
|
startPath(x: number, y: number) {
|
||||||
|
if (this.container) {
|
||||||
|
this.container.style.top = "0px";
|
||||||
|
this.container.style.left = "0px";
|
||||||
|
const { x, y } = this.container.getBoundingClientRect();
|
||||||
|
this.container.style.top = `${-y}px`;
|
||||||
|
this.container.style.left = `${-x}px`;
|
||||||
|
}
|
||||||
this.ownState.currentPath = instantiatePath();
|
this.ownState.currentPath = instantiatePath();
|
||||||
this.ownState.currentPath.addPoint([x, y, performance.now()]);
|
this.ownState.currentPath.addPoint([x, y, performance.now()]);
|
||||||
this.updatePath(this.ownState);
|
this.updatePath(this.ownState);
|
||||||
@@ -127,7 +134,7 @@ export class LaserPathManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private updatePath(state: CollabolatorState) {
|
private updatePath(state: CollabolatorState) {
|
||||||
this.lastUpdate = performance.now();
|
this.isDrawing = true;
|
||||||
|
|
||||||
if (!this.isRunning) {
|
if (!this.isRunning) {
|
||||||
this.start();
|
this.start();
|
||||||
@@ -160,7 +167,7 @@ export class LaserPathManager {
|
|||||||
|
|
||||||
this.updateCollabolatorsState();
|
this.updateCollabolatorsState();
|
||||||
|
|
||||||
if (performance.now() - this.lastUpdate < DECAY_TIME * 2) {
|
if (this.isDrawing) {
|
||||||
this.update();
|
this.update();
|
||||||
} else {
|
} else {
|
||||||
this.isRunning = false;
|
this.isRunning = false;
|
||||||
@@ -250,6 +257,8 @@ export class LaserPathManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let somePathsExist = false;
|
||||||
|
|
||||||
for (const [key, state] of this.collaboratorsState.entries()) {
|
for (const [key, state] of this.collaboratorsState.entries()) {
|
||||||
if (!this.app.state.collaborators.has(key)) {
|
if (!this.app.state.collaborators.has(key)) {
|
||||||
state.svg.remove();
|
state.svg.remove();
|
||||||
@@ -269,6 +278,10 @@ export class LaserPathManager {
|
|||||||
paths += ` ${this.draw(state.currentPath)}`;
|
paths += ` ${this.draw(state.currentPath)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (paths.trim()) {
|
||||||
|
somePathsExist = true;
|
||||||
|
}
|
||||||
|
|
||||||
state.svg.setAttribute("d", paths);
|
state.svg.setAttribute("d", paths);
|
||||||
state.svg.setAttribute("fill", getClientColor(key));
|
state.svg.setAttribute("fill", getClientColor(key));
|
||||||
}
|
}
|
||||||
@@ -287,7 +300,17 @@ export class LaserPathManager {
|
|||||||
paths += ` ${this.draw(this.ownState.currentPath)}`;
|
paths += ` ${this.draw(this.ownState.currentPath)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
paths = paths.trim();
|
||||||
|
|
||||||
|
if (paths) {
|
||||||
|
somePathsExist = true;
|
||||||
|
}
|
||||||
|
|
||||||
this.ownState.svg.setAttribute("d", paths);
|
this.ownState.svg.setAttribute("d", paths);
|
||||||
this.ownState.svg.setAttribute("fill", "red");
|
this.ownState.svg.setAttribute("fill", "red");
|
||||||
|
|
||||||
|
if (!somePathsExist) {
|
||||||
|
this.isDrawing = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,6 @@
|
|||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
|
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
|
|
||||||
.LaserToolOverlayCanvas {
|
.LaserToolOverlayCanvas {
|
||||||
|
17
yarn.lock
17
yarn.lock
@@ -5994,10 +5994,19 @@ portfinder@^1.0.28:
|
|||||||
debug "^3.2.7"
|
debug "^3.2.7"
|
||||||
mkdirp "^0.5.6"
|
mkdirp "^0.5.6"
|
||||||
|
|
||||||
postcss@^8.4.23, postcss@^8.4.24:
|
postcss@^8.4.23:
|
||||||
version "8.4.31"
|
version "8.4.24"
|
||||||
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.31.tgz#92b451050a9f914da6755af352bdc0192508656d"
|
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.24.tgz#f714dba9b2284be3cc07dbd2fc57ee4dc972d2df"
|
||||||
integrity sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==
|
integrity sha512-M0RzbcI0sO/XJNucsGjvWU9ERWxb/ytp1w6dKtxTKgixdtQDq4rmx/g8W1hnaheq9jgwL/oyEdH5Bc4WwJKMqg==
|
||||||
|
dependencies:
|
||||||
|
nanoid "^3.3.6"
|
||||||
|
picocolors "^1.0.0"
|
||||||
|
source-map-js "^1.0.2"
|
||||||
|
|
||||||
|
postcss@^8.4.24:
|
||||||
|
version "8.4.25"
|
||||||
|
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.25.tgz#4a133f5e379eda7f61e906c3b1aaa9b81292726f"
|
||||||
|
integrity sha512-7taJ/8t2av0Z+sQEvNzCkpDynl0tX3uJMCODi6nT3PfASC7dYCWV9aQ+uiCf+KBD4SEFcu+GvJdGdwzQ6OSjCw==
|
||||||
dependencies:
|
dependencies:
|
||||||
nanoid "^3.3.6"
|
nanoid "^3.3.6"
|
||||||
picocolors "^1.0.0"
|
picocolors "^1.0.0"
|
||||||
|
Reference in New Issue
Block a user