From 26f2c1b4e30778e1eb0625e5cc21b2d146cf734d Mon Sep 17 00:00:00 2001 From: Dylan Lin Date: Fri, 12 Aug 2022 17:15:32 +0800 Subject: [PATCH] feat: Support typewriter effect speed options of Subtitle in _config.yml --- layout/includes/third-party/subtitle.pug | 27 +++++++++++++----------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/layout/includes/third-party/subtitle.pug b/layout/includes/third-party/subtitle.pug index 63915ec..d7cec58 100644 --- a/layout/includes/third-party/subtitle.pug +++ b/layout/includes/third-party/subtitle.pug @@ -1,4 +1,7 @@ - const { effect,loop,source,sub } = theme.subtitle +- const startDelay = theme.subtitle.startDelay ?? 300 +- const typeSpeed = theme.subtitle.typeSpeed ?? 150 +- const backSpeed = theme.subtitle.backSpeed ?? 50 - let subContent = sub || new Array() case source @@ -14,10 +17,10 @@ case source sub.unshift(data.hitokoto, from) window.typed = new Typed('#subtitle', { strings: sub, - startDelay: 300, - typeSpeed: 150, + startDelay: !{startDelay}, + typeSpeed: !{typeSpeed}, loop: !{loop}, - backSpeed: 50, + backSpeed: !{backSpeed}, }) } else { document.getElementById('subtitle').innerHTML = data.hitokoto @@ -46,10 +49,10 @@ case source sub.unshift(con, from) window.typed = new Typed('#subtitle', { strings: sub, - startDelay: 300, - typeSpeed: 150, + startDelay: !{startDelay}, + typeSpeed: !{typeSpeed}, loop: !{loop}, - backSpeed: 50, + backSpeed: !{backSpeed}, }) } else { document.getElementById('subtitle').innerHTML = con @@ -78,10 +81,10 @@ case source sub.unshift(content) window.typed = new Typed('#subtitle', { strings: sub, - startDelay: 300, - typeSpeed: 150, + startDelay: !{startDelay}, + typeSpeed: !{typeSpeed}, loop: !{loop}, - backSpeed: 50, + backSpeed: !{backSpeed}, }) } else { document.getElementById('subtitle').innerHTML = result.data.content @@ -107,10 +110,10 @@ case source if (!{effect}) { window.typed = new Typed("#subtitle", { strings: !{JSON.stringify(subContent)}, - startDelay: 300, - typeSpeed: 150, + startDelay: !{startDelay}, + typeSpeed: !{typeSpeed}, loop: !{loop}, - backSpeed: 50 + backSpeed: !{backSpeed} }) } else { document.getElementById("subtitle").innerHTML = '!{subContent[0]}'