hexo-theme-linen 1.0.37 → 1.0.39
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/layout/post.ejs
CHANGED
|
@@ -289,6 +289,15 @@ const seriesInfo = getSeriesInfo(page?.series);
|
|
|
289
289
|
return viewportSize.x < 700 ? smallScreenPadding : largeScreenPadding
|
|
290
290
|
},
|
|
291
291
|
});
|
|
292
|
+
const isSafari = !!(navigator.vendor && navigator.vendor.match(/apple/i));
|
|
293
|
+
lightbox.on('lazyLoadSlide', (event) => {
|
|
294
|
+
const imageSrc = event.itemData && event.itemData.src;
|
|
295
|
+
if (isSafari && imageSrc && imageSrc.includes('/hdr/')) {
|
|
296
|
+
// Let PhotoSwipe's main Content create and reuse its placeholder image.
|
|
297
|
+
// The bundled Lightbox preloader uses a separate, older Content class.
|
|
298
|
+
event.preventDefault();
|
|
299
|
+
}
|
|
300
|
+
});
|
|
292
301
|
|
|
293
302
|
const getExif = (element) => {
|
|
294
303
|
const exifString = (element && element.dataset && element.dataset.pspwExif) || '';
|
package/package.json
CHANGED
|
@@ -170,6 +170,17 @@ function decodeImage(img) {
|
|
|
170
170
|
});
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
+
function areImageSourcesEqual(first, second) {
|
|
174
|
+
if (!first || !second) {
|
|
175
|
+
return false;
|
|
176
|
+
}
|
|
177
|
+
try {
|
|
178
|
+
return new URL(first, document.baseURI).href === new URL(second, document.baseURI).href;
|
|
179
|
+
} catch (error) {
|
|
180
|
+
return first === second;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
173
184
|
/** @typedef {LOAD_STATE[keyof LOAD_STATE]} LoadState */
|
|
174
185
|
/** @type {{ IDLE: 'idle'; LOADING: 'loading'; LOADED: 'loaded'; ERROR: 'error' }} */
|
|
175
186
|
const LOAD_STATE = {
|
|
@@ -4574,13 +4585,43 @@ class Content {
|
|
|
4574
4585
|
) {
|
|
4575
4586
|
return;
|
|
4576
4587
|
}
|
|
4577
|
-
|
|
4588
|
+
let imageElement = /** @type HTMLImageElement */ this.element;
|
|
4589
|
+
let reusingPlaceholder = false;
|
|
4590
|
+
const isHdrImage = this.data.src && this.data.src.includes("/hdr/");
|
|
4591
|
+
const placeholderElement = this.placeholder && this.placeholder.element;
|
|
4592
|
+
// Safari can flash when it swaps between two separate image layers,
|
|
4593
|
+
// even when the placeholder and the full-size HDR image use the same URL.
|
|
4594
|
+
// Reuse the placeholder so HDR is never decoded through HTMLImageElement.decode().
|
|
4595
|
+
if (
|
|
4596
|
+
isSafari() &&
|
|
4597
|
+
isHdrImage &&
|
|
4598
|
+
!this.data.srcset &&
|
|
4599
|
+
placeholderElement &&
|
|
4600
|
+
placeholderElement.tagName === "IMG" &&
|
|
4601
|
+
areImageSourcesEqual(placeholderElement.src, this.data.src)
|
|
4602
|
+
) {
|
|
4603
|
+
imageElement = /** @type HTMLImageElement */ placeholderElement;
|
|
4604
|
+
imageElement.classList.remove("pswp__img--placeholder");
|
|
4605
|
+
imageElement.removeAttribute("aria-hidden");
|
|
4606
|
+
imageElement.removeAttribute("role");
|
|
4607
|
+
imageElement.style.width = "";
|
|
4608
|
+
imageElement.style.height = "";
|
|
4609
|
+
imageElement.style.transform = "";
|
|
4610
|
+
imageElement.style.transformOrigin = "";
|
|
4611
|
+
setWidthHeight(imageElement, this.displayedImageWidth, this.displayedImageHeight);
|
|
4612
|
+
this.element = imageElement;
|
|
4613
|
+
this.placeholder.element = null;
|
|
4614
|
+
this.placeholder = undefined;
|
|
4615
|
+
reusingPlaceholder = true;
|
|
4616
|
+
}
|
|
4578
4617
|
this.updateSrcsetSizes();
|
|
4579
|
-
if (this.data.srcset) {
|
|
4618
|
+
if (this.data.srcset && !reusingPlaceholder) {
|
|
4580
4619
|
imageElement.srcset = this.data.srcset;
|
|
4581
4620
|
}
|
|
4582
|
-
|
|
4583
|
-
|
|
4621
|
+
if (!reusingPlaceholder) {
|
|
4622
|
+
imageElement.src =
|
|
4623
|
+
(_this$data$src = this.data.src) !== null && _this$data$src !== void 0 ? _this$data$src : "";
|
|
4624
|
+
}
|
|
4584
4625
|
imageElement.alt =
|
|
4585
4626
|
(_this$data$alt = this.data.alt) !== null && _this$data$alt !== void 0 ? _this$data$alt : "";
|
|
4586
4627
|
this.state = LOAD_STATE.LOADING;
|