Ver a proveniência

Added panning support for touch based input.

pull/1/merge
Matthew Petroff há 12 anos
ascendente
cometimento
a19f936444
1 ficheiros alterados com 24 adições e 0 eliminações
  1. +24
    -0
      src/js/pannellum.js

+ 24
- 0
src/js/pannellum.js Ver ficheiro

@@ -151,6 +151,9 @@ function init() {
document.addEventListener('keyup',onDocumentKeyUp,false);
window.addEventListener('blur',clearKeys,false);
document.addEventListener('mouseout',onDocumentMouseUp,false);
document.addEventListener('touchstart',onDocumentTouchStart,false);
document.addEventListener('touchmove',onDocumentTouchMove,false);
document.addEventListener('touchend',onDocumentTouchEnd,false);
renderInit();
var t=setTimeout('isTimedOut = true',500);
@@ -204,6 +207,27 @@ function onDocumentMouseUp(event) {
document.getElementById('page').className = 'grab';
}

function onDocumentTouchStart(event) {
onPointerDownPointerX = event.targetTouches[0].clientX;
onPointerDownPointerY = event.targetTouches[0].clientY;
onPointerDownLon = lon;
onPointerDownLat = lat;
}

function onDocumentTouchMove(event) {
// override default action
event.preventDefault();
lon = (onPointerDownPointerX - event.targetTouches[0].clientX) * 0.1 + onPointerDownLon;
lat = (event.targetTouches[0].clientY - onPointerDownPointerY) * 0.1 + onPointerDownLat;
animate();
}

function onDocumentTouchEnd(event) {
// do nothing for now
}

function onDocumentMouseWheel(event) {
event.preventDefault();
if (fov >= 35 && fov <= 105) {


Carregando…
Cancelar
Guardar