vistaview 2.0.1 → 2.0.2

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.
Files changed (2) hide show
  1. package/README.md +206 -14
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,32 +1,224 @@
1
1
  # VistaView
2
2
 
3
- A lightweight, zero-dependency image lightbox library with smooth animations and touch support.
3
+ A lightweight, zero-dependency image lightbox with smooth animations, touch/pinch support, zoom, and an extension system. Works with vanilla JS or any framework.
4
4
 
5
- ## Packages
5
+ **[Documentation](https://vistaview.jujiplay.com)**
6
6
 
7
- | Path | Description |
8
- |------|-------------|
9
- | `main/` | Core library |
10
- | `frameworks/` | React, Vue, Svelte, Solid bindings |
11
- | `extensions/` | Optional plugins (video, maps, UI) |
12
- | `doc/` | Documentation site (Astro + Starlight) |
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install vistaview
11
+ # yarn add vistaview
12
+ # pnpm add vistaview
13
+ ```
14
+
15
+ ## Quick Start
16
+
17
+ ```html
18
+ <div id="gallery">
19
+ <a href="/images/photo1-full.jpg">
20
+ <img src="/images/photo1-thumb.jpg" alt="Photo 1" />
21
+ </a>
22
+ <a href="/images/photo2-full.jpg">
23
+ <img src="/images/photo2-thumb.jpg" alt="Photo 2" />
24
+ </a>
25
+ </div>
26
+ ```
27
+
28
+ ```js
29
+ import { vistaView } from 'vistaview';
30
+ import 'vistaview/style.css';
31
+
32
+ const gallery = vistaView({ elements: '#gallery a' });
33
+ ```
34
+
35
+ You can also pass an array of objects instead of a CSS selector:
36
+
37
+ ```js
38
+ vistaView({
39
+ elements: [
40
+ { src: '/images/photo1.jpg', alt: 'Photo 1' },
41
+ { src: '/images/photo2.jpg', alt: 'Photo 2', srcSet: '/images/photo2-800.jpg 800w, /images/photo2-1200.jpg 1200w' },
42
+ ],
43
+ });
44
+ ```
45
+
46
+ ### CDN (no bundler)
47
+
48
+ ```html
49
+ <link rel="stylesheet" href="https://unpkg.com/vistaview/main/dist/style.css" />
50
+ <script src="https://unpkg.com/vistaview/main/dist/vistaview.umd.js"></script>
51
+ <script>
52
+ VistaView.vistaView({ elements: '#gallery a' });
53
+ </script>
54
+ ```
55
+
56
+ ## API
57
+
58
+ `vistaView(options)` returns an instance with these methods:
59
+
60
+ | Method | Description |
61
+ |--------|-------------|
62
+ | `open(index?)` | Open the lightbox, optionally at a given index |
63
+ | `close()` | Close the lightbox (returns Promise) |
64
+ | `next()` | Go to the next image |
65
+ | `prev()` | Go to the previous image |
66
+ | `view(index)` | Jump to a specific index |
67
+ | `getCurrentIndex()` | Returns the current index |
68
+ | `zoomIn()` | Zoom in |
69
+ | `zoomOut()` | Zoom out |
70
+ | `reset()` | Re-scan elements (call after DOM changes) |
71
+ | `destroy()` | Tear down the instance and remove listeners |
72
+
73
+ ### Options
74
+
75
+ ```ts
76
+ vistaView({
77
+ elements: '#gallery a', // CSS selector or VistaImgConfig[]
78
+ animationDurationBase: 300, // Base animation duration in ms
79
+ maxZoomLevel: 2, // Maximum zoom multiplier
80
+ preloads: 1, // Number of adjacent images to preload
81
+ keyboardListeners: true, // Enable arrow/escape key navigation
82
+ arrowOnSmallScreens: false, // Show nav arrows on small screens
83
+ controls: {
84
+ topLeft: ['indexDisplay'],
85
+ topRight: ['zoomIn', 'zoomOut', 'close'],
86
+ bottomLeft: ['description'],
87
+ },
88
+ extensions: [],
89
+ onOpen: (vistaView) => {},
90
+ onClose: (vistaView) => {},
91
+ onImageView: (data, vistaView) => {},
92
+ onContentChange: (content, vistaView) => {},
93
+ });
94
+ ```
95
+
96
+ ## Framework Bindings
97
+
98
+ ### React
99
+
100
+ ```tsx
101
+ import { VistaView } from 'vistaview/react';
102
+ import 'vistaview/style.css';
103
+
104
+ function Gallery() {
105
+ return (
106
+ <VistaView selector="> a">
107
+ <a href="/images/full.jpg"><img src="/images/thumb.jpg" alt="Photo" /></a>
108
+ </VistaView>
109
+ );
110
+ }
111
+ ```
112
+
113
+ For imperative control, use the ref:
114
+
115
+ ```tsx
116
+ import { useRef } from 'react';
117
+ import { VistaView } from 'vistaview/react';
118
+ import type { VistaComponentRef } from 'vistaview/react';
119
+
120
+ const ref = useRef<VistaComponentRef>(null);
121
+ // ref.current.vistaView.open(0)
122
+ <VistaView ref={ref} selector="> a">...</VistaView>
123
+ ```
124
+
125
+ Or use the hook directly:
126
+
127
+ ```tsx
128
+ import { useVistaView } from 'vistaview/react';
129
+
130
+ const gallery = useVistaView({ elements: '#gallery > a' });
131
+ ```
132
+
133
+ > Add `'use client'` at the top of the file when using Next.js or other RSC frameworks.
134
+
135
+ ### Vue
136
+
137
+ ```vue
138
+ <script setup>
139
+ import { VistaView } from 'vistaview/vue';
140
+ import 'vistaview/style.css';
141
+ </script>
142
+
143
+ <template>
144
+ <VistaView selector="> a">
145
+ <a href="/images/full.jpg"><img src="/images/thumb.jpg" alt="Photo" /></a>
146
+ </VistaView>
147
+ </template>
148
+ ```
149
+
150
+ ### Svelte
151
+
152
+ ```svelte
153
+ <script>
154
+ import { VistaView } from 'vistaview/svelte';
155
+ import 'vistaview/style.css';
156
+ </script>
157
+
158
+ <VistaView selector="> a">
159
+ <a href="/images/full.jpg"><img src="/images/thumb.jpg" alt="Photo" /></a>
160
+ </VistaView>
161
+ ```
162
+
163
+ ### Solid
164
+
165
+ ```tsx
166
+ import { VistaView } from 'vistaview/solid';
167
+ import 'vistaview/style.css';
168
+
169
+ function Gallery() {
170
+ return (
171
+ <VistaView selector="> a">
172
+ <a href="/images/full.jpg"><img src="/images/thumb.jpg" alt="Photo" /></a>
173
+ </VistaView>
174
+ );
175
+ }
176
+ ```
13
177
 
14
178
  ## Extensions
15
179
 
16
- Public extensions are documented at [opencode.ai](https://opencode.ai). Some extensions exist in the repo but are **not publicly documented** they are available for use but don't appear in the sidebar or have dedicated doc pages (`select-box`, `twitch-video`).
180
+ Extensions are passed in the `extensions` array and can optionally add controls to the toolbar.
17
181
 
18
- ## Quick Start
182
+ ```js
183
+ import { vistaView } from 'vistaview';
184
+ import { download } from 'vistaview/extensions/download';
185
+ import 'vistaview/style.css';
186
+
187
+ vistaView({
188
+ elements: '#gallery a',
189
+ controls: { topRight: ['zoomIn', 'zoomOut', 'download', 'close'] },
190
+ extensions: [download()],
191
+ });
192
+ ```
193
+
194
+ Available extensions:
195
+
196
+ | Import path | Description |
197
+ |-------------|-------------|
198
+ | `vistaview/extensions/download` | Download button for the current image |
199
+ | `vistaview/extensions/youtube-video` | Embed YouTube videos |
200
+ | `vistaview/extensions/vimeo-video` | Embed Vimeo videos |
201
+ | `vistaview/extensions/dailymotion-video` | Embed Dailymotion videos |
202
+ | `vistaview/extensions/streamable-video` | Embed Streamable videos |
203
+ | `vistaview/extensions/vidyard-video` | Embed Vidyard videos |
204
+ | `vistaview/extensions/wistia-video` | Embed Wistia videos |
205
+ | `vistaview/extensions/google-maps` | Embed Google Maps |
206
+ | `vistaview/extensions/mapbox` | Embed Mapbox maps |
207
+ | `vistaview/extensions/openstreetmap` | Embed OpenStreetMap |
208
+ | `vistaview/extensions/image-story` | Instagram-style story layout |
209
+ | `vistaview/extensions/logger` | Debug logging |
210
+
211
+ ## Development
19
212
 
20
213
  ```bash
21
214
  pnpm install
22
215
  pnpm dev
23
216
  ```
24
217
 
25
- ## Test
26
-
27
218
  ```bash
28
- pnpm test:core # Core library (170 tests)
29
- pnpm test # All workspace packages with test scripts
219
+ pnpm test:core # Core library tests
220
+ pnpm test # All packages
221
+ pnpm test:e2e # Playwright end-to-end tests
30
222
  ```
31
223
 
32
224
  ## License
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vistaview",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "A lightweight, zero-dependency image lightbox library with smooth animations and touch support",
5
5
  "keywords": [
6
6
  "image",