Add new places; add music component; add audio module; add touch events; fixes

This commit is contained in:
obergodmar
2020-06-29 18:55:33 +03:00
parent 0b52c73cab
commit dea845a76f
53 changed files with 570 additions and 188 deletions
+23
View File
@@ -1,4 +1,5 @@
import { LOADING_DURATION } from './constants'
import Sound from '../modules/sound'
export {
PREVIEW_WIDTH,
@@ -8,4 +9,26 @@ export {
LOADING_DURATION,
ANIMATION_DURATION
} from './constants'
export const delay = () => new Promise(resolve => setTimeout(resolve, LOADING_DURATION))
export const soundLoad = (soundFile: string, soundVolume: number) => (
new Sound(soundFile, soundVolume)
)
export const randomNumber = (min: number, max: number) => (
Math.floor(Math.random() * (max - min)) + min
)
export const debounce = (fn: () => any, ms: number) => {
let timer: NodeJS.Timeout | null
return () => {
if (timer) {
clearTimeout(timer)
}
timer = setTimeout(() => {
timer = null
fn()
}, ms)
}
}