var nextImage = document.getElementById("image" + (idx)); if (nextImage) { if (nextImage.getAttribute("srclazy")) { nextImage.setAttribute("src", nextImage.getAttribute("srclazy")); var rewImage = document.getElementById("image" + (idx)); var rewImage_ = rewImage.cloneNode(true); rewImage.parentNode.replaceChild(rewImage_,nextImage); } } |
<div class="slideshow swipeshow preventSel"> <ul class="slides"> <li class="slide"> <div class="mypopup" rel="ugallery_cvt/1-big.jpg"><img id = "image0" src="ugallery_cvt/1.jpg" alt="" /></div> </li> <li class="slide"> <div class="mypopup" rel="ugallery_cvt/2-big.jpg"><img id="image1" src="dammy.jpg" srclazy="ugallery_cvt/2.jpg" alt="" /></div> </li> <li class="slide"> <div class="mypopup" rel="ugallery_cvt/3-big.jpg"><img id="image2" src="dammy.jpg" srclazy="ugallery_cvt/3.jpg" alt="" /></div> </li> <li class="slide"> <div class="mypopup" rel="ugallery_cvt/4-big.jpg"><img id="image3" src="dammy.jpg" srclazy="ugallery_cvt/4.jpg" alt="" /></div> </li> <li class="slide"> <div class="mypopup" rel="ugallery_cvt/5-big.jpg"><img id="image4" src="dammy.jpg" srclazy="ugallery_cvt/5.jpg" alt="" /></div> </li> <li class="slide"> <div class="mypopup" rel="ugallery_cvt/6-big.jpg"><img id="image5" src="dammy.jpg" srclazy="ugallery_cvt/6.jpg" alt="" /></div> </li> <li class="slide"> <div class="mypopup" rel="ugallery_cvt/7-big.jpg"><img id="image6" src="dammy.jpg" srclazy="ugallery_cvt/7.jpg" alt="" /></div> </li> </ul> <!--<button class='previous'></button> <button class='next'></button>--> <div class='dots'></div> </div> |
function loadOver() { console.log("loaded"); var rewImage = document.getElementById("image" + (idx)); rewImage.style.opacity = "1"; lImg1.style.opacity = "0"; lImg.style.opacity = "0"; } function addEv(obj, type, func){ if(obj.addEventListener){ obj.addEventListener(type, func, false); } else{ if(obj.attachEvent) obj.attachEvent('on' + type, func); } } addEv(rewImage,'load', loadOver); |
var nextImage = document.getElementById("image" + (idx)); if (nextImage ) { if (nextImage.getAttribute("srclazy")) { nextImage.setAttribute("src", nextImage.getAttribute("srclazy")); var rewImage = document.getElementById("image" + (idx)); lImg1.style.opacity = "0"; lImg.style.opacity = "0"; nextImage.onerror = function (evt) { 画像がnot foundならローディング中表示化 lImg1.style.opacity = ".65"; lImg.style.opacity = "1"; } if ( !rewImage.style.opacity ) { // src書き換えが済んでないので表示初期化 rewImage.style.opacity = "0"; lImg1.style.opacity = ".65"; lImg.style.opacity = "1"; } var rewImage_ = rewImage.cloneNode(true); rewImage.parentNode.replaceChild(rewImage_,nextImage); function loadOver() { //console.log("loaded"); var rewImage = document.getElementById("image" + (idx)); rewImage.style.opacity = "1"; lImg1.style.opacity = "0"; lImg.style.opacity = "0"; } rewImage.onload = loadOver; // 読み込み完了なら後処理関数呼び出し nextImage.setAttribute("src", nextImage.getAttribute("srclazy")); // IE用おまじない } } |
.imgfade { transition: all 0.2s ease; -moz-transition: all 0.2s ease; -webkit-transition: all 0.2s ease; -o-transition: all 0.2s ease; -ms-transition: all 0.2s ease; } .slideBoxnotice { margin-top:40px; } .slideBoxloader { width : 10%; margin: 0 auto; } |
<div class="slideshow swipeshow preventSel" id="slideBox"> <ul class="slides" > <li class="slide"> <div class="mypopup" rel="ugallery_cvt/1-big.jpg"><img class="imgfade" id ="image0" src="dammy.png" srclazy="ugallery_cvt/1.jpg" alt="" /></div> </li> <li class="slide"> <div class="mypopup" rel="ugallery_cvt/2-big.jpg"><img class="imgfade" id="image1" src="dammy.png" srclazy="ugallery_cvt/2.jpg" alt="" /></div> </li> <li class="slide"> <div class="mypopup" rel="ugallery_cvt/3-big.jpg"><img class="imgfade" id="image2" src="dammy.png" srclazy="ugallery_cvt/3.jpg" alt="" /></div> </li> <li class="slide"> <div class="mypopup" rel="ugallery_cvt/4-big.jpg"><img class="imgfade" id="image3" src="dammy.png" srclazy="ugallery_cvt/4.jpg" alt="" /></div> </li> <li class="slide"> <div class="mypopup" rel="ugallery_cvt/5-big.jpg"><img class="imgfade" id="image4" src="dammy.png" srclazy="ugallery_cvt/5.jpg" alt="" /></div> </li> <li class="slide"> <div class="mypopup" rel="ugallery_cvt/6-big.jpg"><img class="imgfade" id="image5" src="dammy.png" srclazy="ugallery_cvt/6.jpg" alt="" /></div> </li> <li class="slide"> <div class="mypopup" rel="ugallery_cvt/7-big.jpg"><img class="imgfade" id="image6" src="dammy.png" srclazy="ugallery_cvt/7.jpg" alt="" /></div> </li> </ul> <!--<button class='previous'></button> <button class='next'></button>--> <div class='dots'></div> </div> <script> (function($) { $(".version").text($.swipeshow.version); $(".slideshow").swipeshow({ mouse: true, interval: 6000 }); })(jQuery); </script> |