@michaelyagi/shoji 0.1.0-beta.3 → 0.1.0-beta.6
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 +3 -3
- package/dist/core/shoji-core.js +16 -1
- package/dist/core/shoji-core.js.map +1 -1
- package/dist/core/shoji-core.min.js +1 -1
- package/dist/core/shoji-core.min.js.map +1 -1
- package/dist/esm/core/Gallery.d.ts +2 -0
- package/dist/esm/core/index.js +95 -2
- package/dist/esm/core/index.js.map +1 -1
- package/dist/esm/index.css +86 -820
- package/dist/esm/index.js +1 -1
- package/dist/esm/index2.css +819 -44
- package/dist/esm/index3.css +47 -159
- package/dist/esm/index4.css +169 -26
- package/dist/esm/index5.css +27 -0
- package/dist/esm/plugins/activeThumbnail/index.d.ts +7 -1
- package/dist/esm/plugins/activeThumbnail/index.js +55 -16
- package/dist/esm/plugins/activeThumbnail/index.js.map +1 -1
- package/dist/esm/plugins/rotateFlip/index.js +1 -1
- package/dist/esm/plugins/zoom/index.js +1 -1
- package/dist/esm/{zoomTransition-BbnYTxY-.js → zoomTransition-CQG__VzO.js} +10 -2
- package/dist/esm/zoomTransition-CQG__VzO.js.map +1 -0
- package/dist/plugins/activeThumbnail.css +99 -0
- package/dist/plugins/activeThumbnail.js +55 -17
- package/dist/plugins/activeThumbnail.js.map +1 -1
- package/dist/plugins/activeThumbnail.min.css +1 -0
- package/dist/plugins/activeThumbnail.min.js +1 -1
- package/dist/plugins/activeThumbnail.min.js.map +1 -1
- package/dist/plugins/rotateFlip.js.map +1 -1
- package/dist/plugins/rotateFlip.min.js.map +1 -1
- package/dist/plugins/zoom.js.map +1 -1
- package/dist/plugins/zoom.min.js.map +1 -1
- package/dist/shoji.css +99 -0
- package/dist/shoji.js +69 -17
- package/dist/shoji.js.map +1 -1
- package/dist/shoji.min.css +1 -1
- package/dist/shoji.min.js +1 -1
- package/dist/shoji.min.js.map +1 -1
- package/package.json +1 -1
- package/dist/esm/bodyScrollLock-CC5PJxJp.js +0 -96
- package/dist/esm/bodyScrollLock-CC5PJxJp.js.map +0 -1
- package/dist/esm/zoomTransition-BbnYTxY-.js.map +0 -1
package/README.md
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
[](https://github.com/MichaelYagi/shoji/actions/workflows/ci.yml)
|
|
4
4
|
[](https://www.npmjs.com/package/@michaelyagi/shoji)
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
> **AI-authored.** 100% of the code was written by Claude (Anthropic); I shaped the architecture, scope, and every decision, and did all the testing.
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
A zero-dependency, plugin-first TypeScript lightbox/gallery. Drop in two `<script>`/`<link>` tags, or install from npm — everything beyond the minimal lightbox, including every official plugin, is opt-in.
|
|
9
9
|
|
|
10
10
|
## Features
|
|
11
11
|
|
|
@@ -14,7 +14,7 @@ A zero-dependency, plugin-first TypeScript lightbox/gallery. Drop in two `<scrip
|
|
|
14
14
|
- **Plugin system** — zoom (pinch/pan/wheel), fullscreen, rotate/flip, autoplay/slideshow, active-thumbnail sync, YouTube video embeds, and a grid/masonry/justified layout engine, each independently opt-in.
|
|
15
15
|
- **Accessibility is not a plugin** — keyboard nav, focus trapping, ARIA roles, and screen-reader announcements live in core.
|
|
16
16
|
- **Themeable via CSS custom properties** — no hardcoded colors/sizes in JS.
|
|
17
|
-
- **
|
|
17
|
+
- **Three distributions** — single-file (`dist/shoji.js` + `dist/shoji.css`, core + every plugin, self-registering) for zero-setup `<script>` tag use; core + individual plugin files (`dist/core/shoji-core.(min.)js` + `dist/plugins/{name}.(min.)js`) for `<script>`-tag consumers who want to pick exactly which plugins ship; and tree-shakable per-plugin ESM entries for bundler users.
|
|
18
18
|
- Size-budgeted and CI-enforced: core ≤ 21 kB, each plugin ≤ 8 kB, full bundle ≤ 90 kB (all min+gzip).
|
|
19
19
|
|
|
20
20
|
## Install
|
package/dist/core/shoji-core.js
CHANGED
|
@@ -14,6 +14,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
14
14
|
let styleObserver = null;
|
|
15
15
|
let intentionalScrollOccurred = false;
|
|
16
16
|
const LIGHTBOX_SELECTOR = ".shoji-outer";
|
|
17
|
+
function markIntentionalScroll() {
|
|
18
|
+
intentionalScrollOccurred = true;
|
|
19
|
+
}
|
|
17
20
|
function isRtl() {
|
|
18
21
|
return getComputedStyle(document.documentElement).direction === "rtl";
|
|
19
22
|
}
|
|
@@ -531,8 +534,16 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
531
534
|
const translateY = to.top + to.height / 2 - (from.top + from.height / 2);
|
|
532
535
|
return `translate3d(${translateX}px, ${translateY}px, 0) scale3d(${scale}, ${scale}, 1)`;
|
|
533
536
|
}
|
|
537
|
+
function effectiveOriginBox(origin) {
|
|
538
|
+
const img = origin.querySelector("img");
|
|
539
|
+
if (img) {
|
|
540
|
+
const rect = img.getBoundingClientRect();
|
|
541
|
+
if (rect.width > 0 && rect.height > 0) return rect;
|
|
542
|
+
}
|
|
543
|
+
return origin.getBoundingClientRect();
|
|
544
|
+
}
|
|
534
545
|
function computeTransform(origin, target, aspectRatio, naturalSize) {
|
|
535
|
-
const originRect = origin
|
|
546
|
+
const originRect = effectiveOriginBox(origin);
|
|
536
547
|
const targetRect = effectiveTargetBox(target, aspectRatio, naturalSize);
|
|
537
548
|
if (targetRect.width === 0 || targetRect.height === 0 || originRect.width === 0 || originRect.height === 0) {
|
|
538
549
|
return null;
|
|
@@ -2579,6 +2590,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2579
2590
|
}
|
|
2580
2591
|
return this.scannedElements[index] ?? null;
|
|
2581
2592
|
}
|
|
2593
|
+
/** Lets a plugin's background-page `scrollIntoView()` survive `close()`'s scroll restore, routed through this shared instance rather than importing `bodyScrollLock` directly — required for the standalone core+plugins distribution, where a direct import would get its own disconnected module copy (DESIGN.md §4.2/§10). Same reasoning `getOriginElement`/`getActiveMedia` were made public for. */
|
|
2594
|
+
markIntentionalScroll() {
|
|
2595
|
+
markIntentionalScroll();
|
|
2596
|
+
}
|
|
2582
2597
|
scheduleAutoHide() {
|
|
2583
2598
|
if (this.autoHideTimer !== null) {
|
|
2584
2599
|
clearTimeout(this.autoHideTimer);
|