Redefine Location's new status from latest photo's creation date

This commit is contained in:
2021-10-17 23:01:34 +02:00
parent 277005c591
commit dfb019493e
3 changed files with 22 additions and 8 deletions

View File

@@ -8,22 +8,31 @@
import Badge from '$components/atoms/Badge.svelte'
export let location: any
export let latestPhoto: any
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 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 }, {
stiffness: 0.075,
damping: 0.9
})
// Moving cursor over
const handleMouseMove = ({ clientX }: MouseEvent) => {
const { width, left } = locationEl.getBoundingClientRect()
const moveProgress = (clientX - left) / width // 0 to 1