From 32858022edf1142d2b05e98290d8cca9b6a8c87a Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 21 Jun 2017 20:59:00 +0200 Subject: details page --- client/components/Scroller.js | 72 ------------------------------------------- 1 file changed, 72 deletions(-) delete mode 100644 client/components/Scroller.js (limited to 'client/components/Scroller.js') diff --git a/client/components/Scroller.js b/client/components/Scroller.js deleted file mode 100644 index 9bbe7d4..0000000 --- a/client/components/Scroller.js +++ /dev/null @@ -1,72 +0,0 @@ -import { h, Component } from 'preact' -import { Lethargy } from 'lethargy' -import { Link } from 'react-router-dom' - -export default class Scroller extends Component { - constructor() { - super() - this.state = { - index: 0, - } - this.lastScroll = Date.now() - this.onScroll = this.onScroll.bind(this) - this.lethargy = new Lethargy(8, 100, 1.1, 1000) - document.body.addEventListener('wheel', this.onScroll) - document.body.addEventListener('DOMMouseScroll', this.onScroll) - } - onScroll(e) { - e.preventDefault() - e.stopPropagation() - const scrollDirection = this.lethargy.check(e) - const now = Date.now() - if (scrollDirection !== false && now - this.lastScroll > 600) { - this.lastScroll = now - const cellCount = this.props.data.painting.length + 1 - const index = (this.state.index + cellCount - scrollDirection) % cellCount - this.setState({ index }) - } - } - render() { - const paintings = this.props.data.painting.map( (painting, i) => { - return ( -
-
-
-
-
-
- {painting.title}
- {painting.medium}
- {painting.date}
- {painting.image.caption}
-
- - More info > - -
-
-
- ) - }) - const about = this.props.data.page[0] - const body = (about.body || '').replace(/\n/g,'
') - const page = ( -
-
-
-
-
-
-
- ) - const scrollPercentage = this.state.index * -100 - return ( -
- {paintings} - {page} -
- ) - } -} -- cgit v1.2.3-70-g09d2