Skip to content

Commit

Permalink
Improved random
Browse files Browse the repository at this point in the history
  • Loading branch information
oliver-butterley committed Jan 6, 2024
1 parent 99e24e4 commit 1b5da2b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 28 deletions.
37 changes: 19 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions site/helpers/RandomList.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { random } from "./random";
import { useIdle, useIntervalFn } from "@vueuse/core";
import { useIntervalFn } from "@vueuse/core";
import { ref, onMounted } from "vue";
interface Item {
Expand All @@ -14,13 +14,10 @@ const props = defineProps<{
interval?: number;
}>();
const { idle, lastActive } = useIdle(100); // 1/10 sec
const items = ref(props.items);
function randomize() {
if (idle.value) {
items.value = random(items.value);
}
items.value = random(items.value);
}
onMounted(randomize);
Expand Down
7 changes: 2 additions & 5 deletions site/helpers/TeamPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
<script setup lang="ts">
import { VPTeamPage, VPTeamPageTitle, VPTeamMembers } from "vitepress/theme";
import { ref } from "vue";
import { useIdle, useIntervalFn } from "@vueuse/core";
import { useIntervalFn } from "@vueuse/core";
import { type TeamMember } from "./team.data";
import { random } from "./random";
import TeamMembers from "./TeamMembers.vue";

function randomize() {
if (idle.value) {
team.value = random(team.value);
}
team.value = random(team.value);
}

const props = defineProps<{
Expand All @@ -22,7 +20,6 @@ const props = defineProps<{
}>();

const team = ref(props.team);
const { idle, lastActive } = useIdle(100); // 1/10 sec
if (props.interval) {
const { pause, resume, isActive } = useIntervalFn(randomize, props.interval);
}
Expand Down

0 comments on commit 1b5da2b

Please sign in to comment.