User:Monster Domosed/common.js: Difference between revisionsGive feedback
No edit summary Tag: Manual revert |
No edit summary |
||
| Line 48: | Line 48: | ||
dragOK = true, | dragOK = true, | ||
ready = false; | ready = false; | ||
/* ============================================================ | |||
SQUARE VIEWPORT | |||
============================================================ */ | |||
var viewport = document.createElement('div'); | |||
viewport.className = 'rm-square-viewport'; | |||
viewport.style.position = 'absolute'; | |||
viewport.style.width = sq + 'px'; | |||
viewport.style.height = sq + 'px'; | |||
viewport.style.left = ((fw - sq) / 2) + 'px'; | |||
viewport.style.top = ((fh - sq) / 2) + 'px'; | |||
viewport.style.overflow = 'hidden'; | |||
el.insertBefore(viewport, el.firstChild); | |||
/* ============================================================ | /* ============================================================ | ||
| Line 54: | Line 68: | ||
var img = makeImg(imageUrl, '', 'rm-strip'); | var img = makeImg(imageUrl, '', 'rm-strip'); | ||
img.style.height = sq + 'px'; | img.style.position = 'absolute'; | ||
img.style.width | img.style.height = sq + 'px'; | ||
img.style.width = (sq * count) + 'px'; | |||
img.style.top = '0'; | |||
img.style.left = '0'; | |||
img.addEventListener('load', function () { | img.addEventListener('load', function () { | ||
| Line 66: | Line 83: | ||
}); | }); | ||
viewport.appendChild(img); | |||
if (img.complete && img.naturalWidth > 0) { | if (img.complete && img.naturalWidth > 0) { | ||
| Line 126: | Line 143: | ||
/* ============================================================ | /* ============================================================ | ||
FRAME DISPLAY | FRAME DISPLAY | ||
============================================================ */ | ============================================================ */ | ||
function show(idx) { | function show(idx) { | ||
cur = ((idx % count) + count) % count; | cur = ((idx % count) + count) % count; | ||
img.style.left = ( | img.style.left = -(cur * sq) + 'px'; | ||
} | } | ||
| Line 157: | Line 173: | ||
if (wrap) wrap.classList.add('rm-is-2d'); | if (wrap) wrap.classList.add('rm-is-2d'); | ||
dragOK = false; | dragOK = false; | ||
viewport.style.display = 'none'; | |||
} else { | } else { | ||
el.classList.remove('rm-is-2d'); | el.classList.remove('rm-is-2d'); | ||
if (wrap) wrap.classList.remove('rm-is-2d'); | if (wrap) wrap.classList.remove('rm-is-2d'); | ||
dragOK = true; | dragOK = true; | ||
viewport.style.display = ''; | |||
} | } | ||