私が考えることができる唯一の方法は、エフェクトを使用する前または使用中に、バックグラウンドでJSである種の速度テストを実行することです。これは、プロセッサ速度が原因で遅いデバイスをキャッチするか、またはその逆で、時間精度が高い/速いデバイスをキャッチする必要があります。ただし、デバイスに最適化があり、グラフィック効果を計算するために異なるプロセッサを使用している場合、これは機能しません。
var speedtest = function(){
/// record when we start
var target = new Date().getTime(), count = 0, slow = 0;
/// trigger a set interval to keep a constant eye on things
var iid = setInterval(function(){
/// get where we actually are in time
var actual = new Date().getTime();
/// calculate where we expect time to be
target += 100;
/// 100 value here would need to be tested to find the best sensitivity
if ( (actual - target) > 100 ) {
/// make sure we aren't firing on a one off slow down, wait until this
/// has happened a few times in a row. 5 could be too much / too little.
if ( (++slow) > 5 ) {
/// finally if we are slow, stop the interval
clearInterval(iid);
/// and disable our fancy resource-hogging things
turnOffFancyAnimations();
}
}
else if ( slow > 0 ){
/// decrease slow each time we pass a speedtest
slow--;
}
/// update target to take into account browsers not being exactly accurate
target = actual;
/// use interval of 100, any lower than this might be unreliable
},100);
}
もちろん、これを実行すると、デバイスの速度にも影響するため、実際には最善の解決策ではありません。原則として、画面が小さい場合は、アニメーションなどの不要なものを無効にする傾向があります。
この方法のもう1つの欠点は、私が以前に経験したことですが、マルチタブ環境を実装する特定のブラウザーsetIntervalsは、タブが表示されていないときに自動的に特定の速度に制限されることです。これは、このブラウザがタブで移動すると、自動的にエクスペリエンスがダウングレードされることを意味します-この課せられた速度制限が何らかの方法で検出されない限り。