//Галерея изображений на первой странице сайта function TCGallery(parent) { this.work = function() { if(this.mas[0].style.opacity > 0.05) { this.mas[0].style.opacity = this.mas[0].style.opacity - 0.05; this.timeout_id=setTimeout(function(thiz){return function(){thiz.work();}}(this),50); this.test++; //console.info(this.test+' 50 '+this.mas[0].style.opacity); }else { //Перестовляем Z индексы первый на последнее место (больший наверху) if(this.mas.length>0) { var z=this.mas[this.mas.length-1].style.zIndex; for(var i=this.mas.length-1;i>0;i--) { this.mas[i].style.zIndex=this.mas[i-1].style.zIndex } this.mas[0].style.zIndex=z; } //Поменяли местами востанавливаем прозрачность for(var i=0;i0) setTimeout(function(thiz){return function(){thiz.work();}}(this),5000); maxz++; //Кнопочки для переключения картинок var cdv=document.createElement('div'); cdv.style.cssText='opacity: 0.7; display: block; position: absolute; bottom: 5px; right: 5px; z-index: '+maxz+'; border: solid 0px red;'; for(var i=0;i0) this.btns[0].style.backgroundColor='#f3af5a'; }; //Переместить на заданный слой (позиция с 0) this.moveTo = function(pos) { if(pos<0 || pos>this.firstmas.length - 1) return; var elm=this.firstmas[pos]; for(var j=0;j0;i--) { this.mas[i].style.zIndex=this.mas[i-1].style.zIndex } this.mas[0].style.zIndex=z; this.mas.sort(function(a,b){return b.style.zIndex-a.style.zIndex;}); } //Поменяли местами востанавливаем прозрачность for(var i=0;i this.resize(), 1000); } //Подстраиваюсь под размер родительского компонента resize() { let pDiv = this.parent.parentElement; this.parent.style.width = pDiv.offsetWidth+'px'; } //Добавляю кнопочки для переключения картинок addImage(small) { this.mas.push({div: small, sell: false}); small.onmouseover = function(thiz,small) { return function() { if(!thiz.ower) return; let pos=-1; for(let i=0;i0) dx=Math.ceil(dx); else dx=Math.floor(dx); this.parent.scrollLeft+=dx; if(this.parent.scrollLeft!=this.pos) setTimeout(function(thiz){ return function(){ thiz.moveTo(); } }(this),10); } }