Simplify animation js
parent
e04c0b25b6
commit
460bbdd071
|
@ -1,4 +1,4 @@
|
|||
/* SLIMBOX version 2015-04-30 */
|
||||
/* SLIMBOX version 2015-05-01 */
|
||||
|
||||
#lbOverlay {
|
||||
position: fixed;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* SLIMBOX version 2015-04-30 */
|
||||
/* SLIMBOX version 2015-05-01 */
|
||||
|
||||
#lbOverlay {
|
||||
position: fixed;
|
||||
|
|
15
slimbox2.js
15
slimbox2.js
|
@ -3,7 +3,7 @@
|
|||
Based on and mostly compatible with Slimbox2 <http://www.digitalia.be/software/slimbox2>
|
||||
(c) 2012+ Vitaliy Filippov <http://yourcmc.ru/wiki>
|
||||
MIT-style license.
|
||||
Version 2015-04-30
|
||||
Version 2015-05-01
|
||||
*/
|
||||
|
||||
window.addListener = (function() {
|
||||
|
@ -224,6 +224,7 @@ addListener(window, 'load', function() {
|
|||
nextImage = ((activeImage + 1) % images.length) || (options.loop ? 0 : -1);
|
||||
|
||||
els.center.className = "lbLoading";
|
||||
els.image.className = '';
|
||||
|
||||
preload = new Image();
|
||||
preload.onload = animateBox;
|
||||
|
@ -236,7 +237,6 @@ addListener(window, 'load', function() {
|
|||
function animateBox() {
|
||||
els.center.className = "";
|
||||
els.image.style.backgroundImage = "url(" + activeURL + ")";
|
||||
els.image.style.display = '';
|
||||
els.image.style.marginLeft = (-preload.width/2)+'px';
|
||||
els.image.style.marginTop = (-preload.height/2)+'px';
|
||||
els.image.style.width = preload.width+'px';
|
||||
|
@ -251,25 +251,20 @@ addListener(window, 'load', function() {
|
|||
|
||||
centerWidth = preload.width;
|
||||
centerHeight = preload.height;
|
||||
if (els.window.offsetHeight != centerHeight) {
|
||||
if (els.window.clientHeight != centerHeight) {
|
||||
var top = Math.max(0, middle - (centerHeight / 2));
|
||||
els.window.style.paddingTop = els.window.style.paddingBottom = (centerHeight/2)+'px';
|
||||
els.center.style.top = top+'px';
|
||||
}
|
||||
if (els.window.offsetWidth != centerWidth) {
|
||||
if (els.window.clientWidth != centerWidth) {
|
||||
els.window.style.paddingLeft = els.window.style.paddingRight = (centerWidth/2)+'px';
|
||||
els.center.style.marginLeft = (-centerWidth/2)+'px';
|
||||
}
|
||||
els.image.className = '';
|
||||
setTimeout(showImg, 15);
|
||||
els.image.className = 'lbvisible';
|
||||
if (prevImage >= 0) els.prevLink.style.display = '';
|
||||
if (nextImage >= 0) els.nextLink.style.display = '';
|
||||
}
|
||||
|
||||
function showImg() {
|
||||
els.image.className = 'lbvisible';
|
||||
}
|
||||
|
||||
function stop() {
|
||||
preload.onload = null;
|
||||
preload.src = preloadPrev.src = preloadNext.src = activeURL;
|
||||
|
|
Loading…
Reference in New Issue