{painting.medium}
{painting.date}
{painting.image.caption}
import { h, Component } from 'preact' import { isMobile } from '../util' import db from '../db' import { Lethargy } from 'lethargy' export default class App extends Component { constructor() { super() this.state = { index: 0, data: db.backupDB, } this.lastScroll = Date.now() this.onScroll = this.onScroll.bind(this) this.lethargy = new Lethargy(8, 100, 1.1, 1000) db.fetch( data => { document.body.parentNode.classList.remove('loading') this.setState({ data }) }) // document.body.addEventListener('mousewheel', this.onScroll) // document.body.addEventListener('DOMMouseScroll', this.onScroll) document.body.addEventListener('wheel', this.onScroll) } onScroll(e) { e.preventDefault() e.stopPropagation() const scrollDirection = this.lethargy.check(e) const now = Date.now() if (scrollDirection !== false && now - this.lastScroll > 500) { this.lastScroll = now const cellCount = this.state.data.painting.length const index = (this.state.index + cellCount - scrollDirection) % cellCount this.setState({ index }) } } render() { const paintings = this.state.data.painting.map( (painting, i) => { return (