Browse Source

Merge pull request #8222 from tjgrathwell/ios-fake-cancel-animation-frame

ios: Patch cancelAnimationFrame whenever fakeRequestAnimationFrame is used
Yury Delendik 8 years ago committed by GitHub
parent
commit
b665b0319a
  1. 17
      src/shared/compatibility.js

17
src/shared/compatibility.js

@ -643,8 +643,13 @@ PDFJS.compatibilityChecked = true;
// Support: IE<10, Android<4.0, iOS // Support: IE<10, Android<4.0, iOS
(function checkRequestAnimationFrame() { (function checkRequestAnimationFrame() {
function fakeRequestAnimationFrame(callback) { function installFakeAnimationFrameFunctions() {
window.setTimeout(callback, 20); window.requestAnimationFrame = function (callback) {
return window.setTimeout(callback, 20);
};
window.cancelAnimationFrame = function (timeoutID) {
window.clearTimeout(timeoutID);
};
} }
if (!hasDOM) { if (!hasDOM) {
@ -652,7 +657,7 @@ PDFJS.compatibilityChecked = true;
} }
if (isIOS) { if (isIOS) {
// requestAnimationFrame on iOS is broken, replacing with fake one. // requestAnimationFrame on iOS is broken, replacing with fake one.
window.requestAnimationFrame = fakeRequestAnimationFrame; installFakeAnimationFrameFunctions();
return; return;
} }
if ('requestAnimationFrame' in window) { if ('requestAnimationFrame' in window) {
@ -660,8 +665,10 @@ PDFJS.compatibilityChecked = true;
} }
window.requestAnimationFrame = window.requestAnimationFrame =
window.mozRequestAnimationFrame || window.mozRequestAnimationFrame ||
window.webkitRequestAnimationFrame || window.webkitRequestAnimationFrame;
fakeRequestAnimationFrame; if (!('requestAnimationFrame' in window)) {
installFakeAnimationFrameFunctions();
}
})(); })();
// Support: Android, iOS // Support: Android, iOS

Loading…
Cancel
Save