mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-16 17:30:53 +08:00
✨ 評論增加lazyload
✨ 頭像/打賞圖片 增加lazyload ✨ 調整移動端 ol ul 的邊距 #267 🐛 修復Valine 的requiredFields設置為空 無效的bugs
This commit is contained in:
@@ -108,10 +108,24 @@ const initJustifiedGallery = function (selector) {
|
||||
})
|
||||
}
|
||||
|
||||
const diffDate = function (d) {
|
||||
const diffDate = d => {
|
||||
const dateNow = new Date()
|
||||
const datePost = new Date(d.replace(/-/g, '/'))
|
||||
const dateDiff = dateNow.getTime() - datePost.getTime()
|
||||
const dayDiff = Math.floor(dateDiff / (24 * 3600 * 1000))
|
||||
return dayDiff
|
||||
}
|
||||
|
||||
const loadComment = (dom, callback) => {
|
||||
if ('IntersectionObserver' in window) {
|
||||
const observerItem = new IntersectionObserver((entries) => {
|
||||
if (entries[0].isIntersecting) {
|
||||
callback()
|
||||
observerItem.disconnect()
|
||||
}
|
||||
}, { threshold: [0] })
|
||||
observerItem.observe(dom)
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user