Skip to content
This repository was archived by the owner on Aug 1, 2022. It is now read-only.

Commit 8f76ad7

Browse files
authored
Draw each line immediately if immediate flag (#55)
1 parent a690cc0 commit 8f76ad7

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/index.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,22 @@ export default class extends PureComponent {
234234
lines.forEach(line => {
235235
const { points, brushColor, brushRadius } = line;
236236

237+
// Draw all at once if immediate flag is set, instead of using setTimeout
238+
if (immediate) {
239+
// Draw the points
240+
this.drawPoints({
241+
points,
242+
brushColor,
243+
brushRadius
244+
});
245+
246+
// Save line with the drawn points
247+
this.points = points;
248+
this.saveLine({ brushColor, brushRadius });
249+
return;
250+
}
251+
252+
// Use timeout to draw
237253
for (let i = 1; i < points.length; i++) {
238254
curTime += timeoutGap;
239255
window.setTimeout(() => {

0 commit comments

Comments
 (0)