Skip to content

Commit

Permalink
fix: missed codes for SSR (#52)
Browse files Browse the repository at this point in the history
* Update utils.js

* Update canvas.js

* Update utils.js

* Update canvas.js

* fix lint

* Update canvas.js

* Update utils.js

* Update utils.js

* restore unrelated codes

---------

Co-authored-by: weizhenye <weizhenye@gmail.com>
  • Loading branch information
shiyiya and weizhenye authored Apr 4, 2023
1 parent 3da5e01 commit 9fb49c5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/engine/canvas.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const dpr = window.devicePixelRatio || 1;
const dpr = typeof window !== 'undefined' && window.devicePixelRatio || 1;

export var canvasHeightCache = Object.create(null);

Expand Down
22 changes: 16 additions & 6 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
export /* istanbul ignore next */ var raf =
window.requestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.webkitRequestAnimationFrame ||
(
typeof window !== 'undefined' &&
(
window.requestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.webkitRequestAnimationFrame
)
) ||
function(cb) {
return setTimeout(cb, 50 / 3);
};

export /* istanbul ignore next */ var caf =
window.cancelAnimationFrame ||
window.mozCancelAnimationFrame ||
window.webkitCancelAnimationFrame ||
(
typeof window !== 'undefined' &&
(
window.cancelAnimationFrame ||
window.mozCancelAnimationFrame ||
window.webkitCancelAnimationFrame
)
) ||
clearTimeout;

export function binsearch(arr, prop, key) {
Expand Down

0 comments on commit 9fb49c5

Please sign in to comment.