typeit multiple lines shuffled in random order

This commit is contained in:
suidpit
2026-02-10 12:30:17 +01:00
parent 3a9016a6d9
commit 38a04ae80b
+9 -1
View File
@@ -6,6 +6,7 @@
{{- $breakLines := .Get "breakLines" | default true -}}
{{- $waitUntilVisible := .Get "waitUntilVisible" | default true -}}
{{- $loop := .Get "loop" | default false -}}
{{- $randomLines := .Get "randomLines" | default false -}}
{{- $classList := slice -}}
{{- with .Get "class" -}}
{{- $classList = $classList | append . -}}
@@ -23,8 +24,15 @@
<script>
document.addEventListener("DOMContentLoaded", function () {
var strings = {{ $content }};
{{ if $randomLines }}
for (var i = strings.length - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
[strings[i], strings[j]] = [strings[j], strings[i]];
}
{{ end }}
new TypeIt("#{{ $id }}", {
strings: {{ $content }},
strings: strings,
speed: {{ $speed }},
lifeLike: {{ $lifeLike }},
startDelay: {{ $startDelay }},