|
@@ -5,15 +5,23 @@ export default class CanvasOperator {
|
|
|
|
|
|
|
|
/* ---------- RAF 封装 ---------- */
|
|
/* ---------- RAF 封装 ---------- */
|
|
|
raf(cb) {
|
|
raf(cb) {
|
|
|
- // #ifdef MP-WEIXIN || MP-ALIPAY
|
|
|
|
|
- return this.canvas.requestAnimationFrame(cb)
|
|
|
|
|
- // #endif
|
|
|
|
|
|
|
+ if (typeof this.canvas.requestAnimationFrame === 'function') {
|
|
|
|
|
+ return this.canvas.requestAnimationFrame(cb)
|
|
|
|
|
+ }
|
|
|
|
|
+ if (typeof requestAnimationFrame === 'function') {
|
|
|
|
|
+ return requestAnimationFrame(cb)
|
|
|
|
|
+ }
|
|
|
|
|
+ return setTimeout(cb, 16)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
cancelRaf(id) {
|
|
cancelRaf(id) {
|
|
|
- // #ifdef MP-WEIXIN || MP-ALIPAY
|
|
|
|
|
- return this.canvas.cancelAnimationFrame(id)
|
|
|
|
|
- // #endif
|
|
|
|
|
|
|
+ if (typeof this.canvas.cancelAnimationFrame === 'function') {
|
|
|
|
|
+ return this.canvas.cancelAnimationFrame(id)
|
|
|
|
|
+ }
|
|
|
|
|
+ if (typeof cancelAnimationFrame === 'function') {
|
|
|
|
|
+ return cancelAnimationFrame(id)
|
|
|
|
|
+ }
|
|
|
|
|
+ return clearTimeout(id)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/* ---------- 图片加载 ---------- */
|
|
/* ---------- 图片加载 ---------- */
|