@things-factory/figure-ui 10.1.127 → 10.1.128

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.
@@ -163,6 +163,10 @@ export class FigureEditor extends LitElement {
163
163
  div[middle][hidden] {
164
164
  display: none;
165
165
  }
166
+ /* The preview, once made, stays standing out of sight too: its 3D scene is not made again each time it is asked for. */
167
+ figure-preview[hidden] {
168
+ display: none;
169
+ }
166
170
  ox-canvas-bar .status {
167
171
  padding: 0 8px;
168
172
  color: var(--md-sys-color-on-surface-variant);
@@ -640,7 +644,10 @@ export class FigureEditor extends LitElement {
640
644
  for (const inner of panel.querySelectorAll('figure-links')) folds.push(...(inner.shadowRoot?.querySelectorAll('details') ?? []))
641
645
  return folds
642
646
  }
647
+ /** The preview is made when first asked for, and kept (hidden) after that; it is taken down with the editor. */
648
+ private previewMounted = false
643
649
  protected willUpdate(_changed: PropertyValues) {
650
+ if (this.middle === 'preview') this.previewMounted = true
644
651
  const view = this.session?.read()
645
652
  if (view?.context !== this.lastContext) {
646
653
  this.lastContext = view?.context ?? null
@@ -2149,8 +2156,10 @@ export class FigureEditor extends LitElement {
2149
2156
  @duplicate-part=${(e: CustomEvent) => this.duplicatePart(e.detail.id)}
2150
2157
  @remove-part=${(e: CustomEvent) => this.removePart(e.detail.id)}
2151
2158
  ></figure-parts>
2152
- ${this.middle === 'preview'
2159
+ ${this.previewMounted
2153
2160
  ? html`<figure-preview
2161
+ ?hidden=${this.middle !== 'preview'}
2162
+ .active=${this.middle === 'preview'}
2154
2163
  .asset=${asset}
2155
2164
  .context=${view.context ?? ''}
2156
2165
  .view=${this.view}
@@ -173,6 +173,13 @@ export class FigurePreview extends localize(i18next)(LitElement) {
173
173
  @property({ attribute: false }) asset?: FigureAsset
174
174
  /** Which figure: the type it is registered under here is this one's own, never a real type a board uses. */
175
175
  @property() context = ''
176
+ /**
177
+ * In front. Once made, the preview stays standing behind the edit canvas, so coming back to it is not a new 3D scene
178
+ * (about 300 ms): out of sight it does not follow the figure, and when it is shown again it makes its content again
179
+ * inside the scene that stands if the figure changed meanwhile.
180
+ */
181
+ @property({ type: Boolean }) active = true
182
+ private stale = false
176
183
  @property({ attribute: false }) view: ViewSettings = DEFAULT_VIEW
177
184
 
178
185
  @query('div[stage]') private stage!: HTMLDivElement
@@ -306,6 +313,15 @@ export class FigurePreview extends localize(i18next)(LitElement) {
306
313
 
307
314
  willUpdate(changed: Map<string, unknown>) {
308
315
  if (!this.hasUpdated) return
316
+ if (!this.active) {
317
+ this.stale = true
318
+ return
319
+ }
320
+ if (this.stale || changed.has('active')) {
321
+ this.stale = false
322
+ this.standUp()
323
+ return
324
+ }
309
325
  if (changed.has('asset') || changed.has('context')) {
310
326
  this.standUp()
311
327
  return
@@ -319,7 +335,9 @@ export class FigurePreview extends localize(i18next)(LitElement) {
319
335
 
320
336
  firstUpdated() {
321
337
  this.standUp()
322
- this.watcher = new ResizeObserver(() => this.scene?.resize?.())
338
+ this.watcher = new ResizeObserver(() => {
339
+ if (this.active) this.scene?.resize?.()
340
+ })
323
341
  this.watcher.observe(this)
324
342
  }
325
343
 
@@ -113,6 +113,8 @@ export declare class FigureEditor extends LitElement {
113
113
  private restorePanelFor?;
114
114
  private propertiesPanel;
115
115
  private foldsOf;
116
+ /** The preview is made when first asked for, and kept (hidden) after that; it is taken down with the editor. */
117
+ private previewMounted;
116
118
  protected willUpdate(_changed: PropertyValues): void;
117
119
  /**
118
120
  * The selection moved off the part being edited. With nothing changed there the editor closes; with changes, the part
@@ -153,6 +153,8 @@ let FigureEditor = class FigureEditor extends LitElement {
153
153
  hide which part the panel speaks of. Another model starts clean.
154
154
  */
155
155
  this.panelMemory = new Map();
156
+ /** The preview is made when first asked for, and kept (hidden) after that; it is taken down with the editor. */
157
+ this.previewMounted = false;
156
158
  this.lastAnchors = {};
157
159
  /** To the release that exists: the history tab's release section, not a second one here. */
158
160
  this.goRelease = async () => {
@@ -236,6 +238,10 @@ let FigureEditor = class FigureEditor extends LitElement {
236
238
  div[middle][hidden] {
237
239
  display: none;
238
240
  }
241
+ /* The preview, once made, stays standing out of sight too: its 3D scene is not made again each time it is asked for. */
242
+ figure-preview[hidden] {
243
+ display: none;
244
+ }
239
245
  ox-canvas-bar .status {
240
246
  padding: 0 8px;
241
247
  color: var(--md-sys-color-on-surface-variant);
@@ -617,6 +623,8 @@ let FigureEditor = class FigureEditor extends LitElement {
617
623
  return folds;
618
624
  }
619
625
  willUpdate(_changed) {
626
+ if (this.middle === 'preview')
627
+ this.previewMounted = true;
620
628
  const view = this.session?.read();
621
629
  if (view?.context !== this.lastContext) {
622
630
  this.lastContext = view?.context ?? null;
@@ -2169,8 +2177,10 @@ let FigureEditor = class FigureEditor extends LitElement {
2169
2177
  @duplicate-part=${(e) => this.duplicatePart(e.detail.id)}
2170
2178
  @remove-part=${(e) => this.removePart(e.detail.id)}
2171
2179
  ></figure-parts>
2172
- ${this.middle === 'preview'
2180
+ ${this.previewMounted
2173
2181
  ? html `<figure-preview
2182
+ ?hidden=${this.middle !== 'preview'}
2183
+ .active=${this.middle === 'preview'}
2174
2184
  .asset=${asset}
2175
2185
  .context=${view.context ?? ''}
2176
2186
  .view=${this.view}