fix: remove unnecessary function cache (#1358)
This is just a bit of code cleanup; I think this cache logic is excessive
This commit is contained in:
parent
fbcac6d3e4
commit
6c58052684
|
@ -1,11 +0,0 @@
|
|||
// Rough guess at whether this is a "mobile" device or not, for the purposes
|
||||
// of "device class" estimations
|
||||
|
||||
let cached
|
||||
|
||||
export function isMobile () {
|
||||
if (typeof cached === 'undefined') {
|
||||
cached = !!(process.browser && navigator.userAgent.match(/(iPhone|iPod|iPad|Android)/))
|
||||
}
|
||||
return cached
|
||||
}
|
|
@ -1,6 +1,9 @@
|
|||
import { scheduleIdleTask } from './scheduleIdleTask'
|
||||
import { store } from '../_store/store'
|
||||
import { isMobile } from './isMobile'
|
||||
|
||||
// Rough guess at whether this is a "mobile" device or not, for the purposes
|
||||
// of "device class" estimations
|
||||
const IS_MOBILE = process.browser && navigator.userAgent.match(/(?:iPhone|iPod|iPad|Android)/)
|
||||
|
||||
// Run a task that doesn't need to be processed immediately, but should
|
||||
// probably be delayed if we're on a mobile device. Also run it sooner
|
||||
|
@ -8,7 +11,7 @@ import { isMobile } from './isMobile'
|
|||
export function runMediumPriorityTask (fn) {
|
||||
if (store.get().pageVisibilityHidden) {
|
||||
fn()
|
||||
} else if (isMobile()) {
|
||||
} else if (IS_MOBILE) {
|
||||
scheduleIdleTask(fn)
|
||||
} else {
|
||||
requestAnimationFrame(fn)
|
||||
|
|
Loading…
Reference in a new issue