Skip to content

Commit 269d98c

Browse files
fix: #69 — nice
1 parent daa7db8 commit 269d98c

File tree

5 files changed

+268
-5
lines changed

5 files changed

+268
-5
lines changed

docs/src/main.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ const routes: RouteRecordRaw[] = [
1313
path: "/tests-keep-alive",
1414
component: () => import("./pages/PageTestKeepAlive.vue"),
1515
},
16+
{
17+
path: "/bottom-jump-test",
18+
component: () => import("./pages/PageBottomJumpTest.vue"),
19+
},
1620
{
1721
path: "/:catchAll(.*)",
1822
redirect: "/",
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<script setup lang="ts">
2+
import { onMounted, ref } from 'vue'
3+
import { vAutoAnimate } from "../../../src/index"
4+
5+
const items = ref([1, 2, 3, 4, 5])
6+
const remove = (n: number) => (items.value = items.value.filter((item) => item !== n))
7+
const reset = () => items.value = [1, 2, 3, 4, 5]
8+
9+
const list = ref()
10+
onMounted(() => {
11+
if (list.value) {
12+
// Import the default export function
13+
import('../../../src/index').then(({ default: autoAnimate }) => {
14+
autoAnimate(list.value, { duration: 1000 })
15+
})
16+
}
17+
})
18+
</script>
19+
20+
<template>
21+
<div class="test-container">
22+
<ul ref="list" class="bottom-aligned-list">
23+
<li v-for="item in items" :key="item" class="list-item">
24+
<span>Item {{ item }}</span>
25+
<button @click="remove(item)" class="remove-btn">
26+
click to remove
27+
</button>
28+
</li>
29+
</ul>
30+
<button @click="reset" class="reset-btn">Reset list</button>
31+
</div>
32+
</template>
33+
34+
<style scoped>
35+
.test-container {
36+
position: relative;
37+
height: 100vh;
38+
padding: 20px;
39+
}
40+
41+
.bottom-aligned-list {
42+
border: 1px solid red;
43+
position: fixed;
44+
right: 0;
45+
bottom: 0;
46+
width: 120px;
47+
margin: 0;
48+
padding: 0;
49+
list-style: none;
50+
background: white;
51+
}
52+
53+
.list-item {
54+
display: block;
55+
padding: 8px;
56+
border-bottom: 1px solid #eee;
57+
}
58+
59+
.list-item:last-child {
60+
border-bottom: none;
61+
}
62+
63+
.remove-btn {
64+
display: block;
65+
width: 100%;
66+
margin-top: 4px;
67+
padding: 2px;
68+
font-size: 10px;
69+
cursor: pointer;
70+
}
71+
72+
.reset-btn {
73+
position: fixed;
74+
top: 20px;
75+
left: 20px;
76+
padding: 10px;
77+
font-size: 14px;
78+
cursor: pointer;
79+
}
80+
</style>

0 commit comments

Comments
 (0)