Add comments to js

pull/37/head
Varun Patil 2022-08-15 04:09:16 +00:00
parent a860208745
commit 20ff9a4b7d
1 changed files with 15 additions and 3 deletions

View File

@ -29,14 +29,21 @@
export default { export default {
data() { data() {
return { return {
/** Main list of rows */
list: [], list: [],
/** Counter of rows */
numRows: 0, numRows: 0,
/** Computed number of columns */
numCols: 5, numCols: 5,
/** Header rows for dayId key */
heads: {}, heads: {},
/** Computed row height */
rowHeight: 100, rowHeight: 100,
/** Current start index */
currentStart: 0, currentStart: 0,
/** Current end index */
currentEnd: 0, currentEnd: 0,
} }
}, },
@ -47,6 +54,7 @@ export default {
}, },
methods: { methods: {
/** Handle window resize and initialization */
handleResize() { handleResize() {
let height = this.$refs.container.clientHeight; let height = this.$refs.container.clientHeight;
let width = this.$refs.container.clientWidth; let width = this.$refs.container.clientWidth;
@ -56,6 +64,7 @@ export default {
this.rowHeight = Math.floor(width / this.numCols) - 4; this.rowHeight = Math.floor(width / this.numCols) - 4;
}, },
/** Trigger when recycler view changes */
scrollChange(startIndex, endIndex) { scrollChange(startIndex, endIndex) {
if (startIndex === this.currentStart && endIndex === this.currentEnd) { if (startIndex === this.currentStart && endIndex === this.currentEnd) {
return; return;
@ -65,12 +74,13 @@ export default {
this.currentEnd = endIndex; this.currentEnd = endIndex;
setTimeout(() => { setTimeout(() => {
if (this.currentStart === startIndex && this.currentEnd === endIndex) { if (this.currentStart === startIndex && this.currentEnd === endIndex) {
this.loadChanges(startIndex, endIndex); this.loadScrollChanges(startIndex, endIndex);
} }
}, 300); }, 300);
}, },
loadChanges(startIndex, endIndex) { /** Load image data for given view */
loadScrollChanges(startIndex, endIndex) {
for (let i = startIndex; i <= endIndex; i++) { for (let i = startIndex; i <= endIndex; i++) {
let item = this.list[i]; let item = this.list[i];
if (!item) { if (!item) {
@ -85,6 +95,7 @@ export default {
} }
}, },
/** Fetch timeline main call */
async fetchDays() { async fetchDays() {
const res = await fetch('/apps/betterphotos/api/days'); const res = await fetch('/apps/betterphotos/api/days');
const data = await res.json(); const data = await res.json();
@ -123,6 +134,7 @@ export default {
} }
}, },
/** Fetch image data for one dayId */
async fetchDay(dayId) { async fetchDay(dayId) {
const head = this.heads[dayId]; const head = this.heads[dayId];
head.loaded = true; head.loaded = true;
@ -169,7 +181,7 @@ export default {
} }
}, },
// Get a new blank row /** Get a new blank row */
getBlankRow(dayId) { getBlankRow(dayId) {
return { return {
id: ++this.numRows, id: ++this.numRows,