mirror of
https://github.com/pinry/pinry.git
synced 2025-11-18 02:40:40 +01:00
Feature: Add loading spinner for pins
This commit is contained in:
committed by
Isaac Bythewood
parent
4b5a55725f
commit
5890a02807
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
@@ -50,6 +50,7 @@
|
|||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<loadingSpinner v-bind:show="status.loading"></loadingSpinner>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -58,6 +59,7 @@
|
|||||||
import API from './api';
|
import API from './api';
|
||||||
import pinHandler from './utils/PinHandler';
|
import pinHandler from './utils/PinHandler';
|
||||||
import PinPreview from './PinPreview.vue';
|
import PinPreview from './PinPreview.vue';
|
||||||
|
import loadingSpinner from './loadingSpinner.vue';
|
||||||
|
|
||||||
function createImageItem(pin) {
|
function createImageItem(pin) {
|
||||||
const image = {};
|
const image = {};
|
||||||
@@ -74,11 +76,17 @@ function createImageItem(pin) {
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'pins',
|
name: 'pins',
|
||||||
components: {},
|
components: {
|
||||||
|
loadingSpinner,
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
blocks: [],
|
blocks: [],
|
||||||
|
status: {
|
||||||
|
loading: false,
|
||||||
|
hasNext: true,
|
||||||
offset: 0,
|
offset: 0,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
@@ -117,26 +125,34 @@ export default {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
fetchMore() {
|
fetchMore(created) {
|
||||||
let promise;
|
let promise;
|
||||||
|
if (!created) {
|
||||||
|
if (this.status.loading) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.status.loading = true;
|
||||||
if (this.pinFilters.tagFilter) {
|
if (this.pinFilters.tagFilter) {
|
||||||
promise = API.fetchPins(this.offset, this.pinFilters.tagFilter);
|
promise = API.fetchPins(this.status.offset, this.pinFilters.tagFilter);
|
||||||
} else if (this.pinFilters.userFilter) {
|
} else if (this.pinFilters.userFilter) {
|
||||||
promise = API.fetchPins(this.offset, null, this.pinFilters.userFilter);
|
promise = API.fetchPins(this.status.offset, null, this.pinFilters.userFilter);
|
||||||
} else if (this.pinFilters.boardFilter) {
|
} else if (this.pinFilters.boardFilter) {
|
||||||
promise = API.fetchPinsForBoard(this.pinFilters.boardFilter);
|
promise = API.fetchPinsForBoard(this.pinFilters.boardFilter);
|
||||||
} else {
|
} else {
|
||||||
promise = API.fetchPins(this.offset);
|
promise = API.fetchPins(this.status.offset);
|
||||||
}
|
}
|
||||||
promise.then(
|
promise.then(
|
||||||
(resp) => {
|
(resp) => {
|
||||||
this.blocks = this.buildBlocks(resp.data.results);
|
this.blocks = this.buildBlocks(resp.data.results);
|
||||||
|
this.status.loading = false;
|
||||||
},
|
},
|
||||||
|
() => { this.status.loading = false; },
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.fetchMore();
|
this.fetchMore(true);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
31
pinry-spa/src/components/loadingSpinner.vue
Normal file
31
pinry-spa/src/components/loadingSpinner.vue
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<template>
|
||||||
|
<div class="loading-spinner">
|
||||||
|
<div v-show="show" class="spinner">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: 'loadingSpinner',
|
||||||
|
props: {
|
||||||
|
show: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
/* loading spinner */
|
||||||
|
.spinner {
|
||||||
|
background: url('../assets/loader.gif');
|
||||||
|
background-position: center center;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
height: 31px;
|
||||||
|
margin: 0 auto;
|
||||||
|
padding: 50px;
|
||||||
|
width: 31px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Reference in New Issue
Block a user