mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-16 17:30:53 +08:00
feat: 替換 Justified Gallery 為 flickr-justified-gallery
feat: 完全移除 jquery feat: 清除配置文件的CDN, 默認 CDN 不再顯示在 config feat: 切換夜間模式後, mermaid 也會切換夜間主題 feat: 移除騰訊分析 feat: 移除右下角字體調整按鈕 feat: 本地搜索可處理 json feat: 右下角按鈕自定義順序 feat: 右小角按鈕 UI 微調 improvement: 手機端更改閲讀模式退出按鈕到右下角 improvement: photofigcaption 和 fancybox 的 figcaption 優先顯示 圖片的title屬性,然後是 alt 屬性 improvement: 首頁ui微調 improvement: 禁止一些瀏覽器會出現點擊左下角按鈕出現放大網頁的行為 improvement: js 優化 fix: 修復窗口大小改變時,導航欄的ui 可能會錯亂的 bug fix: 修復 pjax 下, twikoo 評論獲取是上一篇評論的 bug fix: 壓縮 html 代碼後, mermaid 顯示正常
This commit is contained in:
@@ -72,20 +72,6 @@ const btf = {
|
||||
})
|
||||
},
|
||||
|
||||
initJustifiedGallery: function (selector) {
|
||||
if (!(selector instanceof jQuery)) {
|
||||
selector = $(selector)
|
||||
}
|
||||
selector.each(function (i, o) {
|
||||
if ($(this).is(':visible')) {
|
||||
$(this).justifiedGallery({
|
||||
rowHeight: 220,
|
||||
margins: 4
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
diffDate: (d, more = false) => {
|
||||
const dateNow = new Date()
|
||||
const datePost = new Date(d)
|
||||
@@ -135,15 +121,11 @@ const btf = {
|
||||
}
|
||||
},
|
||||
|
||||
scrollToDest: (pos, time) => {
|
||||
if (pos < 0 || time < 0) {
|
||||
return
|
||||
}
|
||||
|
||||
const currentPos = window.scrollY || window.screenTop
|
||||
scrollToDest: (pos, time = 500) => {
|
||||
const currentPos = window.pageYOffset
|
||||
if (currentPos > pos) pos = pos - 70
|
||||
|
||||
if ('CSS' in window && CSS.supports('scroll-behavior', 'smooth')) {
|
||||
if ('scrollBehavior' in document.documentElement.style) {
|
||||
window.scrollTo({
|
||||
top: pos,
|
||||
behavior: 'smooth'
|
||||
@@ -152,25 +134,19 @@ const btf = {
|
||||
}
|
||||
|
||||
let start = null
|
||||
time = time || 500
|
||||
pos = +pos
|
||||
window.requestAnimationFrame(function step (currentTime) {
|
||||
start = !start ? currentTime : start
|
||||
const progress = currentTime - start
|
||||
if (currentPos < pos) {
|
||||
const progress = currentTime - start
|
||||
window.scrollTo(0, ((pos - currentPos) * progress / time) + currentPos)
|
||||
if (progress < time) {
|
||||
window.requestAnimationFrame(step)
|
||||
} else {
|
||||
window.scrollTo(0, pos)
|
||||
}
|
||||
} else {
|
||||
const progress = currentTime - start
|
||||
window.scrollTo(0, currentPos - ((currentPos - pos) * progress / time))
|
||||
if (progress < time) {
|
||||
window.requestAnimationFrame(step)
|
||||
} else {
|
||||
window.scrollTo(0, pos)
|
||||
}
|
||||
}
|
||||
if (progress < time) {
|
||||
window.requestAnimationFrame(step)
|
||||
} else {
|
||||
window.scrollTo(0, pos)
|
||||
}
|
||||
})
|
||||
},
|
||||
@@ -226,14 +202,6 @@ const btf = {
|
||||
}
|
||||
},
|
||||
|
||||
isJqueryLoad: fn => {
|
||||
if (typeof jQuery === 'undefined') {
|
||||
getScript(GLOBAL_CONFIG.source.jQuery).then(fn)
|
||||
} else {
|
||||
fn()
|
||||
}
|
||||
},
|
||||
|
||||
isHidden: ele => ele.offsetHeight === 0 && ele.offsetWidth === 0,
|
||||
|
||||
getEleTop: ele => {
|
||||
@@ -265,14 +233,35 @@ const btf = {
|
||||
ele.forEach(i => {
|
||||
if (i.parentNode.tagName !== 'A') {
|
||||
const dataSrc = i.dataset.lazySrc || i.src
|
||||
const dataCaption = i.alt || ''
|
||||
const dataCaption = i.title || i.alt || ''
|
||||
btf.wrap(i, 'a', { href: dataSrc, 'data-fancybox': 'gallery', 'data-caption': dataCaption, 'data-thumb': dataSrc })
|
||||
}
|
||||
})
|
||||
|
||||
Fancybox.bind('[data-fancybox]', {
|
||||
Hash: false
|
||||
})
|
||||
if (!window.fancyboxRun) {
|
||||
Fancybox.bind('[data-fancybox]', {
|
||||
Hash: false,
|
||||
Thumbs: {
|
||||
autoStart: false
|
||||
}
|
||||
})
|
||||
window.fancyboxRun = true
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
initJustifiedGallery: function (selector) {
|
||||
selector.forEach(function (i) {
|
||||
if (!btf.isHidden(i)) {
|
||||
fjGallery(i, {
|
||||
itemSelector: '.fj-gallery-item',
|
||||
rowHeight: 220,
|
||||
gutter: 4,
|
||||
onJustify: function () {
|
||||
this.$container.style.opacity = '1'
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user