Skip to content

Commit 01781ec

Browse files
committed
💄 Make Landing page better
1 parent 42decfc commit 01781ec

File tree

2 files changed

+30
-21
lines changed

2 files changed

+30
-21
lines changed

src/components/landing/LandingItem.vue

+9-13
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
{{ alcim }}
99
</p>
1010
</div>
11-
<img
12-
:src="photos"
13-
alt="LandingPhoto"
14-
class="col-lg-6 mt-2"
11+
<div
12+
class="col-lg-6 mt-2 text-center"
1513
:class="{ 'order-first': floating(orientation) && jo }"
16-
/>
14+
>
15+
<img :src="photos" alt="LandingPhoto" />
16+
</div>
1717
</div>
1818
</div>
1919
</li>
@@ -42,14 +42,7 @@ export default {
4242
},
4343
computed: {
4444
photos() {
45-
switch (this.photo) {
46-
case 'stat':
47-
return 'https://via.placeholder.com/350';
48-
case 'qr':
49-
return 'https://via.placeholder.com/350';
50-
default:
51-
return this.photo;
52-
}
45+
return this.photo;
5346
},
5447
},
5548
};
@@ -68,4 +61,7 @@ li {
6861
p.card-text {
6962
font-size: 1.2rem;
7063
}
64+
img {
65+
max-width: 30vw;
66+
}
7167
</style>

src/views/Landing.vue

+21-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div>
33
<base-loader v-if="isLoading">Töltés...</base-loader>
4-
<p v-else-if="error">{{ error }}</p>
4+
<p v-else-if="error" class="text-center display-3">{{ error }}</p>
55
<p v-else-if="!results || results.length === 0" class="text-center display-3">
66
Nincs adat
77
</p>
@@ -19,24 +19,24 @@
1919
</template>
2020

2121
<script>
22-
import { ref, onBeforeMount } from 'vue';
22+
import { ref, onBeforeMount, onUnmounted } from 'vue';
2323
import LandingItem from '../components/landing/LandingItem.vue';
2424
import axios from '@/config/axios.js';
2525
export default {
2626
name: 'Landing',
27-
title: 'asd',
2827
components: { LandingItem },
2928
setup() {
3029
const results = ref([]);
3130
const isLoading = ref(false);
3231
const error = ref(null);
32+
const limit = 5;
33+
let page = 1;
3334
3435
function loadExp() {
35-
isLoading.value = true;
3636
error.value = null;
37-
37+
if (!results.value) isLoading.value = true;
3838
axios
39-
.get('/homepage')
39+
.get(`/homepage?limit=${limit}&page=${page}`)
4040
.then(res => {
4141
const datas = [];
4242
for (const i in res.data) {
@@ -47,11 +47,12 @@ export default {
4747
picture: res.data[i].picture,
4848
});
4949
}
50-
results.value = datas;
50+
page++;
51+
results.value.push(...datas);
5152
isLoading.value = false;
5253
})
5354
.catch(err => {
54-
error.value = err;
55+
error.value = err.message;
5556
console.log('ERROR', err);
5657
});
5758
}
@@ -60,9 +61,21 @@ export default {
6061
return id % 2 ? 'left' : 'right';
6162
}
6263
64+
function handleScroll() {
65+
const posFromBottom = Math.max(
66+
document.body.offsetHeight - (window.pageYOffset + window.innerHeight),
67+
0,
68+
);
69+
if (posFromBottom < 100) loadExp();
70+
}
71+
6372
onBeforeMount(() => {
73+
window.addEventListener('scroll', handleScroll);
6474
loadExp();
6575
});
76+
onUnmounted(() => {
77+
window.removeEventListener('scroll', handleScroll);
78+
});
6679
return { isLoading, results, error, orient };
6780
},
6881
};

0 commit comments

Comments
 (0)