-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathvendor.js
55 lines (40 loc) · 1.09 KB
/
vendor.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import regeneratorRuntime from 'regenerator-runtime'
global.regeneratorRuntime = regeneratorRuntime
import _ from 'lodash'
global._ = _
import R from 'ramda'
global.R = R
const asyncWrap = fn => (options = {}) => new Promise((resolve, reject) => {
let conf = {
success: res => {
resolve(res)
},
fail: err => {
reject(err)
}
}
wx[fn](R.merge(conf, options))
})
wx.loginAsync = asyncWrap('login')
wx.getUserInfoAsync = asyncWrap('getUserInfo')
wx.reqAsync = asyncWrap('request')
wx.getSystemInfoAsync = asyncWrap('getSystemInfo')
wx.payAsync = asyncWrap('requestPayment')
let lastTime = 0
global.requestAnimationFrame = callback => {
const currentTime = new Date().getTime()
const timeToCall = Math.max(0, 16 - (currentTime - lastTime))
const timer = global.setTimeout(function () {
callback(currentTime + timeToCall)
}, timeToCall)
lastTime = currentTime + timeToCall
return timer
}
global.cancelAnimationFrame = timer => {
clearTimeout(timer)
}
import TWEEN from 'tween.js'
TWEEN.now = function () {
return new Date().getTime()
}
global.TWEEN = TWEEN