c++){ index = orderArr[c+','+r]; if(effect.chess && index % 2 == 1) effect = effectsInvers; else effect = optionsCopy; styleStart = {top: 0, left: 0, opacity: 1, width: display.width, height: display.height, overflow: 'hidden'}; styleEnd = array_copy(styleStart); piece = array_copy(pieces[c+','+r]); if(effect.fade) styleStart.opacity = 0; if(effect.top && effect.bottom) piece[0] = piece[2] = (piece[0] + piece[2]) / 2; else if(effect.top) piece[2] -= pieces.height; else if(effect.bottom) piece[0] += pieces.height; if(effect.left && effect.right) piece[1] = piece[3] = (piece[1] + piece[3]) / 2; else if(effect.left) piece[1] -= pieces.width; else if(effect.right) piece[3] += pieces.width; if(effect.zoom){ styleStart.left = pieces[c+','+r][3]; styleStart.top = pieces[c+','+r][0]; if(effect.left && effect.right) styleStart.left += pieces.width / 2; else if(effect.right) styleStart.left += pieces.width; else if(!effect.left) styleStart.left = 0; if(effect.top && effect.bottom) styleStart.top += pieces.height / 2; else if(effect.bottom) styleStart.top += pieces.height; else if(!effect.top) styleStart.top = 0; if(effect.left || effect.right) piece[1] = piece[3] = 0; if(effect.top || effect.bottom) piece[0] = piece[2] = 0; styleStart.width = effect.left || effect.right ? 0 : display.width; styleStart.height = effect.top || effect.bottom ? 0 : display.height; } if(effect.move){ if(effect.top){ styleStart.top = parseInt(styleStart.top)-pieces.height; piece[0] += pieces.height; piece[2] += pieces.height; } if(effect.bottom){ styleStart.top = parseInt(styleStart.top)+pieces.height; piece[0] -= pieces.height; piece[2] -= pieces.height; } if(effect.left){ styleStart.left = parseInt(styleStart.left)-pieces.width; piece[1] += pieces.width; piece[3] += pieces.width; } if(effect.right){ styleStart.left = parseInt(styleStart.left)+pieces.width; piece[1] -= pieces.width; piece[3] -= pieces.width; } } styleStart.clip = piece; styleEnd.clip = pieces[c+','+r]; styleDif = []; foreach(styleEnd, function(property){ if(styleStart[property].toString() != styleEnd[property].toString()){ styleDif[property] = []; if(property == 'clip'){ foreach(styleStart[property], function(n){ styleDif[property][n] = styleEnd[property][n] - styleStart[property][n]; }); }else styleDif[property] = styleEnd[property] - styleStart[property]; needAnimate[index] = true; } }); startStylesArr[index] = styleStart; AnimateArr[index] = []; if(effect.delay) for(var n = 0; n < Math.round(index*effect.delay/effect.interval); n++) AnimateArr[index].push(null); var frameN; if(!needAnimate[index]) AnimateArr[index].push({display: ''}); else for(frameN = 1; frameN <= framesCount; frameN++){ progress = frameN/framesCount; progress = -Math.cos(progress*Math.PI)/2 + 0.5; var style_c = []; if(frameN == framesCount) style_c = styleEnd; else{ foreach(styleDif, function(property){ value = []; if(property == 'clip'){ foreach(styleDif[property], function(n){ value[n] = styleStart[property][n]+styleDif[property][n]*progress; }); }else value = styleStart[property]+styleDif[property]*progress; style_c[property] = value; }); } AnimateArr[index].push(style_c); } }//for EffectsArr[effectsOptStr] = {startStylesArr: startStylesArr, AnimateArr: AnimateArr, needAnimate: needAnimate}; } for(r = 0; r < pieces.rows; r++) for(c = 0; c < pieces.cols; c++){ index = orderArr[c+','+r]; if(parameters.contentmode){ image = newElement('DIV', startStylesArr[index]); image.appendChild(parameters.src.cloneNode(true)); }else{ image = newElement('IMG', startStylesArr[index]); image.src = parameters.src; } var style = image.style; style.position = 'absolute'; container.appendChild(image); AnimateItemsArr[index] = style; if(!needAnimate[index]) hide(AnimateItemsArr[index]); } //ANIMATE var time_s = now(); var framesCountAll = AnimateArr[AnimateArr.length-1].length; var AnimateItem, AnimateItemsComplete = [], timerFuncStatus = true, timerFunc = function(){ if(timerFuncStatus){ var frameC = Math.ceil((now() - time_s) / effect.interval); frameC = frameC >= framesCountAll ? framesCountAll-1 : frameC-1; foreach(AnimateArr, function(index){ AnimateItem = frameC > AnimateArr[index].length-1 ? AnimateArr[index].length-1 : frameC; if(AnimateArr[index][AnimateItem] && !AnimateItemsComplete[index+','+AnimateItem]){ setStyles(AnimateItemsArr[index], AnimateArr[index][AnimateItem]); AnimateItemsComplete[index+','+AnimateItem] = true; } }); if(frameC == framesCountAll-1){ if(pieces.count > 1){ container.innerHTML = ''; if(parameters.contentmode) container.appendChild(parameters.src); else container.innerHTML = '<img src="'+parameters.src+'" width="'+display.width+'" height="'+display.height+'" />'; } parameters.callback(container); timerFuncStatus = false; } } return timerFuncStatus; }; var animateInterval = setInterval(function(){ if(!timerFunc()) clearInterval(animateInterval); }, effect.interval);}//Effects var OrderArr = []; function doOrder(cols, rows, order, road, reverse){ cols = parseInt(cols); rows = parseInt(rows); var arr = [], tmp = [], i = 0, c = 0, r = 0, count = cols*rows, cl = cols