Skip to content

Commit 66e0b4d

Browse files
committed
update(demo): add distance prop
1 parent 9043f75 commit 66e0b4d

File tree

3 files changed

+35
-11
lines changed

3 files changed

+35
-11
lines changed

demo/src/App.vue

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,32 @@ import { ref, nextTick } from "vue";
33
import Top from "./components/Top.vue";
44
import Bottom from "./components/Bottom.vue";
55
import Checkbox from "./components/Checkbox.vue";
6-
76
let page = 0;
87
let mount = ref(true);
98
let resetData = ref(false);
109
let target = ref(".bottom-results");
10+
let distance = ref(0);
1111
let top = ref(false);
1212
let comments = ref([]);
1313
let mountname = ref("Unmount");
14-
1514
const refresh = () => {
1615
page = 0;
1716
comments.value.length = 0;
1817
resetData.value = !resetData.value;
1918
};
20-
2119
const reset = () => {
2220
target.value = ".bottom-results";
21+
distance.value = 0;
2322
top.value = false;
2423
mount.value = true;
2524
mountname.value = "Unmount";
2625
refresh();
2726
};
28-
2927
const mountToggler = async () => {
3028
mount.value = !mount.value;
3129
if (!mount.value) mountname.value = "Mount";
3230
else mountname.value = "Unmount";
3331
};
34-
3532
const targetToggler = async () => {
3633
top.value = false;
3734
if (target.value) target.value = false;
@@ -42,17 +39,21 @@ const targetToggler = async () => {
4239
mountToggler();
4340
refresh();
4441
};
45-
4642
const topToggler = async () => {
4743
top.value = !top.value;
4844
if (top.value) target.value = ".top-results";
4945
else target.value = ".bottom-results";
46+
mountToggler();
47+
await nextTick();
48+
mountToggler();
5049
refresh();
50+
};
51+
const distanceHandler = async () => {
5152
mountToggler();
5253
await nextTick();
5354
mountToggler();
55+
refresh();
5456
};
55-
5657
const load = async $state => {
5758
console.log("loading more...");
5859
page++;
@@ -88,6 +89,15 @@ const load = async $state => {
8889
<Checkbox :checked="target" label="target" @click="targetToggler">
8990
Target
9091
</Checkbox>
92+
<div>
93+
Distance:
94+
<input
95+
@change="distanceHandler"
96+
class="distance"
97+
v-model.number.lazy="distance"
98+
type="text"
99+
/>
100+
</div>
91101
</span>
92102
<span class="buttons">
93103
<button class="btn-mount" @click="mountToggler">{{ mountname }}</button>
@@ -98,16 +108,18 @@ const load = async $state => {
98108
<div v-if="mount">
99109
<Top
100110
v-if="top"
101-
:target="target"
111+
:distance="distance"
102112
:comments="comments"
103113
:identifier="resetData"
114+
:target="target"
104115
@infinite="load"
105116
/>
106117
<Bottom
107118
v-if="!top"
108-
:target="target"
119+
:distance="distance"
109120
:comments="comments"
110121
:identifier="resetData"
122+
:target="target"
111123
@infinite="load"
112124
/>
113125
</div>
@@ -161,6 +173,15 @@ body {
161173
gap: 20px;
162174
flex-wrap: wrap;
163175
}
176+
.distance {
177+
width: 50px;
178+
border-radius: 5px;
179+
padding: 4px 5px;
180+
outline: none;
181+
border: none;
182+
background: #6a6c6d;
183+
color: inherit;
184+
}
164185
.buttons {
165186
display: flex;
166187
gap: 20px;
@@ -210,6 +231,9 @@ body {
210231
background: #101011;
211232
border-radius: 10px;
212233
}
234+
.loader {
235+
padding: 10px;
236+
}
213237
.results::-webkit-scrollbar-track {
214238
border-radius: 4px;
215239
background: #333536;

demo/src/components/Bottom.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const { comments } = toRefs(props);
1414
<div>{{ comment.email }}</div>
1515
<div>{{ comment.id }}</div>
1616
</div>
17-
<infinite-loading v-bind="$attrs" />
17+
<infinite-loading class="loader" v-bind="$attrs" />
1818
</div>
1919
</div>
2020
</template>

demo/src/components/Top.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const { comments } = toRefs(props);
1010
<template>
1111
<div v-bind="$attrs">
1212
<div class="results" :class="{ 'top-results': $attrs.target }">
13-
<infinite-loading top v-bind="$attrs" />
13+
<infinite-loading class="loader" top v-bind="$attrs" />
1414
<div class="result" v-for="comment in comments" :key="comment.id">
1515
<div>{{ comment.email }}</div>
1616
<div>{{ comment.id }}</div>

0 commit comments

Comments
 (0)