Pārlūkot izejas kodu

Add option to turn device orientation control on by default.

pull/234/head
Matthew Petroff pirms 8 gadiem
vecāks
revīzija
13cd182f82
2 mainītis faili ar 26 papildinājumiem un 6 dzēšanām
  1. +7
    -0
      doc/json-config-parameters.md
  2. +19
    -6
      src/js/pannellum.js

+ 7
- 0
doc/json-config-parameters.md Parādīt failu

@@ -63,6 +63,13 @@ not supported by the user's device. The user will be given the option to click
a link and visit this URL if Pannellum fails to work.


### `orientationOnByDefault` (boolean)

If set to `true`, device orientation control will be used when the panorama is
loaded, if the device supports it. If false, device orientation control needs
to be activated by pressing a button. Defaults to `false`.


### `showZoomCtrl` (boolean)

If set to `false`, the zoom controls will not be displayed. Defaults to `true`.


+ 19
- 6
src/js/pannellum.js Parādīt failu

@@ -192,13 +192,10 @@ if (document.fullscreenEnabled || document.mozFullScreenEnabled || document.webk
// Device orientation toggle
controls.orientation = document.createElement('div');
controls.orientation.addEventListener('click', function(e) {
if (orientation) {
if (orientation)
stopOrientation();
} else {
orientation = true;
window.addEventListener('deviceorientation', orientationListener);
controls.orientation.classList.add('pnlm-orientation-button-active');
}
else
startOrientation();
});
controls.orientation.addEventListener('mousedown', function(e) {e.stopPropagation();});
controls.orientation.addEventListener('touchstart', function(e) {e.stopPropagation();});
@@ -1820,6 +1817,12 @@ function processOptions() {
controls.zoom.style.display = 'none';
controls.fullscreen.style.display = 'none';
}
break;

case 'orientationOnByDefault':
if (config[key])
startOrientation();
break;
}
}
}
@@ -2043,6 +2046,16 @@ function stopOrientation() {
}

/**
* Start using device orientation.
* @private
*/
function startOrientation() {
orientation = true;
window.addEventListener('deviceorientation', orientationListener);
controls.orientation.classList.add('pnlm-orientation-button-active');
}

/**
* Escapes HTML string (to mitigate possible DOM XSS attacks).
* @private
* @param {string} s - String to escape


Notiek ielāde…
Atcelt
Saglabāt