Sco*_*ton 6 javascript transform css3
我已经建立了一个月左右的画廊,布局很简单,左边是缩略图菜单,右边是画廊预览.当您单击已加载的缩略图时,会触发一个mousdown事件,该事件会折叠缩略图区域并将图库预览扩展为完整大小(全部使用CSS3变换).到目前为止,一切都很完美,除了我创建了一个omouseover事件,当你将鼠标悬停在缩略图上时激活该功能.该函数重绘画廊预览div("pics")的内容并创建三个图像,两个是帧中的前一个图像,一个是帧中的下一个图像(在中心).在innerHTML中,它将CSS样式"left:"设置为724px或-724px,具体取决于它是向前还是向后.然后当生成所有这个html的函数完成时,负责监视开关的函数将"style.left ="设置为"0px".所有这些都适用于safari和chrome.但由于某些原因,firefox拒绝为过渡动画!我已经研究了这个故障几天,没有提出任何问题,在另一个版本中我可以在错误的时间过渡到火.但是在firefox中发生的所有事情都是从724px到0 px的无转换变化.这是我的代码片段.
这会切换缩略图图像并激活转换图像的功能
document.getElementById(thumbid).onmouseover = function() {
num = parseInt(this.name);
this.src = image[1][num].src;
this.style.cursor = "pointer";
switcher(num, null);
}
Run Code Online (Sandbox Code Playgroud)
这是确定如何切换图像的功能,它设置一个计时器(在它下面的变量中看到)接受输入而不改变图像,直到图像完成转换:
function switcher (num, direction) {
if (direction == 'left') {
num--;
} else if (direction == 'right') {
num++;
}
if (num < 0) {
num = fullcount-1;
} else if (num == fullcount) {
num = 0;
}
if (intransit == false) {
drawgallery(num);
document.getElementById("photos").style.left = "0px";
intransit = true;
transittimer = setTimeout("intransit = false; if (transitnumber != null) { switcher(transitnumber, null); transitnumber = null; }", 450);
} else {
transitnumber = num;
}
}
var transittimer = null;
var intransit = false;
var transitnumber = null;
Run Code Online (Sandbox Code Playgroud)
这是绘制图库的实际元素,start变量变为左变量.然后afterdrawgallery函数完成自己切换器将div的"左"设置为0px,在每个浏览器中,但是firefox,转换转换:
function drawgallery(num) {
start = 724;
if (num > curpos) {
} else {
start = "-"+start;
}
table = "<div id=\"photos\" style=\"position:absolute; height:470px; top:0px; left:"+start+"px;\">";
//first square drawn at an X of 0 so that the image remains the same but the drawer can slide over.
table += "<div id=\"i"+orderarr[2][curpos]+"\" style=\"overflow:hidden; position:absolute; top:0px; left:-724px; width:724px; height:470px;\">";
if (curpos <= (totalloaded-1)) {
table += "<img id=\"i"+curpos+"\" src=\"image.php?field=pics&id="+orderarr[2][curpos]+"\" style=\"border:none; position:relative; top:0px; left:0px;\" />";
} else {
table += "<div id=\"iloader"+orderarr[2][curpos]+"\" class=\"loader\" style=\"top:205px;\" ></div>";
}
table += "</div>";
table += "<div id=\"i"+orderarr[2][curpos]+"\" style=\"overflow:hidden; position:absolute; top:0px; left:724px; width:724px; height:470px;\">";
if (curpos <= (totalloaded-1)) {
table += "<img id=\"i"+curpos+"\" src=\"image.php?field=pics&id="+orderarr[2][curpos]+"\" style=\"border:none; position:relative; top:0px; left:0px;\" />";
} else {
table += "<div id=\"iloader"+orderarr[2][curpos]+"\" class=\"loader\" style=\"top:205px;\" ></div>";
}
table += "</div>";
/////////////////////////////
//second square drawn at an X of either negative or positive 724 so that the image remains the same but the drawer can slide over.
table += "<div id=\"i"+orderarr[2][num]+"\" style=\"overflow:hidden; position:absolute; top:0px; left:0px; width:724px; height:470px;\">";
if (curpos <= (totalloaded-1)) {
table += "<img id=\"i"+num+"\" src=\"image.php?field=pics&id="+orderarr[2][num]+"\" style=\"border:none; position:relative; top:0px; left:0px;\" />";
} else {
table += "<div id=\"iloader"+orderarr[2][num]+"\" class=\"loader\" style=\"top:205px;\" ></div>";
}
table += "</div>";
table += "</div>";
document.getElementById("pics").innerHTML = table;
curpos = num;
}
Run Code Online (Sandbox Code Playgroud)
尝试为转换添加超时。超时是转换属性中的最后一个属性。
-moz-transition:全1s线性1s;
您的元素此时应该可见,因此可见性和显示属性应该是块且可见的。您可以使用 opacity:0 (filter:alpha(opacity=0) for ie) 将其隐藏。
假设这会有所帮助。
| 归档时间: |
|
| 查看次数: |
402 次 |
| 最近记录: |