Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chinsun9/random-dice
Roll π² !!! click & shake
https://github.com/chinsun9/random-dice
animation css
Last synced: about 1 month ago
JSON representation
Roll π² !!! click & shake
- Host: GitHub
- URL: https://github.com/chinsun9/random-dice
- Owner: chinsun9
- Created: 2021-06-16T04:32:56.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-09-30T02:11:14.000Z (over 3 years ago)
- Last Synced: 2023-03-08T07:00:35.939Z (almost 2 years ago)
- Topics: animation, css
- Language: TypeScript
- Homepage: https://chinsun9.github.io/random-dice/
- Size: 54.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Random Dice
**3D CSS - lighting, animations, and more! - Kevin Powell**μ λ³΄κ³ μμ©ν΄μ λ§λ€μλ€
- https://youtu.be/NdftnCDwKaU
## κΈ°λ₯
- μ£Όμ¬μ λ리기
- μ£Όμ¬μ λ리λ μ λλ©μ΄μ
- λλ€ κ²°κ³Ό 1~6
- νΈλν°μ νλ€μ΄ μ£Όμ¬μ λ리기## TMI
### νΈλν° νλ€κΈ° κ°μ§ : devicemotion
```js
window.addEventListener('devicemotion', (event) => {
if (!event.acceleration) {
console.log(`no acceleration`);
return;
}const currentTime = new Date().getTime();
if (currentTime - lastTimestamp < 300) {
return;
}lastTimestamp = currentTime;
const acceleration = Math.max(
Math.abs(event.acceleration.x!),
Math.abs(event.acceleration.y!),
Math.abs(event.acceleration.z!)
);if (acceleration >= 4) {
dice.roll();
}
});
```- `devicemotion`λΌλ window μ΄λ²€νΈμμ κ°μ Έμ¬ μ μλ€
- x, y, zμ κ°μλλ₯Ό μ»μ΄μ κ°μ₯ ν° κ°μ κΈ°μ€μΌλ‘ μ§μ ν κ°μ λκΈ°λ©΄ μ£Όμ¬μλ₯Ό ꡴리λλ‘ νλ€
- 보μ 컨ν μ€νΈμμλ§ λμνκΈ° λλ¬Έμ localhost λλ HTTPSμμ λμνλ€