わからないためhttps://github.com/naugtur/insertionQueryを参照してくださいが、私はだった、これは私が使用して終了ソリューションです。
var __css = document.createElement("style");
__css.type = "text/css";
__css.innerHTML = '.alertInsertion {animation: __nodeInserted 0.001s !important; -o-animation: __nodeInserted 0.001s !important; -ms-animation: __nodeInserted 0.001s !important; -moz-animation: __nodeInserted 0.001s !important; -webkit-animation: __nodeInserted 0.001s !important;}'+
'@keyframes __nodeInserted {from{outline-color: #111;}to{outline-color: #000;}}'+
'@-moz-keyframes __nodeInserted {from{outline-color: #111;}to{outline-color: #000;}}'+
'@-webkit-keyframes __nodeInserted {from{outline-color: #111;}to{outline-color: #000;}}'+
'@-ms-keyframes __nodeInserted {from{outline-color: #111;}to{outline-color: #000;}}'+
'@-o-keyframes __nodeInserted {from{outline-color: #111;}to{outline-color: #000;}}';
document.body.appendChild(__css);
insertion_event = function(event){
if (event.animationName == '__nodeInserted') {
event.target.className = event.target.className.replace(/\balertInsertion\b/,'');
document.dispatchEvent(new CustomEvent('elementInserted', {'target': event.target}));
}
}
document.addEventListener('animationstart', insertion_event, false);
document.addEventListener('MSAnimationStart', insertion_event, false);
document.addEventListener('webkitAnimationStart', insertion_event, false);
__nodeInsertedアニメーションを呼び出して、ページのCSSへのクラスのalertInsertion」を追加します。
アニメーションがトリガされた場合、それは要素からクラスを削除し、それをトリガした要素を含むカスタムイベントeventInsertedを送出します。
document.addEventListener('elementInserted', function(e)
{
//Do whatever you want with e.target here.
});
、あなたはそれをトリガーにしたい任意の要素に.alertInsertionクラスを追加:
単にイベントリスナーを追加することによって、それを使用しています。
要素にアニメーションのある別のクラスがある場合、このクラスが削除された後に要素が実行されます。
これを行う良い方法はありません。 setTimeoutのバージョンはどこでも動作しますが、通常DOMをポーリングするのはあなたがすべきことではありません。突然変異のイベントはいくつかのブラウザでは機能しますが、すでに廃止されており、おそらく使用すべきではありません。 – adeneo
リンクの追加をトリガーするサードパーティのツールはどのようなイベントですか?ページの読み込み中か、ページ上のいくつかの要素をクリックしていますか? –
ブレイク、わかりません。コードはいくつかのJSファイルに縮小されているため、簡単にブレークポイントを設定することはできません。 – Stephen