Needle Engine

Changes between version 3.37.10-alpha.8 and 3.37.10-alpha.9
Files changed (1) hide show
  1. src/engine/webcomponents/needle menu/needle-menu.ts +15 -10
src/engine/webcomponents/needle menu/needle-menu.ts CHANGED
@@ -466,9 +466,9 @@
466
466
  setTimeout(() => context = this._context);
467
467
 
468
468
  // watch changes
469
- let showInterval = -1;
470
- let didWarnAboutWrongLicense = 0;
469
+ let changeEventCounter = 0;
471
470
  const forceVisible = (parent, visible) => {
471
+ if (debug) console.log("Set menu visible", visible);
472
472
  if (context?.isInAR && context.arOverlayElement) {
473
473
  if (parent != context.arOverlayElement) {
474
474
  context.arOverlayElement.appendChild(this);
@@ -488,21 +488,26 @@
488
488
  const requiredParent = this?.parentNode;
489
489
  if (this.style.display != "flex" || this.style.visibility != "visible" || this.style.opacity != "1" || requiredParent != this._domElement?.shadowRoot) {
490
490
  if (!hasProLicense()) {
491
+ const change = changeEventCounter++;
491
492
  // if a user doesn't have a local pro license *but* for development the menu is hidden then we show a warning
492
- if (isLocalNetwork()) {
493
+ if (isLocalNetwork() && this._userRequestedMenuVisible === false) {
493
494
  // set visible once so that the check above is not triggered again
494
- if (didWarnAboutWrongLicense === 0) {
495
+ if (change === 0) {
495
496
  // if the user requested visible to false before this code is called for the first time we want to respect the choice just in this case
496
- forceVisible(requiredParent, this._userRequestedLogoVisible);
497
+ forceVisible(requiredParent, this._userRequestedMenuVisible);
497
498
  }
498
499
  // warn only once
499
- if (didWarnAboutWrongLicense++ === 1) {
500
+ if (change === 1) {
500
501
  console.warn(`Needle Menu Warning: You need a PRO license to hide the Needle Engine menu → The menu will be visible in your deployed website if you don't have a PRO license. See https://needle.tools/pricing for details.`);
501
502
  }
502
503
  }
503
504
  else {
504
- clearInterval(showInterval);
505
- showInterval = setInterval(() => forceVisible(requiredParent, true), 5)
505
+ if (change === 0) {
506
+ forceVisible(requiredParent, true);
507
+ }
508
+ else {
509
+ setTimeout(() => forceVisible(requiredParent, true), 5)
510
+ }
506
511
  }
507
512
  }
508
513
  }
@@ -554,7 +559,7 @@
554
559
 
555
560
  private _userRequestedMenuVisible?: boolean = undefined;
556
561
  setVisible(visible: boolean) {
557
- this._userRequestedLogoVisible = visible;
562
+ this._userRequestedMenuVisible = visible;
558
563
  this.style.display = visible ? "flex" : "none";
559
564
  }
560
565
 
@@ -661,7 +666,7 @@
661
666
  get hasAnyContent() {
662
667
  // is the logo visible?
663
668
  if (this.logoContainer.style.display != "none") return true;
664
- if (this.hasAnyVisibleOptions) return true;
669
+ if(this.hasAnyVisibleOptions) return true;
665
670
  return false;
666
671
  }
667
672
  get hasAnyVisibleOptions() {