我有一個燈箱照片庫我正在建設。當第一個圖像加載css過渡作品。當加載後的每個圖像都沒有。任何想法爲什麼?第一次加載後的照片卻沒有過渡。JavaScript阻止CSS?
Image.prototype.load = function(url){
var thisImg = this;
var xmlHTTP = new XMLHttpRequest();
xmlHTTP.open('GET', url,true);
xmlHTTP.responseType = 'arraybuffer';
xmlHTTP.onload = function(e) {
var blob = new Blob([this.response]);
thisImg.src = window.URL.createObjectURL(blob);
};
xmlHTTP.onprogress = function(e) {
thisImg.completedPercentage = parseInt((e.loaded/e.total) * 100);
};
xmlHTTP.onloadstart = function() {
thisImg.completedPercentage = 0;
};
xmlHTTP.onloadend = function() {
thisImg.completedPercentage = 0;
gallery.appendChild(currentImage);
gallery.className = "gallery toggle";
};
xmlHTTP.send();
};
.gallery {
display: absolute;
position: fixed;
margin: auto;
visibility: hidden;
opacity: 0;
-moz-transition: opacity 0.5s, visibility 0.5s ease-in-out;
-webkit-transition: opacity 0.5s, visibility 0.5s ease-in-out;
-ms-transition: opacity 0.5s, visibility 0.5s ease-in-out;
transition: opacity 0.5s, visibility 0.5s ease-in-out;
background: rgba(0, 0, 0, 0.0);
width: 96%;
height: 96%;
margin-top: 2%;
margin-left: 2%;
overflow: hidden;
z-index: 1001;
}
.gallery.toggle {
visibility: visible;
opacity: 1;
}
你可以參考https://developers.google.com/speed/docs/insights/BlockingJS#InlineJS – Rajesh