@johnmorrisdotca/fuda-cards 0.8.0 → 0.9.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/README.md CHANGED
@@ -126,7 +126,7 @@ Open `demo/tcgdex.html` through the local server to browse the Pokémon Base Set
126
126
 
127
127
  ## Collection viewer
128
128
 
129
- Run `pnpm dev` and open `/demo/collections-component.html`. Import `@johnmorrisdotca/fuda-cards/collection-element` to register the element, then set its `cards` property to an array of `{ id, name, image, backImage? }`. Image URLs are loaded by the viewer's browser. `id` is optional on input (the position is used if omitted); IDs must be unique. Set `view` to `deck`, `rolodex`, `binder`, `case`, `random`, `story`, `wall`, `spotlight`, `atlas` or `fan` (`jukebox` and `tower`, dropped in 0.8.0, still open the deck). Set `page-size` for the binder and case (1–100 cards) and `columns` (1–10) for their grid; small screens use at most two columns. In random view, filter card names to limit the draw; the draw button is disabled when no cards match.
129
+ Run `pnpm dev` and open `/demo/collections-component.html`. Import `@johnmorrisdotca/fuda-cards/collection-element` to register the element, then set its `cards` property to an array of `{ id, name, image, backImage?, kind? }` (`kind` is `"card"`, the default, or `"object"`: a picture of a thing that is not a card, such as a games console, which has no back and no thickness and so never turns over; see `docs/collection-input.md`). Image URLs are loaded by the viewer's browser. `id` is optional on input (the position is used if omitted); IDs must be unique. Set `view` to `deck`, `rolodex`, `binder`, `case`, `random`, `story`, `wall`, `spotlight`, `atlas` or `fan` (`jukebox` and `tower`, dropped in 0.8.0, still open the deck). Set `page-size` for the binder and case (1–100 cards) and `columns` (1–10) for their grid; small screens use at most two columns. In random view, filter card names to limit the draw; the draw button is disabled when no cards match.
130
130
 
131
131
  **Choosing a display.** The ten displays are a row of buttons across the top, each with a small picture of its layout and its name, at least 48 px high, one chosen, wrapping on a phone (4 to a row, 6 on a desk). It is a radio group: one tab stop, the arrow keys move the choice. There is no drop-down. The colours follow the reader's light or dark setting; set `theme="light"` or `theme="dark"` to choose for them.
132
132
 
package/dist/binder.d.ts CHANGED
@@ -33,7 +33,7 @@ export declare const spreadCount: (sides: number) => number;
33
33
  export declare const spreadOf: (index: number, per: number) => number;
34
34
  /** The sides an opening shows (-1 where there is none), left then right, for `sides` sides in all. */
35
35
  export declare function spreadSides(spread: number, sides: number): [number, number];
