adding typeit
This commit is contained in:
parent
d14aa8aa6b
commit
b62229a693
2
static/js/typeit.umd.js
Normal file
2
static/js/typeit.umd.js
Normal file
File diff suppressed because one or more lines are too long
37
templates/shortcodes/typeit.html
Normal file
37
templates/shortcodes/typeit.html
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
{{- $content := split .Inner "\n" -}}
|
||||||
|
{{- $initialString := .Get "initialString" | default "" -}}
|
||||||
|
{{- $speed := .Get "speed" | default 100 -}}
|
||||||
|
{{- $lifeLike := .Get "lifeLike" | default false -}}
|
||||||
|
{{- $startDelay := .Get "startDelay" | default 0 -}}
|
||||||
|
{{- $breakLines := .Get "breakLines" | default true -}}
|
||||||
|
{{- $waitUntilVisible := .Get "waitUntilVisible" | default true -}}
|
||||||
|
{{- $loop := .Get "loop" | default false -}}
|
||||||
|
|
||||||
|
{{- $classList := slice -}}
|
||||||
|
{{- with .Get "class" -}}
|
||||||
|
{{- $classList = $classList | append . -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- $tag := .Get "tag" | default "div" -}}
|
||||||
|
|
||||||
|
{{ $id := delimit (slice "typeit" .Ordinal now.UnixNano) "-" }}
|
||||||
|
|
||||||
|
{{- $attrs := printf `id="%v"` $id -}}
|
||||||
|
{{- with $classList -}}
|
||||||
|
{{- $attrs = delimit $classList " " | printf `%v class="%v"` $attrs -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{ printf `<%v %v>%s</%v>` $tag $attrs $initialString $tag | safeHTML }}
|
||||||
|
|
||||||
|
<script>
|
||||||
|
document.addEventListener("DOMContentLoaded", function () {
|
||||||
|
new TypeIt("#{{ $id }}", {
|
||||||
|
strings: {{ $content }},
|
||||||
|
speed: {{ $speed }},
|
||||||
|
lifeLike: {{ $lifeLike }},
|
||||||
|
startDelay: {{ $startDelay }},
|
||||||
|
breakLines: {{ $breakLines }},
|
||||||
|
waitUntilVisible: {{ $waitUntilVisible }},
|
||||||
|
loop: {{ $loop }}
|
||||||
|
}).go();
|
||||||
|
});
|
||||||
|
</script>
|
Loading…
Reference in a new issue