Skip to content

Commit 4d9380a

Browse files
authored
Merge pull request #35 from oumoussa98/feat/intersection-observer
Feat/intersection observer
2 parents d704a5b + f7705fd commit 4d9380a

32 files changed

+759
-363
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.

example/package.json renamed to demo/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
{
2-
"name": "vu3-infinite-loading-example",
2+
"name": "vu3-infinite-loading-demo",
33
"version": "0.0.0",
44
"scripts": {
55
"dev": "vite",
66
"build": "vite build",
77
"serve": "vite preview"
88
},
99
"dependencies": {
10-
"v3-infinite-loading": "^1.1.4",
1110
"vue": "^3.2.13"
1211
},
1312
"devDependencies": {
File renamed without changes.

example/src/App.vue renamed to demo/src/App.vue

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +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");
11-
let distance = ref(100);
10+
let distance = ref(0);
1211
let top = ref(false);
1312
let comments = ref([]);
1413
let mountname = ref("Unmount");
15-
1614
const refresh = () => {
1715
page = 0;
1816
comments.value.length = 0;
1917
resetData.value = !resetData.value;
2018
};
21-
2219
const reset = () => {
2320
target.value = ".bottom-results";
24-
distance.value = 100;
21+
distance.value = 0;
2522
top.value = false;
2623
mount.value = true;
2724
mountname.value = "Unmount";
2825
refresh();
2926
};
30-
3127
const mountToggler = async () => {
3228
mount.value = !mount.value;
3329
if (!mount.value) mountname.value = "Mount";
3430
else mountname.value = "Unmount";
3531
};
36-
3732
const targetToggler = async () => {
3833
top.value = false;
3934
if (target.value) target.value = false;
@@ -44,18 +39,21 @@ const targetToggler = async () => {
4439
mountToggler();
4540
refresh();
4641
};
47-
4842
const topToggler = async () => {
4943
top.value = !top.value;
5044
if (top.value) target.value = ".top-results";
5145
else target.value = ".bottom-results";
46+
mountToggler();
47+
await nextTick();
48+
mountToggler();
5249
refresh();
5350
};
54-
5551
const distanceHandler = async () => {
52+
mountToggler();
53+
await nextTick();
54+
mountToggler();
5655
refresh();
5756
};
58-
5957
const load = async $state => {
6058
console.log("loading more...");
6159
page++;
@@ -78,12 +76,19 @@ const load = async $state => {
7876

7977
<template>
8078
<div class="settings">
81-
<a target="_blank" href="https://github.com/oumoussa98/vue3-infinite-loading/tree/main/example">
79+
<a
80+
target="_blank"
81+
href="https://github.com/oumoussa98/vue3-infinite-loading/tree/main/example"
82+
>
8283
<img src="./assets/github.svg" alt="github icon" />
8384
</a>
8485
<span class="props">
85-
<Checkbox :checked="top" :disabled="!target" label="top" @click="topToggler"> Top </Checkbox>
86-
<Checkbox :checked="target" label="target" @click="targetToggler"> Target </Checkbox>
86+
<Checkbox :checked="top" :disabled="!target" label="top" @click="topToggler">
87+
Top
88+
</Checkbox>
89+
<Checkbox :checked="target" label="target" @click="targetToggler">
90+
Target
91+
</Checkbox>
8792
<div>
8893
Distance:
8994
<input
@@ -226,6 +231,9 @@ body {
226231
background: #101011;
227232
border-radius: 10px;
228233
}
234+
.loader {
235+
padding: 10px;
236+
}
229237
.results::-webkit-scrollbar-track {
230238
border-radius: 4px;
231239
background: #333536;
File renamed without changes.
File renamed without changes.

example/src/components/Bottom.vue renamed to 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>

0 commit comments

Comments
 (0)