36
- export declare const BINDER_CSS = "\n.stage.binder{perspective:2400px;background:radial-gradient(ellipse,var(--fc-stage-1),var(--fc-stage-2) 68%)}\n.v.binder{--sw:300px;--sh:384px;--strip:34px;--cover:#1f7a4a;display:flex;align-items:center;justify-content:center;transform-style:preserve-3d}\n.book{position:relative;display:flex;padding:18px 16px;border-radius:16px;background:var(--cover);box-shadow:0 12px 28px #0008,inset 0 0 0 2px #fff2,inset 0 0 24px #0005;transform-style:preserve-3d}\n.book::before{content:'';position:absolute;inset:6px;border-radius:12px;box-shadow:inset 0 0 0 2px #0004;pointer-events:none}\n.book.b-zip::after{content:'';position:absolute;inset:5px;border-radius:13px;border:3px dotted #cfd2d8;opacity:.7;pointer-events:none}\n.book .tab{display:none}.book.b-zip .tab{display:block;position:absolute;right:30px;bottom:-4px;width:34px;height:14px;border-radius:5px;background:linear-gradient(#e4e6ea,#8d9098);box-shadow:0 2px 4px #0006}\n.inside{position:relative;display:flex;transform-style:preserve-3d;background:var(--lining,#f1eee6);border-radius:6px;box-shadow:inset 0 0 18px #0003}\n.half{position:relative;width:var(--sw);height:var(--sh);flex:none}\n.half:empty::after{content:'';position:absolute;inset:0;background:linear-gradient(90deg,#0002,transparent 14%)}\n.spine{position:absolute;left:50%;top:0;bottom:0;width:0;transform-style:preserve-3d;pointer-events:none;z-index:3}\n.ring{position:absolute;left:-9px;width:18px;height:46px;margin-top:-23px;border-radius:9px;border:4px solid #c3c6cd;border-color:#f1f2f5 #8d9098 #8d9098 #f1f2f5;box-shadow:0 2px 3px #0005;transform:translateZ(2px)}\n.side{position:absolute;inset:0;display:grid;padding:12px 10px;grid-template-columns:repeat(var(--cols,3),minmax(0,1fr));grid-template-rows:repeat(var(--rows,3),minmax(0,1fr));gap:5px;background:var(--sheetbg);box-sizing:border-box;border:1px solid var(--sheetedge)}\n.side.clear{--sheetbg:#ffffff2e;--sheetedge:#ffffff55;--pocketbg:#ffffff26;--pocketedge:#ffffffa0}.side.black{--sheetbg:#17171b;--sheetedge:#000;--pocketbg:#ffffff12;--pocketedge:#ffffff55}\n.side.r{padding-left:calc(var(--strip) + 6px)}.side.l{padding-right:calc(var(--strip) + 6px)}\n.holes{position:absolute;top:0;bottom:0;width:var(--strip);display:flex;flex-direction:column;justify-content:space-evenly;align-items:center;padding:14px 0}.side.r .holes{left:0}.side.l .holes{right:0}.holes i{width:9px;height:9px;border-radius:50%;background:var(--lining,#f1eee6);box-shadow:inset 0 1px 2px #0007,0 0 0 1px #0002}\n.pocket{position:relative;display:grid;place-items:center;border-radius:4px;background:var(--pocketbg);border:1px solid var(--pocketedge);box-shadow:inset 0 0 0 1px #0000000d,0 1px 2px #0003;overflow:hidden;min-width:0;min-height:0}\n.pocket::after{content:'';position:absolute;inset:0;pointer-events:none;background:linear-gradient(118deg,#ffffff55 0,#ffffff00 32%,#ffffff12 55%,#ffffff00 70%,#ffffff33 100%)}\n.pocket .card{position:relative;z-index:0;width:86%;height:92%;padding:0;border:0;background:transparent;line-height:0;display:grid;place-items:center}.pocket .card img{width:100%;height:100%;object-fit:contain;border-radius:3%;box-shadow:0 2px 5px #0007}\n.pocket.empty{opacity:.55}\n.leaf{position:absolute;left:50%;top:0;width:var(--sw);height:var(--sh);transform-origin:0 50%;transform-style:preserve-3d;pointer-events:none;z-index:2}\n.slice{position:absolute;top:0;height:100%;transform-origin:0 50%;transform-style:preserve-3d}\n.slice>.f,.slice>.b{position:absolute;inset:0;backface-visibility:hidden;-webkit-backface-visibility:hidden;overflow:hidden}.slice>.b{transform:rotateY(180deg)}\n.slice .sf{position:absolute;top:0;height:100%}\n";
36
+ export declare const BINDER_CSS = "\n.stage.binder{perspective:2400px;background:radial-gradient(ellipse,var(--fc-stage-1),var(--fc-stage-2) 68%)}\n.v.binder{--sw:300px;--sh:384px;--strip:34px;--cover:#1f7a4a;display:flex;align-items:center;justify-content:center;transform-style:preserve-3d}\n.book{position:relative;display:flex;padding:18px 16px;border-radius:16px;background:var(--cover);box-shadow:0 12px 28px #0008,inset 0 0 0 2px #fff2,inset 0 0 24px #0005;transform-style:preserve-3d}\n.book::before{content:'';position:absolute;inset:6px;border-radius:12px;box-shadow:inset 0 0 0 2px #0004;pointer-events:none}\n.book.b-zip::after{content:'';position:absolute;inset:5px;border-radius:13px;border:3px dotted #cfd2d8;opacity:.7;pointer-events:none}\n.book .tab{display:none}.book.b-zip .tab{display:block;position:absolute;right:30px;bottom:-4px;width:34px;height:14px;border-radius:5px;background:linear-gradient(#e4e6ea,#8d9098);box-shadow:0 2px 4px #0006}\n.inside{position:relative;display:flex;transform-style:preserve-3d;background:var(--lining,#f1eee6);border-radius:6px;box-shadow:inset 0 0 18px #0003}\n.half{position:relative;width:var(--sw);height:var(--sh);flex:none}\n.half:empty::after{content:'';position:absolute;inset:0;background:linear-gradient(90deg,#0002,transparent 14%)}\n.spine{position:absolute;left:50%;top:0;bottom:0;width:0;transform-style:preserve-3d;pointer-events:none;z-index:3}\n.ring{position:absolute;left:-9px;width:18px;height:46px;margin-top:-23px;border-radius:9px;border:4px solid #c3c6cd;border-color:#f1f2f5 #8d9098 #8d9098 #f1f2f5;box-shadow:0 2px 3px #0005;transform:translateZ(2px)}\n.side{position:absolute;inset:0;display:grid;padding:12px 10px;grid-template-columns:repeat(var(--cols,3),minmax(0,1fr));grid-template-rows:repeat(var(--rows,3),minmax(0,1fr));gap:5px;background:var(--sheetbg);box-sizing:border-box;border:1px solid var(--sheetedge)}\n.side.clear{--sheetbg:#ffffff2e;--sheetedge:#ffffff55;--pocketbg:#ffffff26;--pocketedge:#ffffffa0}.side.black{--sheetbg:#17171b;--sheetedge:#000;--pocketbg:#ffffff12;--pocketedge:#ffffff55}\n.side.r{padding-left:calc(var(--strip) + 6px)}.side.l{padding-right:calc(var(--strip) + 6px)}\n.holes{position:absolute;top:0;bottom:0;width:var(--strip);display:flex;flex-direction:column;justify-content:space-evenly;align-items:center;padding:14px 0}.side.r .holes{left:0}.side.l .holes{right:0}.holes i{width:9px;height:9px;border-radius:50%;background:var(--lining,#f1eee6);box-shadow:inset 0 1px 2px #0007,0 0 0 1px #0002}\n.pocket{position:relative;display:grid;place-items:center;border-radius:4px;background:var(--pocketbg);border:1px solid var(--pocketedge);box-shadow:inset 0 0 0 1px #0000000d,0 1px 2px #0003;overflow:hidden;min-width:0;min-height:0}\n.pocket::after{content:'';position:absolute;inset:0;pointer-events:none;background:linear-gradient(118deg,#ffffff55 0,#ffffff00 32%,#ffffff12 55%,#ffffff00 70%,#ffffff33 100%)}\n.pocket .card{position:relative;z-index:0;width:86%;height:92%;padding:0;border:0;background:transparent;line-height:0;display:grid;place-items:center}.pocket .card img{width:100%;height:100%;object-fit:contain;border-radius:3%;box-shadow:0 2px 5px #0007}\n.pocket.empty{opacity:.55}\n.leaf{position:absolute;left:50%;top:0;width:var(--sw);height:var(--sh);transform-origin:0 50%;transform-style:preserve-3d;pointer-events:none;z-index:2}\n.slice{position:absolute;top:0;height:100%;transform-origin:0 50%;transform-style:preserve-3d}\n.slice>.f,.slice>.b{position:absolute;inset:0 -1.5px;backface-visibility:hidden;-webkit-backface-visibility:hidden;overflow:hidden}.slice>.b{transform:rotateY(180deg)}\n.slice .sf{position:absolute;top:0;height:100%}\n/* The slices overlap their neighbours by a pixel and a half, so no seam between them lets the page behind show; the outer edges of the leaf stay where they are. */\n.slice.first>.f,.slice.last>.b{left:0}.slice.first>.b,.slice.last>.f{right:0}\n";
37
37
  /** The cards a side holds, as indexes into the collection (or -1 for an empty pocket), in reading order. */
