/** @jsx dom */
import dom from 'magic-virtual-element';
import scrollTo from 'scroll-to';

const defaultProps = {
	duration: 500,
	ease: 'out-circ',
	top: 0
};

const propTypes = {
	class: {
		type: 'string'
	},
	duration: {
		type: 'number'
	},
	ease: {
		type: 'string'
	},
	show: {
		type: 'number'
	},
	top: {
		type: 'number'
	}
};

function shouldUpdate({state}, nextProps, {active}) {
	return !state.active === active;
}

function afterMount({props}, el, setState) {
	const {show} = props;

	window.addEventListener('scroll', () => {
		if (window.scrollY >= show) {
			setState({active: true});
			return;
		}

		setState({active: false});
	});
}

function render({props, state}) {
	const {children, duration, ease, top} = props;
	const {active} = state;

	return (
		<div class={['ScrollUp', props.class, {'ScrollUp--active': active}]} onClick={() => scrollTo(0, top, {ease, duration})}>
			{children}
		</div>
	);
}

export default {afterMount, defaultProps, propTypes, render, shouldUpdate};

@@ -89,78 +89,8 @@
 ';%0A%0A
-const defaultProps = %7B%0A%09duration: 500,%0A%09ease: 'out-circ',%0A%09top: 0%0A%7D;%0A%0A
 cons
@@ -266,107 +266,143 @@
 %7D;%0A%0A
-function shouldUpdate(%7Bstate%7D, nextProps, %7Bactive%7D) %7B%0A%09return !state.active === active;%0A%7D%0A%0Afunction
+const defaultProps = %7B%0A%09duration: 500,%0A%09ease: 'out-circ',%0A%09top: 0%0A%7D;%0A%0Aconst onClick = (top, obj) =%3E () =%3E scrollTo(0, top, obj);%0A%0Aconst
  aft
@@ -408,16 +408,19 @@
 terMount
+ = 
 (%7Bprops%7D
@@ -434,16 +434,19 @@
 etState)
+ =%3E
  %7B%0A%09cons
@@ -623,25 +623,108 @@
 );%0A%7D
+;
 %0A%0A
-function
+const shouldUpdate = (%7Bstate%7D, nextProps, %7Bactive%7D) =%3E !state.active === active;%0A%0Aconst
  render
+ = 
 (%7Bpr
@@ -735,16 +735,19 @@
  state%7D)
+ =%3E
  %7B%0A%09cons
@@ -905,34 +905,24 @@
 nClick=%7B
-() =%3E scrollTo(0, 
+onClick(
 top, %7Bea
@@ -966,16 +966,17 @@
 v%3E%0A%09);%0A%7D
+;
 %0A%0Aexport

Improve code style