Kaynağa Gözat

Possibly fix request for device orientation permission (#797).

tags/2.5.5
Matthew Petroff 5 yıl önce
ebeveyn
işleme
1a7c71c062
1 değiştirilmiş dosya ile 13 ekleme ve 5 silme
  1. +13
    -5
      src/js/pannellum.js

+ 13
- 5
src/js/pannellum.js Dosyayı Görüntüle

@@ -1595,8 +1595,6 @@ function computeQuaternion(alpha, beta, gamma) {
* @param {DeviceOrientationEvent} event - Device orientation event.
*/
function orientationListener(e) {
if (e.hasOwnProperty('requestPermission'))
e.requestPermission()
var q = computeQuaternion(e.alpha, e.beta, e.gamma).toEulerAngles();
if (typeof(orientation) == 'number' && orientation < 10) {
// This kludge is necessary because iOS sometimes provides a few stale
@@ -2353,9 +2351,19 @@ function stopOrientation() {
* @private
*/
function startOrientation() {
orientation = 1;
window.addEventListener('deviceorientation', orientationListener);
controls.orientation.classList.add('pnlm-orientation-button-active');
if (typeof DeviceMotionEvent.requestPermission === 'function') {
DeviceOrientationEvent.requestPermission().then(response => {
if (response == 'granted') {
orientation = 1;
window.addEventListener('deviceorientation', orientationListener);
controls.orientation.classList.add('pnlm-orientation-button-active');
}
});
} else {
orientation = 1;
window.addEventListener('deviceorientation', orientationListener);
controls.orientation.classList.add('pnlm-orientation-button-active');
}
}

/**


Yükleniyor…
İptal
Kaydet