38
38
  export declare function sideCards(side: number, layout: BinderLayout, total: number): number[];
39
39
  export interface PocketMaker {
package/dist/binder.js CHANGED
@@ -47,8 +47,10 @@ export const BINDER_CSS = `
47
47
  .pocket.empty{opacity:.55}
48
48
  .leaf{position:absolute;left:50%;top:0;width:var(--sw);height:var(--sh);transform-origin:0 50%;transform-style:preserve-3d;pointer-events:none;z-index:2}
49
49
  .slice{position:absolute;top:0;height:100%;transform-origin:0 50%;transform-style:preserve-3d}
50
- .slice>.f,.slice>.b{position:absolute;inset:0;backface-visibility:hidden;-webkit-backface-visibility:hidden;overflow:hidden}.slice>.b{transform:rotateY(180deg)}
50
+ .slice>.f,.slice>.b{position:absolute;inset:0 -1.5px;backface-visibility:hidden;-webkit-backface-visibility:hidden;overflow:hidden}.slice>.b{transform:rotateY(180deg)}
51
51
  .slice .sf{position:absolute;top:0;height:100%}
52
+ /* The slices overlap their neighbours by a pixel and a half, so no seam between them lets the page behind show; the outer edges of the leaf stay where they are. */
53
+ .slice.first>.f,.slice.last>.b{left:0}.slice.first>.b,.slice.last>.f{right:0}
52
54
  `;
53
55
  /** The cards a side holds, as indexes into the collection (or -1 for an empty pocket), in reading order. */
54
56
  export function sideCards(side, layout, total) {
@@ -84,7 +86,7 @@ export function buildLeaf(front, back, sheet, layout, total, pocket, widthPx, st
84
86
  let parent = leaf, offset = 0;
85
87
  widths.forEach((w, k) => {
86
88
  const slice = document.createElement('div');
87
- slice.className = 'slice';
89
+ slice.className = k === 0 ? 'slice first' : k === widths.length - 1 ? 'slice last' : 'slice';
88
90
  slice.style.width = `${w}px`;
89
91
  slice.style.left = k === 0 ? '0' : '100%';
90
92
  const f = document.createElement('div'), b = document.createElement('div');
@@ -32,6 +32,8 @@ export declare class FudaCollection extends HTMLElement {
32
32
  private get fanOpen();
33
33
  private get stacked();
34
34
  private get piled();
35
+ /** Only a card turns: a collection of objects (no card in it) never turns, and in a mixed one the objects stay square to the reader while the cards turn. */
36
+ private get hasCards();
35
37
  private get turnable();
36
38
  private q;
37
39
  /** With `address`, the display, the fan, the landing, the animation and its speed are kept in the page's address (`?view=fan&fan=open&land=face-down&animate=off`), and a link to it opens the same. */
@@ -1,4 +1,4 @@
1
- import { collectionViewAliases, collectionViews, parseCollection, randomDrawIndex, movePage } from './collection.js';
1
+ import { collectionViewAliases, collectionViews, isCard, parseCollection, randomDrawIndex, movePage } from './collection.js';
2
2
  import { BINDER_CSS, binderCovers, binderLayout, buildLeaf, buildSide, sideCount, spreadCount, spreadOf, spreadSides } from './binder.js';
3
3
  import { deckLandings, fanBounds, fanLayout, fanShift, flight, normalizeLanding, timing } from './pile.js';
4
4
  import { zoomView } from './zoom.js';
@@ -16,7 +16,7 @@ button:focus-visible,input:focus-visible,.card:focus-visible{outline:3px solid v
16
16
  .grid{display:grid;grid-template-columns:repeat(var(--columns,3),minmax(0,1fr));gap:1rem;padding:1rem;align-content:start}.grid .card{height:clamp(130px,24vw,220px)}
17
17
  .v.case{perspective:800px}.stage.case{background:linear-gradient(#4a3f33,#1d1914);border:10px solid #6b5436;box-shadow:inset 0 0 26px #000a}.stage.case::after{content:'';position:absolute;inset:0;pointer-events:none;z-index:2;background:linear-gradient(115deg,#ffffff30 0,#ffffff00 28%,#ffffff12 55%,#ffffff00 78%,#ffffff22 100%)}.case .card{transform:perspective(600px) rotateX(-15deg);box-shadow:0 12px 0 -3px #2c251d,0 18px 8px -4px #000a}.case .card img{box-shadow:0 4px 10px #0009}
18
18
  .wall{display:flex;gap:1rem;align-items:center;padding:1rem}.wall .card{height:90%;flex:0 0 190px}
19
- .story{display:flex;flex-direction:column;align-items:center;gap:1rem;padding:1rem}.story .card{width:min(75%,300px);flex:0 0 90%}
19
+ .story{display:flex;flex-direction:column;align-items:center;gap:1rem;padding:1rem}.story .card{width:min(75%,300px);flex:0 0 90%;min-height:0}
20
20
  .plane{position:absolute;left:0;top:0;display:grid;gap:18px;grid-template-columns:repeat(var(--atlas-cols,5),140px);padding:30px}.plane .card{height:195px}
21
21
  .stage.spotlight{background:radial-gradient(ellipse at center,#e5ce99,#454054 40%,#171822 78%)}
22
22
  .stage:is(.deck,.random,.fan){perspective:1800px}.v.deck{--w:200px;--gap:56px;--fl:0;--fr:0;--ft:0;--fb:0;--ease:cubic-bezier(.2,.8,.2,1);transform-style:preserve-3d}
@@ -28,7 +28,7 @@ button:focus-visible,input:focus-visible,.card:focus-visible{outline:3px solid v
28
28
  .fan-open .deck-pile .card{transform-origin:50% 165%;transform:translate3d(calc(var(--fx,0) * var(--w)),0,calc(var(--k,0) * .9px)) rotate(calc(var(--fa,0) * 1deg));transition-delay:calc(var(--i,0) * var(--stag,28ms));pointer-events:auto;cursor:pointer}.fan-open .deck-pile .card:hover,.fan-open .deck-pile .card:focus-visible{translate:0 -14px}
29
29
  .fly,.turn{position:absolute;inset:0;transform-style:preserve-3d}.face{position:absolute;inset:0;backface-visibility:hidden;-webkit-backface-visibility:hidden;border-radius:5%;overflow:hidden}.face img{display:block;width:100%;height:100%;object-fit:contain;border-radius:3%;box-shadow:0 4px 10px #0008}.face.back{transform:rotateY(180deg)}
30
30
  .generic-back{display:grid;place-items:center;background:radial-gradient(ellipse at center,#b78745 0 12%,#152d46 13% 27%,#386988 28% 31%,#10233b 32% 62%,#d2b074 63% 66%,#182c45 67%);border:6px solid #b39158;color:#f7e9bf;font:bold 18px Georgia;letter-spacing:.12em;box-shadow:0 4px 10px #0008}
31
- .pile.discard[data-land=face-down] .card .turn{transform:rotateY(180deg)}.ghost{pointer-events:none}
31
+ .pile.discard[data-land=face-down] .card:not(.flat) .turn{transform:rotateY(180deg)}.card.flat .turn{transform:rotateY(calc(var(--fuda-yaw,0) * -1deg)) rotateX(calc(var(--fuda-tilt,0) * -1deg))}.ghost{pointer-events:none}
32
32
  dialog{color:var(--fc-text);background:var(--fc-dialog);border:1px solid var(--fc-btn-border);border-radius:1rem;text-align:center;max-width:95vw;max-height:95vh}dialog::backdrop{background:#000c}.detail{display:block;height:min(70vh,600px);max-width:80vw;object-fit:contain;margin:1rem auto}.empty{text-align:center;padding:3rem}
33
33
  @media(max-width:600px){.stage{height:var(--fuda-stage-height,clamp(220px,calc(100svh - 570px),620px))}}@media(max-width:500px){.opts{grid-template-columns:repeat(2,minmax(0,1fr))}.opts .speed{grid-column:1/-1}.v.deck{--gap:28px}.grid{grid-template-columns:repeat(min(2,var(--columns,3)),minmax(0,1fr))}.shell{padding:.7rem}.v.deck{--w:150px}}@media(prefers-reduced-motion:reduce){*{transition:none!important}}
34
34
  </style>`;
@@ -105,7 +105,9 @@ export class FudaCollection extends HTMLElement {
105
105
  get fanOpen() { return this.getAttribute('fan') === 'open'; }
106
106
  get stacked() { return ![...pages, ...scrolling].includes(this.currentView); }
107
107
  get piled() { return pileViews.includes(this.currentView); }
108
- get turnable() { return this.piled || this.currentView === 'fan'; }
108
+ /** Only a card turns: a collection of objects (no card in it) never turns, and in a mixed one the objects stay square to the reader while the cards turn. */
109
+ get hasCards() { return this.data.some(isCard); }
110
+ get turnable() { return (this.piled || this.currentView === 'fan') && this.hasCards; }
109
111
  q(selector) { return this.root.querySelector(selector); }
110
112
  /** With `address`, the display, the fan, the landing, the animation and its speed are kept in the page's address (`?view=fan&fan=open&land=face-down&animate=off`), and a link to it opens the same. */
111
113
  readAddress() { try {
@@ -234,7 +236,8 @@ export class FudaCollection extends HTMLElement {
234
236
  shown.forEach((at, j) => {
235
237
  const top = j === shown.length - 1, c = this.data[at], place = places[j];
236
238
  const el = document.createElement('div');
237
- el.className = `card${top ? ' top' : ''}`;
239
+ const flat = !isCard(c);
240
+ el.className = `card${top ? ' top' : ''}${flat ? ' flat' : ''}`;
238
241
  el.dataset.i = String(at);
239
242
  if (place && !top) {
240
243
  el.style.setProperty('--x', String(place.x));
@@ -261,20 +264,24 @@ export class FudaCollection extends HTMLElement {
261
264
  img.loading = 'lazy';
262
265
  img.onerror = () => { img.replaceWith(document.createTextNode(`Image unavailable: ${c.name}`)); };
263
266
  front.append(img);
264
- const back = document.createElement('div');
265
- back.className = 'face back';
266
- if (c.backImage) {
267
- const b = document.createElement('img');
268
- b.src = c.backImage;
269
- b.alt = '';
270
- b.loading = 'lazy';
271
- back.append(b);
267
+ turn.append(front);
268
+ // An object has no back to show: only a card gets the picture of its back (or the package's own).
269
+ if (!flat) {
270
+ const back = document.createElement('div');
271
+ back.className = 'face back';
272
+ if (c.backImage) {
273
+ const b = document.createElement('img');
274
+ b.src = c.backImage;
275
+ b.alt = '';
276
+ b.loading = 'lazy';
277
+ back.append(b);
278
+ }
279
+ else {
280
+ back.classList.add('generic-back');
281
+ back.textContent = 'FUDA';
282
+ }
283
+ turn.append(back);
272
284
  }
273
- else {
274
- back.classList.add('generic-back');
275
- back.textContent = 'FUDA';
276
- }
277
- turn.append(front, back);
278
285
  fly.append(turn);
279
286
  el.append(fly);
280
287
  el.onclick = () => this.open(c);
@@ -354,8 +361,10 @@ export class FudaCollection extends HTMLElement {
354
361
  const lead = this.fanOpen && this.fanPlaces.length > 1 ? this.fanPlaces[0] : null, shift = lead ? fanShift(lead) : { x: 0, y: 0 };
355
362
  const away = { x: shift.x * w, y: shift.y * w }, spin = lead ? lead.angle : 0;
356
363
  // Taking a card off an open fan starts it where the fan holds it; bringing it back ends there.
357
- const from = direction === 'off' ? { x: -dx + away.x, y: -dy + away.y } : { x: dx - away.x, y: dy - away.y };
358
- flight(fly, turn, from, this.land, direction, ms, direction === 'off' ? spin : -spin);
364
+ // The piles' cards lie 0.9 px apart in depth (ten at most), so the flying card starts just above the higher of them and ends at its own place.
365
+ const z = 9.6 - (Number.parseFloat(moved.style.getPropertyValue('--k')) || 0) * 0.9;
366
+ const from = direction === 'off' ? { x: -dx + away.x, y: -dy + away.y, z } : { x: dx - away.x, y: dy - away.y, z };
367
+ flight(fly, turn, from, moved.classList.contains('flat') ? 'face-up' : this.land, direction, ms, direction === 'off' ? spin : -spin);
359
368
  }
360
369
  renderFan(v) { this.renderDeck(v, true); }
361
370
  /** Where every card is on screen now, by data index. */
@@ -486,7 +495,7 @@ export class FudaCollection extends HTMLElement {
486
495
  this.landing.set(this.land);
487
496
  this.fanChoice.set(this.fanOpen ? 'open' : 'closed');
488
497
  this.syncChoices();
489
- this.landing.hidden = !this.piled;
498
+ this.landing.hidden = !this.piled || !this.hasCards;
490
499
  this.fanChoice.hidden = !(this.piled || view === 'fan');
491
500
  this.q('.count').textContent = this.data.length ? (view === 'binder' ? this.binderCount() : pages.includes(view) ? `Page ${Math.floor(this.index / this.pageSize) + 1} / ${Math.ceil(this.data.length / this.pageSize)}` : `${this.index + 1} / ${this.data.length}`) : 'No cards';
492
501
  for (const selector of ['.prev', '.next'])
@@ -503,7 +512,7 @@ export class FudaCollection extends HTMLElement {
503
512
  for (const k of ['--fl', '--fr', '--ft', '--fb'])
504
513
  v.style.removeProperty(k);
505
514
  this.zoom.minOpen = scrolling.includes(view) ? .5 : 0;
506
- this.zoom.setTurnable(this.turnable && this.data.length > 0);
515
+ this.zoom.setTurnable(this.turnable && this.data.length > 0, this.data.length > 0 && !this.hasCards);
507
516
  this.zoom.items = this.piled || view === 'fan' ? '.extent' : view === 'binder' ? '.book' : '.card,.slot';
508
517
  if (!this.data.length) {
509
518
  v.innerHTML = '<p class="empty">No cards in this collection.</p>';
@@ -12,13 +12,24 @@ export interface CollectionMetadata {
12
12
  quantity?: number;
13
13
  notes?: string;
14
14
  }
15
+ /**
16
+ * What an item is. A `card` (the default, so every collection written before this field existed is still cards) is a flat, thin card with a back: it
17
+ * turns in 3D, can be seen from behind and lands turned over when taken off a pile. An `object` is a picture of a thing that is not a card, such as a
18
+ * games console: it has no back and no thickness, so it never turns over, is never seen from behind or edge-on, and always lands facing up. (A real 3D
19
+ * object would be a third kind; none can be given as an image yet.)
20
+ */
21
+ export type CollectionKind = 'card' | 'object';
22
+ export declare const collectionKinds: ReadonlyArray<CollectionKind>;
15
23
  export interface CollectionCard {
16
24
  id: string;
17
25
  name: string;
18
26
  image: string;
19
27
  backImage?: string;
28
+ kind?: CollectionKind;
20
29
  metadata?: CollectionMetadata;
21
30
  }
31
+ /** True for an item that is a card: anything that does not say it is an object. Only a card turns, has a back and lands turned over. */
32
+ export declare const isCard: (card: Pick<CollectionCard, "kind">) => boolean;
22
33
  /** The displays, in the order the buttons show them. `jukebox` and `tower` were two more names for the deck's pile of cards (no real counterpart for cards, and the same drawing), so they are no longer offered; see `collectionViewAliases`. */
23
34
  export declare const collectionViews: ReadonlyArray<{
24
35
  id: CollectionView;
@@ -1,4 +1,7 @@
1
1
  export { fanLayout, deckLandings, normalizeLanding } from './pile.js';
2
+ export const collectionKinds = ['card', 'object'];
3
+ /** True for an item that is a card: anything that does not say it is an object. Only a card turns, has a back and lands turned over. */
4
+ export const isCard = (card) => card.kind !== 'object';
2
5
  /** The displays, in the order the buttons show them. `jukebox` and `tower` were two more names for the deck's pile of cards (no real counterpart for cards, and the same drawing), so they are no longer offered; see `collectionViewAliases`. */
3
6
  export const collectionViews = [
4
7
  { id: 'deck', label: 'Overlapping Deck' }, { id: 'rolodex', label: 'Rolodex' }, { id: 'binder', label: 'Binder Pages' },
@@ -26,6 +29,8 @@ export function parseCollection(value) {
26
29
  ids.add(id);
27
30
  if (c.backImage !== undefined && typeof c.backImage !== 'string')
28
31
  throw new Error(`Card ${i + 1} backImage must be a URL.`);
32
+ if (c.kind !== undefined && !collectionKinds.includes(c.kind))
33
+ throw new Error(`Card ${i + 1} kind must be "card" or "object".`);
29
34
  let metadata;
30
35
  if (c.metadata !== undefined) {
31
36
  if (!c.metadata || typeof c.metadata !== 'object' || Array.isArray(c.metadata))
@@ -45,7 +50,7 @@ export function parseCollection(value) {
45
50
  if (typeof m[key] === 'number')
46
51
  metadata[key] = m[key];
47
52
  }
48
- return { id, name: c.name, image: c.image, ...(c.backImage ? { backImage: c.backImage } : {}), ...(metadata ? { metadata } : {}) };
53
+ return { id, name: c.name, image: c.image, ...(c.backImage ? { backImage: c.backImage } : {}), ...(c.kind === 'object' ? { kind: 'object' } : {}), ...(metadata ? { metadata } : {}) };
49
54
  });
50
55
  }
51
56
  /** Choose a matching card, avoiding the current card when another match exists. */
package/dist/pile.d.ts CHANGED
@@ -65,6 +65,11 @@ export declare function timing(host: Element, dflt: boolean): Timing;
65
65
  /**
66
66
  * A card taken off a pile flies to the pile at its side, and turns over sideways on the way if it lands face down; coming back it
67
67
  * does the same in reverse. `fly` carries the card across, `turn` carries the turn. `from` is how far the card is from where it ends.
68
+ *
69
+ * The card must never pass through another card: every card of a 3D scene is drawn by its depth, so a card that turns while it is level
70
+ * with the piles is cut by them and shows the cards behind it. So the card starts above the pile it leaves (`from.z`, in pixels, is how
71
+ * much higher than its landing place that is), stays above both piles all the way, and while it turns it is lifted by half its width times the
72
+ * sine of the turn, which is exactly what keeps its lowest corner above the cards it passes. It is level again, and down on the pile, at the end.
68
73
  */
69
74
  export declare function flight(fly: HTMLElement, turn: HTMLElement, from: {
70
75
  x: number;
package/dist/pile.js CHANGED
@@ -93,15 +93,28 @@ export function timing(host, dflt) {
93
93
  /**
94
94
  * A card taken off a pile flies to the pile at its side, and turns over sideways on the way if it lands face down; coming back it
95
95
  * does the same in reverse. `fly` carries the card across, `turn` carries the turn. `from` is how far the card is from where it ends.
96
+ *
97
+ * The card must never pass through another card: every card of a 3D scene is drawn by its depth, so a card that turns while it is level
98
+ * with the piles is cut by them and shows the cards behind it. So the card starts above the pile it leaves (`from.z`, in pixels, is how
99
+ * much higher than its landing place that is), stays above both piles all the way, and while it turns it is lifted by half its width times the
100
+ * sine of the turn, which is exactly what keeps its lowest corner above the cards it passes. It is level again, and down on the pile, at the end.
96
101
  */
97
102
  export function flight(fly, turn, from, land, direction, ms, spin = 0) {
98
103
  const options = { duration: ms, easing: 'cubic-bezier(.3,.1,.2,1)' };
99
- const out = [fly.animate([
100
- { transform: `translate3d(${from.x}px,${from.y}px,${from.z ?? 0}px) rotate(${spin}deg)` },
101
- { transform: `translate3d(${from.x / 2}px,${from.y / 2 - 34}px,${(from.z ?? 0) / 2 + 80}px) rotate(${spin / 2}deg) scale(1.07)`, offset: 0.5 },
102
- { transform: 'translate3d(0,0,0) rotate(0deg)' }
103
- ], options)];
104
- if (land === 'face-down')
105
- out.push(turn.animate(direction === 'off' ? [{ transform: 'none' }, { transform: 'rotateY(180deg)' }] : [{ transform: 'rotateY(180deg)' }, { transform: 'none' }], options));
104
+ const turns = land === 'face-down', half = (fly.offsetWidth || 200) / 2, z0 = from.z ?? 0, STEPS = 16, MARGIN = 1.5;
105
+ const fly3d = [], turn3d = [];
106
+ for (let k = 0; k <= STEPS; k++) {
107
+ const p = k / STEPS, q = 1 - p, arc = Math.sin(Math.PI * p);
108
+ // Over the pile it leaves the card stays as high as that pile until half way, then comes down to where it lands.
109
+ const base = Math.max(0, z0 * Math.min(1, 2 * q)) + MARGIN * arc;
110
+ const lift = (turns ? half + 6 : 80) * arc;
111
+ const z = k === STEPS ? 0 : base + lift;
112
+ fly3d.push({ offset: p, transform: `translate3d(${from.x * q}px,${from.y * q - 136 * p * q}px,${z}px) rotate(${spin * q}deg) scale(${1 + 0.07 * arc})` });
113
+ if (turns)
114
+ turn3d.push({ offset: p, transform: `rotateY(${(direction === 'off' ? p : q) * 180}deg)` });
115
+ }
116
+ const out = [fly.animate(fly3d, options)];
117
+ if (turns)
118
+ out.push(turn.animate(turn3d, options));
106
119
  return out;
107
120
  }
package/dist/zoom.d.ts CHANGED
@@ -35,8 +35,8 @@ export interface ZoomView {
35
35
  /** Go back to the opening view. */
36
36
  reset(): void;
37
37
  zoomed(): boolean;
38
- /** Let the reader turn the view in 3D (angle, tilt, Auto-turn) or only zoom and move it. Off by default. */
39
- setTurnable(on: boolean): void;
38
+ /** Let the reader turn the view in 3D (angle, tilt, Auto-turn) or only zoom and move it. Off by default. `never` says nothing in the view can turn, so an angle in the address is dropped too. */
39
+ setTurnable(on: boolean, never?: boolean): void;
40
40
  /** The selector of the items that must be visible at Fit. It can change with the display. */
41
41
  items: string;
42
42
  /** Run a change that moves the view (a refit, a pan) so that the view glides to its new place over `ms` instead of jumping; 0 jumps. */
package/dist/zoom.js CHANGED
@@ -59,11 +59,18 @@ export function zoomView(stage, view, options = {}) {
59
59
  const scale = fit * state.zoom;
60
60
  view.style.transformOrigin = `${box.cx}px ${box.cy}px`;
61
61
  const turn = turnable ? ` rotateX(${state.tilt ?? 0}deg) rotateY(${state.yaw ?? 0}deg)` : '';
62
+ // The turn, for the items that must stay square to the reader (they turn the other way by this much).
63
+ view.style.setProperty('--fuda-yaw', turnable ? String(state.yaw ?? 0) : '0');
64
+ view.style.setProperty('--fuda-tilt', turnable ? String(state.tilt ?? 0) : '0');
62
65
  view.style.transform = `translate(${box.w / 2 - box.cx + state.panX}px,${box.h / 2 - box.cy + state.panY}px) scale(${scale})${turn}`;
63
66
  }
64
- function setTurnable(on) {
65
- if (on === turnable)
67
+ function setTurnable(on, never = false) {
68
+ // A view whose items can never turn (`never`) keeps no angle either, whatever the address says.
69
+ if (on === turnable) {
70
+ if (never && !on && (controls.state.yaw || controls.state.tilt))
71
+ controls.set({ yaw: 0, tilt: 0 });
66
72
  return;
73
+ }
67
74
  turnable = on;
68
75
  if (!on)
69
76
  controls.set({ yaw: 0, tilt: 0 });
@@ -11,6 +11,15 @@ Fuda supplies reusable frames for a caller's cards and reusable ways to display
11
11
  - **Animate (0.7.0).** `animate="off"` and `speed` for every move: the fan, a card taken off, Next in the carousels, a binder page turn, a switch of display, a pan to the card in the wall, story and atlas. On when the attribute is missing; reduced motion always wins. One shared timing, CSS transforms and one-shot animations, nothing running when idle. Moves with it on and off end in exactly the same place.
12
12
  - Not done: dealing more than one card at a time, a pile that fills up with the whole discard history (the pile shows the last ten), wear on the cards of a fan.
13
13
 
14
+ ## Items that are not cards (0.9.0)
15
+
16
+ An item says what it is with `kind` (`"card"`, the default, or `"object"`; see `docs/collection-input.md`). A card is flat and thin with a back, so everything that turns it, shows its back or lands it turned over applies to it, exactly as before. An object (a picture of a games console, say) has no back and no thickness, so none of that applies:
17
+
18
+ - a collection with no card in it offers no Angle, Tilt, Auto-turn or Front, ignores `yaw` and `tilt` in the address and in the controls, and does not offer the "turned over" landing;
19
+ - in a mixed collection the controls are there for the cards; each object stays square to the reader (it turns the other way by as much as the view turns) and lands facing up whatever `deck-land` says;
20
+ - a flight never turns an object over, and no card back is drawn for it;
21
+ - fanning open and taking one off a pile are kept for objects: a fan is a flat layout (each item leans in the plane of the page, nothing turns over) and taking one off only moves it across, so both stay true to a console on a table.
22
+
14
23
  ## Zoom, Fit and move (every view)
15
24
 
16
25
  Every view has the shared view controls (`@johnmorrisdotca/kazoku-ui`) on the view: zoom out, 2×, zoom in, **Fit**, and, zoomed in, an arrow pad. Ctrl or Command with the wheel, a trackpad pinch and a two-finger pinch zoom about the pointer; zoomed in, a drag or the wheel moves the view. The views are flat, so none turns in 3D and the angle, tilt and auto-turn controls are hidden.
@@ -62,12 +71,9 @@ Options
62
71
  - Support a responsive alternative for small displays and large collections; avoid rendering a separate active 3D viewer per card at once. The host controls the collection and card content.
63
72
  - Research: [angled modular display risers](https://boxboy.co/products/modular-display-risers), [staggered rear rows](https://dhoptcg.com/?product=glass-display-shelves), and [a 13-column, 7-row cabinet](https://www.jz-shop.com.tw/en/graded-card-display-case-slim). These examples show different capacities, so dimensions and overlap should remain adjustable.
64
73
 
65
- ## Jukebox-style display
74
+ ## Jukebox-style display (dropped in 0.8.0)
66
75
 
67
- - Present the collection inside a jukebox-like device. Browse cards in the device, then select a card to bring it into a focused view.
68
- - Provide a clear way back to browsing and preserve the selected card and collection position.
69
- - Keep card flip and interactive content controls separate from the device navigation; make browse and selection usable by keyboard, touch, and pointer.
70
- - Allow the host to configure device styling and the cards supplied. Support a reduced-motion alternative to mechanical animations.
76
+ A jukebox plays records, not cards, and the display drew the deck's pile of three cards, so it was removed (see the real-life audit above). `view="jukebox"` still opens the deck.
71
77
 
72
78
  ## Feeling lucky
73
79
 
@@ -22,12 +22,14 @@ An example supported collection format:
22
22
  "name": "Starship Block 3",
23
23
  "image": "https://example.com/starship-front.jpg",
24
24
  "backImage": "https://example.com/starship-back.jpg",
25
+ "kind": "card",
25
26
  "metadata": { "year": 2026, "number": "001" }
26
27
  }
27
28
  ]
28
29
  }
29
30
  ```
30
31
 
32
+ - **What an item is.** `kind` is `"card"` (the default: a collection written without it is all cards, as before) or `"object"`. A card is flat and thin with a back, so it turns in 3D, can be seen from behind and lands turned over when taken off a pile. An object is a picture of a thing that is not a card (a games console, a trophy): it has no back and no thickness, so it never turns over, is never seen edge-on or from behind, and always lands facing up. No angle, tilt, Auto-turn or "turned over" landing is offered for a collection with no card in it, and an angle in the address is dropped. In a mixed collection the controls are there for the cards, and the objects stay square to the reader. Objects can still be fanned open (a flat layout) and taken off a pile (they fly across and land facing up). A real 3D object would be a third kind, once an item can carry one.
31
33
  - Represent photographed or scanned cards as full-card front and back images, so collectors can display what they already own. Alternatively, use a Fuda frame with a separate image or host-provided interactive artwork in its window.
32
34
  - Keep collector details optional: set, year, card number, edition, condition, grade, quantity, notes, and other metadata. Do not assume every item has a market price or grade.
33
35
  - Provide stable IDs for selection and navigation; validate malformed input and report errors without discarding valid cards.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@johnmorrisdotca/fuda-cards",
3
- "version": "0.8.0",
3
+ "version": "0.9.1",
4
4
  "description": "Fuda Cards: collectible card frames for images and interactive 3D content.",
5
5
  "type": "module",
6
6
  "sideEffects": [