mirror of
https://github.com/cotes2020/jekyll-theme-chirpy.git
synced 2025-12-19 06:06:54 +00:00
feat(ui): show preview image in home page
This commit is contained in:
@@ -1,27 +0,0 @@
|
||||
/**
|
||||
* Set up image stuff
|
||||
*/
|
||||
|
||||
export function imgExtra() {
|
||||
if ($('#core-wrapper img[data-src]') <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* See: <https://github.com/dimsemenov/Magnific-Popup> */
|
||||
$('.popup').magnificPopup({
|
||||
type: 'image',
|
||||
closeOnContentClick: true,
|
||||
showCloseBtn: false,
|
||||
zoom: {
|
||||
enabled: true,
|
||||
duration: 300,
|
||||
easing: 'ease-in-out'
|
||||
}
|
||||
});
|
||||
|
||||
/* Stop shimmer when image loaded */
|
||||
document.addEventListener('lazyloaded', function (e) {
|
||||
const $img = $(e.target);
|
||||
$img.parent().removeClass('shimmer');
|
||||
});
|
||||
}
|
||||
15
_javascript/modules/components/img-lazyload.js
Normal file
15
_javascript/modules/components/img-lazyload.js
Normal file
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Set up image lazy-load
|
||||
*/
|
||||
|
||||
export function imgLazy() {
|
||||
if ($('#core-wrapper img[data-src]') <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Stop shimmer when image loaded */
|
||||
document.addEventListener('lazyloaded', function (e) {
|
||||
const $img = $(e.target);
|
||||
$img.parent().removeClass('shimmer');
|
||||
});
|
||||
}
|
||||
22
_javascript/modules/components/img-popup.js
Normal file
22
_javascript/modules/components/img-popup.js
Normal file
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Set up image popup
|
||||
*
|
||||
* See: https://github.com/dimsemenov/Magnific-Popup
|
||||
*/
|
||||
|
||||
export function imgPopup() {
|
||||
if ($('.popup') <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
$('.popup').magnificPopup({
|
||||
type: 'image',
|
||||
closeOnContentClick: true,
|
||||
showCloseBtn: false,
|
||||
zoom: {
|
||||
enabled: true,
|
||||
duration: 300,
|
||||
easing: 'ease-in-out'
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -174,13 +174,7 @@ function displayPageviews(data) {
|
||||
let hasInit = getInitStatus();
|
||||
const rows = data.rows; /* could be undefined */
|
||||
|
||||
if ($('#post-list').length > 0) {
|
||||
/* the Home page */
|
||||
$('.post-preview').each(function () {
|
||||
const path = $(this).find('a').attr('href');
|
||||
tacklePV(rows, path, $(this).find('.pageviews'), hasInit);
|
||||
});
|
||||
} else if ($('.post').length > 0) {
|
||||
if ($('.post').length > 0) {
|
||||
/* the post */
|
||||
const path = window.location.pathname;
|
||||
tacklePV(rows, path, $('#pv'), hasInit);
|
||||
|
||||
Reference in New Issue
Block a user