0
トランジションに問題があります。イメージを含むdivは「right:200px;」から移動する必要があります。ここイメージをロードした後でトランジションイベントを開始する
div.contenedor {
width: 300px;
height: 257px;
position: fixed;
right: 200px;
bottom: 0px;
z-index: 100;
-webkit-transition: right 2s;
-moz-transition: right 2s;
transition: right 2s;
}
とJSコード:
function transi() {
var id = "L" + Math.floor(Math.random() * 10000);
function open() {
var eOpen = document.getElementById(id + "_container");
eOpen.style.right = "400px";
};
var dContenedor = document.createElement("div");
dContenedor.id = id + "_container";
dContenedor.className = "contenedor";
var ima = document.createElement("img");
ima.src = "XXXX.jpg";
ima.width = "300";
ima.height = "250";
dContenedor.appendChild(ima);
document.onreadystatechange = function(){
var rsw = this.readyState;
console.log(rsw);
if (rsw) if (rsw != 'complete') if (rsw != 'loaded') {return;}
document.body.appendChild(dContenedor);
console.log(ima.complete);
if (ima.complete) {
open();
};
}
};
transi();
については2Sでの推移と画像が文書にロードされたときに開始する必要が移行する「400ピクセル」に、ここでCSSのコードがあります何らかの理由で移行が行われておらず、divが直接「400px」に向かいます。誰かが考えていることがあれば、私はそれを感謝します。
それはあなたが要素にトランジションを設定しましたが、あなたはJS 'オープン()'関数に移動しているものと思われますその要素のコンテナです。 – KWeiss
'document.querySelector().onload = function(){...}' –
いいえ、同じ要素です.dContenedorはトランジションを持ち、open()を呼び出すとその要素 " document.getElementById(id + "_container"); " "style.right"を400に変更してください。 はい、私はonloadを試してみましたが、同じ結果が得られました。 私は最近、 "setTimeout(function(){open(); 3000);のように" setTimeout() "の中にopen()今、移行が表示されます、なぜですか?私は考えていない... –