Redefine Location's new status from latest photo's creation date
This commit is contained in:
@@ -8,22 +8,31 @@
|
|||||||
import Badge from '$components/atoms/Badge.svelte'
|
import Badge from '$components/atoms/Badge.svelte'
|
||||||
|
|
||||||
export let location: any
|
export let location: any
|
||||||
|
export let latestPhoto: any
|
||||||
|
|
||||||
const { settings: { limit_new }}: any = getContext('global')
|
const { settings: { limit_new }}: any = getContext('global')
|
||||||
|
|
||||||
// Location date limit
|
|
||||||
const dateNowOffset = dayjs().subtract(limit_new, 'day')
|
|
||||||
const dateLocationUpdated = dayjs(location.date_updated)
|
|
||||||
const isNew = dateLocationUpdated.isAfter(dateNowOffset)
|
|
||||||
|
|
||||||
let locationEl: HTMLElement
|
let locationEl: HTMLElement
|
||||||
let photoIndex = 0
|
let photoIndex = 0
|
||||||
|
|
||||||
|
// Location date limit
|
||||||
|
let isNew = false
|
||||||
|
let dateUpdated: dayjs.Dayjs
|
||||||
|
const dateNowOffset = dayjs().subtract(limit_new, 'day')
|
||||||
|
|
||||||
|
$: if (latestPhoto) {
|
||||||
|
dateUpdated = dayjs(latestPhoto.date_created)
|
||||||
|
isNew = dateUpdated.isAfter(dateNowOffset)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Moving cursor over
|
||||||
|
*/
|
||||||
const offset = spring({ x: 0, y: 0 }, {
|
const offset = spring({ x: 0, y: 0 }, {
|
||||||
stiffness: 0.075,
|
stiffness: 0.075,
|
||||||
damping: 0.9
|
damping: 0.9
|
||||||
})
|
})
|
||||||
|
|
||||||
// Moving cursor over
|
|
||||||
const handleMouseMove = ({ clientX }: MouseEvent) => {
|
const handleMouseMove = ({ clientX }: MouseEvent) => {
|
||||||
const { width, left } = locationEl.getBoundingClientRect()
|
const { width, left } = locationEl.getBoundingClientRect()
|
||||||
const moveProgress = (clientX - left) / width // 0 to 1
|
const moveProgress = (clientX - left) / width // 0 to 1
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
export let locations: any
|
export let locations: any
|
||||||
|
|
||||||
|
|
||||||
const { continents, settings: { explore_list }} = getContext('global')
|
const { continents, settings: { explore_list }} = getContext('global')
|
||||||
|
|
||||||
// Continents filtering logic
|
// Continents filtering logic
|
||||||
@@ -60,7 +61,10 @@
|
|||||||
in:receive={{ key: location.slug }}
|
in:receive={{ key: location.slug }}
|
||||||
out:send={{ key: location.slug }}
|
out:send={{ key: location.slug }}
|
||||||
>
|
>
|
||||||
<Location {location} />
|
<Location
|
||||||
|
location={location}
|
||||||
|
latestPhoto={location.photos[0]}
|
||||||
|
/>
|
||||||
</li>
|
</li>
|
||||||
{/each}
|
{/each}
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -45,6 +45,7 @@
|
|||||||
id
|
id
|
||||||
title
|
title
|
||||||
}
|
}
|
||||||
|
date_created
|
||||||
}
|
}
|
||||||
has_poster
|
has_poster
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user