Needle Engine

Changes between version 3.37.10-alpha.7 and 3.37.10-alpha.8
Files changed (1) hide show
  1. src/engine/webcomponents/needle menu/needle-menu.ts +10 -6
src/engine/webcomponents/needle menu/needle-menu.ts CHANGED
@@ -468,7 +468,7 @@
468
468
  // watch changes
469
469
  let showInterval = -1;
470
470
  let didWarnAboutWrongLicense = 0;
471
- const forceVisible = (parent) => {
471
+ const forceVisible = (parent, visible) => {
472
472
  if (context?.isInAR && context.arOverlayElement) {
473
473
  if (parent != context.arOverlayElement) {
474
474
  context.arOverlayElement.appendChild(this);
@@ -476,7 +476,7 @@
476
476
  }
477
477
  else if (this.parentNode != this._domElement?.shadowRoot)
478
478
  this._domElement?.shadowRoot?.appendChild(this);
479
- this.style.display = "flex";
479
+ this.style.display = visible ? "flex" : "none";
480
480
  this.style.visibility = "visible";
481
481
  this.style.opacity = "1";
482
482
  }
@@ -491,8 +491,10 @@
491
491
  // if a user doesn't have a local pro license *but* for development the menu is hidden then we show a warning
492
492
  if (isLocalNetwork()) {
493
493
  // set visible once so that the check above is not triggered again
494
- if (didWarnAboutWrongLicense === 0)
495
- forceVisible(requiredParent);
494
+ if (didWarnAboutWrongLicense === 0) {
495
+ // 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
+ }
496
498
  // warn only once
497
499
  if (didWarnAboutWrongLicense++ === 1) {
498
500
  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.`);
@@ -500,7 +502,7 @@
500
502
  }
501
503
  else {
502
504
  clearInterval(showInterval);
503
- showInterval = setInterval(() => forceVisible(requiredParent), 5)
505
+ showInterval = setInterval(() => forceVisible(requiredParent, true), 5)
504
506
  }
505
507
  }
506
508
  }
@@ -550,7 +552,9 @@
550
552
  this.root.classList.add(position);
551
553
  }
552
554
 
555
+ private _userRequestedMenuVisible?: boolean = undefined;
553
556
  setVisible(visible: boolean) {
557
+ this._userRequestedLogoVisible = visible;
554
558
  this.style.display = visible ? "flex" : "none";
555
559
  }
556
560
 
@@ -657,7 +661,7 @@
657
661
  get hasAnyContent() {
658
662
  // is the logo visible?
659
663
  if (this.logoContainer.style.display != "none") return true;
660
- if(this.hasAnyVisibleOptions) return true;
664
+ if (this.hasAnyVisibleOptions) return true;
661
665
  return false;
662
666
  }
663
667
  get hasAnyVisibleOptions() {