Last active
November 10, 2020 20:48
-
-
Save developit/f1d6b235cb299e330fc76d0dce415196 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package-lock.json | |
node_modules | |
.cache | |
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.drag { | |
display: grid; | |
background: #abc; | |
border-radius: 16px; | |
height: 80px; | |
width: 80px; | |
z-index: 10000; | |
position: relative; | |
cursor: -webkit-grab; | |
cursor: grab; | |
touch-action: none; | |
user-select: none; | |
color: #333; | |
place-items: center; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { h, FunctionalComponent } from "preact"; | |
import { useSpring, animated } from "react-spring"; | |
import { useDrag } from "react-use-gesture"; | |
import styles from './app.module.css'; | |
const Slide : FunctionalComponent = () => { | |
const [props, set] = useSpring(() => ({ left: 0, top: 0 })); | |
const bind = useDrag(({ down, movement: [mx, my] }) => { | |
set({ left: down ? mx : 0, top: down ? my : 0 }); | |
}); | |
return <animated.div {...bind()} style={props} class={styles.drag} />; | |
}; | |
export default Slide; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>useSpring</title> | |
<link rel="stylesheet" href="/style.css"> | |
</head> | |
<body> | |
<script type="module" src="/index.js"></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { render } from 'preact'; | |
import App from './app.tsx'; | |
render(<App />, document.body); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.0.1", | |
"scripts": { | |
"start": "wmr", | |
"build:prod": "wmr build" | |
}, | |
"engines": { | |
"node": "12.x" | |
}, | |
"alias": { | |
"react": "preact/compat", | |
"react-dom": "preact/compat" | |
}, | |
"devDependencies": { | |
"wmr": "^0.0.11" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
html, | |
body { | |
font: 100% system-ui; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment