ezal-theme-example 0.0.1 → 0.0.3

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.
@@ -152,12 +152,13 @@ export function initFootnote() {
152
152
  }
153
153
 
154
154
  function display(image: HTMLImageElement) {
155
- const { top, left, width } = image.getBoundingClientRect();
156
- const boxFrame = { background: '#0000' };
157
- const frame = { top: `${top}px`, left: `${left}px`, width: `${width}px` };
158
- const defaultDuration: number = 100;
155
+ const { top, left, width, height } = image.getBoundingClientRect();
159
156
  const naturalWidth = image.naturalWidth;
160
157
  const naturalHeight = image.naturalHeight;
158
+ const realWidth = (naturalWidth / naturalHeight) * height;
159
+ const realLeft = left + (width - realWidth) / 2;
160
+ const boxFrame = { background: '#0000' };
161
+ const defaultDuration: number = 100;
161
162
  let currentWidth = 0;
162
163
  let currentHeight = 0;
163
164
  const box = $new('div');
@@ -184,7 +185,19 @@ function display(image: HTMLImageElement) {
184
185
  hammer.get('pan').recognizeWith('pinch');
185
186
 
186
187
  const hide = () => {
187
- img.animate({ ...frame, scale: 1, translate: '0px 0px' }, defaultDuration);
188
+ const { top, left, width, height } = image.getBoundingClientRect();
189
+ const realWidth = (naturalWidth / naturalHeight) * height;
190
+ const realLeft = left + (width - realWidth) / 2;
191
+ img.animate(
192
+ {
193
+ top: `${top}px`,
194
+ left: `${realLeft}px`,
195
+ width: `${realWidth}px`,
196
+ scale: 1,
197
+ translate: '0px 0px',
198
+ },
199
+ defaultDuration,
200
+ );
188
201
  const animation = box.animate(boxFrame, defaultDuration);
189
202
  animation.onfinish = () => {
190
203
  box.remove();
@@ -231,7 +244,19 @@ function display(image: HTMLImageElement) {
231
244
  resize();
232
245
  doc.body.append(box);
233
246
  box.animate([boxFrame, {}], defaultDuration).play();
234
- img.animate([frame, {}], { duration: 300, easing: 'ease-in-out' }).play();
247
+ img
248
+ .animate(
249
+ [
250
+ {
251
+ top: `${top}px`,
252
+ left: `${realLeft}px`,
253
+ width: `${realWidth}px`,
254
+ },
255
+ {},
256
+ ],
257
+ { duration: 300, easing: 'ease-in-out' },
258
+ )
259
+ .play();
235
260
  image.style.opacity = '0';
236
261
 
237
262
  let dragging = false;
@@ -1,7 +1,6 @@
1
1
  p img
2
2
  max-width 100%
3
3
  max-height 80vh
4
- width auto
5
4
  height auto
6
5
  vertical-align middle
7
6
  transition .1s background
@@ -14,7 +14,10 @@ function resolveFavicons(): [type: string, href: string][] {
14
14
  }
15
15
 
16
16
  const favicons = resolveFavicons();
17
- const title = page.title ? `${page.title} - ${site.title}` : site.title;
17
+ const title =
18
+ page.title && page.layout !== 'home'
19
+ ? `${page.title} - ${site.title}`
20
+ : site.title;
18
21
  const description = page.description ?? site.description;
19
22
  const keywords = (page.keywords ?? site.keywords ?? []).join(',');
20
23
  const canonicalUrl = URL.full(page.url);
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "ezal-theme-example",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "author": "jonnyjong",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "peerDependencies": {
9
- "ezal": "^3.0.0"
9
+ "ezal": "^3.0.1"
10
10
  },
11
11
  "engines": {
12
12
  "node": ">=22"