Added ios detection (#591)

https://stackoverflow.com/questions/9038625/detect-if-device-is-ios/9039885#9039885

*Note* navigator.platform is deprecated but still seems to work for now.
This commit is contained in:
Robbie Davis 2021-09-22 12:28:58 -04:00 committed by GitHub
parent 5c5289d3db
commit 7414b8ae07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -783,7 +783,16 @@ export class MangaReaderComponent implements OnInit, AfterViewInit, OnDestroy {
if (this.ctx && this.canvas) { if (this.ctx && this.canvas) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment // eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore // @ts-ignore
const isSafari = /constructor/i.test(window.HTMLElement) || (function (p) { return p.toString() === "[object SafariRemoteNotification]"; })(!window['safari'] || (typeof safari !== 'undefined' && window['safari'].pushNotification)); const isSafari = [
'iPad Simulator',
'iPhone Simulator',
'iPod Simulator',
'iPad',
'iPhone',
'iPod'
].includes(navigator.platform)
// iPad on iOS 13 detection
|| (navigator.userAgent.includes("Mac") && "ontouchend" in document);
const canvasLimit = isSafari ? 16_777_216 : 124_992_400; const canvasLimit = isSafari ? 16_777_216 : 124_992_400;
const needsScaling = this.canvasImage.width * this.canvasImage.height > canvasLimit; const needsScaling = this.canvasImage.width * this.canvasImage.height > canvasLimit;
if (needsScaling) { if (needsScaling) {