@leafer-draw/worker 1.6.0 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/worker.cjs CHANGED
@@ -458,6 +458,15 @@ class Renderer {
458
458
  }
459
459
  checkRender() {
460
460
  if (this.running) {
461
+ const { target } = this;
462
+ if (target.isApp) {
463
+ target.emit(core.RenderEvent.CHILD_START, target);
464
+ target.children.forEach(leafer => {
465
+ leafer.renderer.FPS = this.FPS;
466
+ leafer.renderer.checkRender();
467
+ });
468
+ target.emit(core.RenderEvent.CHILD_END, target);
469
+ }
461
470
  if (this.changed && this.canvas.view)
462
471
  this.render();
463
472
  this.target.emit(core.RenderEvent.NEXT);
@@ -543,7 +552,7 @@ class Renderer {
543
552
  bounds.spread(Renderer.clipSpread).ceil();
544
553
  canvas.clearWorld(bounds, true);
545
554
  canvas.clipWorld(bounds, true);
546
- this.__render(bounds, block.includes(this.target.__world), realBounds);
555
+ this.__render(bounds, realBounds);
547
556
  canvas.restore();
548
557
  core.Run.end(t);
549
558
  }
@@ -552,12 +561,12 @@ class Renderer {
552
561
  const { canvas } = this;
553
562
  canvas.save();
554
563
  canvas.clear();
555
- this.__render(canvas.bounds, true);
564
+ this.__render(canvas.bounds);
556
565
  canvas.restore();
557
566
  core.Run.end(t);
558
567
  }
559
- __render(bounds, includes, realBounds) {
560
- const { canvas } = this, options = includes ? { includes } : { bounds, includes };
568
+ __render(bounds, realBounds) {
569
+ const { canvas } = this, includes = bounds.includes(this.target.__world), options = includes ? { includes } : { bounds, includes };
561
570
  if (this.needFill)
562
571
  canvas.fillWorld(bounds, this.config.fill);
563
572
  if (core.Debug.showRepaint)
@@ -584,22 +593,14 @@ class Renderer {
584
593
  }
585
594
  __requestRender() {
586
595
  const target = this.target;
587
- if (target.parentApp)
588
- return target.parentApp.renderer.update(false);
589
- if (this.requestTime)
596
+ if (this.requestTime || !target)
590
597
  return;
598
+ if (target.parentApp)
599
+ return target.parentApp.requestRender(false);
591
600
  const requestTime = this.requestTime = Date.now();
592
601
  core.Platform.requestRender(() => {
593
602
  this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - requestTime)));
594
603
  this.requestTime = 0;
595
- if (target.isApp) {
596
- target.emit(core.RenderEvent.CHILD_START, target);
597
- target.children.forEach(leafer => {
598
- leafer.renderer.FPS = this.FPS;
599
- leafer.renderer.checkRender();
600
- });
601
- target.emit(core.RenderEvent.CHILD_END, target);
602
- }
603
604
  this.checkRender();
604
605
  });
605
606
  }