Skip to content

Commit ae4a3d7

Browse files
committed
TrackingConsent: safari hacks for browser bottom bar
1 parent aca955a commit ae4a3d7

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

src/components/TrackingConsent.vue

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div
33
class="tracking-consent nq-shadow"
4-
:class="theme"
4+
:class="[ theme, safariFix ]"
55
v-if="uiRequired && uiAllowed"
66
>
77
{{ text.main }} ❤️
@@ -118,6 +118,7 @@ class TrackingConsent extends Vue {
118118
119119
private static _instances: Set<TrackingConsent> = new Set();
120120
private uiRequired: boolean = false;
121+
private safariFix: string = '';
121122
122123
public static get _paq() {
123124
if (!window._paq || !Array.isArray(window._paq)) {
@@ -243,6 +244,29 @@ class TrackingConsent extends Vue {
243244
this._checkUiRequired();
244245
}
245246
247+
private mounted() {
248+
/* Safari IOS style fix */
249+
const ua = window.navigator.userAgent;
250+
const iOS = !!ua.match(/iPad/i) || !!ua.match(/iPhone/i);
251+
const webkit = !!ua.match(/WebKit/i);
252+
const iOSSafari = iOS && webkit && !ua.match(/CriOS/i);
253+
254+
if (iOSSafari) {
255+
let majorVersion = null;
256+
257+
if (/iP(hone|od|ad)/.test(navigator.platform)) {
258+
const match = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/);
259+
majorVersion = parseInt(match[1], 10);
260+
}
261+
262+
if (majorVersion >= 13) {
263+
this.safariFix = 'ios-safari-13-fix';
264+
} else if (majorVersion >= 12) {
265+
this.safariFix = 'ios-safari-12-fix';
266+
}
267+
}
268+
}
269+
246270
private destroyed() {
247271
/* Remove the event watching for consent changes on tab / window focus */
248272
document.removeEventListener('visibilitychange', this._onVisibilityChange);
@@ -413,6 +437,14 @@ export default TrackingConsent;
413437
padding: 2.5rem;
414438
}
415439
440+
.tracking-consent.ios-safari-13-fix {
441+
bottom: 74px;
442+
}
443+
444+
.tracking-consent.ios-safari-12-fix {
445+
bottom: 34px;
446+
}
447+
416448
.button-group {
417449
margin-left: 0;
418450
margin-top: 16px;

0 commit comments

Comments
 (0)