From 26f2c1b4e30778e1eb0625e5cc21b2d146cf734d Mon Sep 17 00:00:00 2001 From: Dylan Lin Date: Fri, 12 Aug 2022 17:15:32 +0800 Subject: [PATCH 1/3] 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]}' From d12f5be271abb03be443d0e5219a8a94e15eef44 Mon Sep 17 00:00:00 2001 From: Dylan Lin Date: Sat, 13 Aug 2022 02:29:20 +0800 Subject: [PATCH 2/3] docs: add default Effect Speed Options of Subtitle in _config.yml --- _config.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/_config.yml b/_config.yml index dcafa69..a5ffaba 100644 --- a/_config.yml +++ b/_config.yml @@ -619,6 +619,10 @@ subtitle: enable: false # Typewriter Effect (打字效果) effect: true + # Effect Speed Options (打字效果速度參數) + startDelay: 300 # time before typing starts in milliseconds + typeSpeed: 150 # type speed in milliseconds + backSpeed: 50 # backspacing speed in milliseconds # loop (循環打字) loop: true # source 調用第三方服務 @@ -631,6 +635,7 @@ subtitle: # 如果關閉打字效果,subtitle 只會顯示 sub 的第一行文字 sub: + # Loading Animation (加載動畫) preloader: false From 8cfa1665b9c8795461c8adb7945e4a8445d3db4b Mon Sep 17 00:00:00 2001 From: Jerry Wong Date: Sat, 13 Aug 2022 12:59:53 +0800 Subject: [PATCH 3/3] Update subtitle.pug --- layout/includes/third-party/subtitle.pug | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/layout/includes/third-party/subtitle.pug b/layout/includes/third-party/subtitle.pug index d7cec58..9236757 100644 --- a/layout/includes/third-party/subtitle.pug +++ b/layout/includes/third-party/subtitle.pug @@ -1,7 +1,4 @@ -- 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 +- const { effect,loop,source,sub,startDelay,typeSpeed,backSpeed } = theme.subtitle - let subContent = sub || new Array() case source