This is the HTML:
<div id="panoramaContain">
<div id="panoramaWrap">
<div class="tBar">Panorama
<div id="panNote" class="fRight fNorm fSml">
Click and drag to view panorama.</div>
</div>
<div id="panorama">
<div id="pan01" class="panDiv" style="left:0px;background-image:url('/levels/ep_procedures/ep_procedures01.jpg')"></div>
<div id="pan02" class="panDiv" style="left:480px;background-image:url('/levels/ep_procedures/ep_procedures02.jpg')"></div>
<div id="pan03" class="panDiv" style="left:960px;background-image:url('/levels/ep_procedures/ep_procedures03.jpg')"></div>
<div id="pan04" class="panDiv" style="left:-480px;background-image:url('/levels/ep_procedures/ep_procedures04.jpg')"></div>
</div>
<div class="clr"><div class="tBar2"><a href="/panorama/Dynasty" class="tip">Previous release<span class="fNorm">Dynasty</span></a> <div class="fRight"><a href="/panorama/id:1" class="tip">First release<span class="fNorm">The Final Hour</span></a></div></div></div>
</div>
This is the CSS:
#panoramaContain {
width:80%;
max-width:1200px;
margin:auto
}
#panoramaWrap {
position:absolute;
top:109px;
width:80%;
max-width:1200px
}
#panorama {
position:relative;
height:480px;
width:100%;
max-width:1200px;
float:right;
text-align:left;
white-space:nowrap;
overflow:hidden
}
.panDiv {
user-select:none;
position:absolute;
width:480px;
height:480px;
background-repeat:no-repeat;
}
This is the current Javascript:
<script type="text/javascript">
var panDiv;
var pan = [{ 'p':null,'x':0 }, { 'p':null,'x':480}, {'p':null,'x':960}, {'p':null,'x':-480 }];
var mPosStart = 0;
var touchDevice = ('ontouchstart' in document.documentElement) ? true : false;
function addListener(elm, handle, func) {
if (elm.addEventListener) {
elm.addEventListener(handle, func, false);
} else {
elm.attachEvent('on'+ handle, func);
}
}
function removeListener(elm, handle, func) {
if (elm.removeEventListener) {
elm.removeEventListener(handle, func, false);
} else {
elm.detachEvent('on'+ handle,func);
}
}
function panDown(e) {
document.onselectstart = function(){return false;};
panDiv.style.cursor = 'move';
if (touchDevice) {
addListener(panDiv,'touchmove',panMoveTouch);
addListener(panDiv,'touchend',panUp);
mPosStart = e.targetTouches[0].pageX;
} else {
addListener(panDiv,'mousemove',panMove);
addListener(panDiv,'mouseup',panUp);
mPosStart = e.clientX;
}
}
function panUp(e) {
for(x in pan) {
pan[x].x = parseInt(pan[x].p.style.left);
}
panDiv.style.cursor = 'default';
if (touchDevice) {
removeListener(panDiv,'touchmove',panMoveTouch);
} else {
removeListener(panDiv,'mousemove',panMove);
}
document.onselectstart = null;
}
function panMoveTouch(e) {
e.preventDefault();
panPosition((mPosStart - e.targetTouches[0].pageX));
}
function panMove(e) {
panPosition((mPosStart - e.clientX));
}
function panPosition(moved) {
// DEBUG.innerHTML = 'moved:['+ moved +']';
var newPos = 0, min = 0, minId = 0, max = 0, maxId = 0;
for(x in pan) {
newPos = (pan[x].x - moved);
pan[x].p.style.left = newPos +'px';
if (newPos < min) {
min = newPos;
minId = x;
} else if (newPos > max) {
max = newPos;
maxId = x;
}
}
// check for a loop
if (min < -480) {
pan[minId].x += 1920;
} else if (max > 1440) {
pan[maxId].x -= 1920;
}
}
function panListener() {
if (document.getElementById('panorama')) {
panDiv = document.getElementById('panorama');
pan[0].p = document.getElementById('pan01');
pan[1].p = document.getElementById('pan02');
pan[2].p = document.getElementById('pan03');
pan[3].p = document.getElementById('pan04');
panDiv.onselectstart = function(){return false;};
addListener(panDiv,((touchDevice) ? 'touchstart' : 'mousedown'),panDown);
}
}
panListener();
</script>
Edited 19.2 days after the original posting.