Add new places; add music component; add audio module; add touch events; fixes
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user