적절한 분화를 개선하지 않아도됩니다. 문제의 코드는 requestAnimationFrame
polyfill입니다. 즉, 다른 공급 업체 접두사를 시도 할 것입니다. 때로는 코드가 "requestAnimationFrame"
(소문자 : r
)이고 때로는 msRequestAnimationFrame
과 같은 공급 업체 접두어가 사용됩니다.
동적으로 작성되므로 "equestAnimationFrame"
이 항상 있지만, 접두사가 "r"
또는 "R"
일 수 있습니다.
은 "축약을 향상"부분 때문에 대신 쓰기입니다 :
var requestAnimationFrame = window.requestAnimationFrame ||
window.msRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.oRequestAnimationFrame ||
그들은 ["ms","moz","o", "webkit"]
에 루프를 실행하고 접두사를 시도합니다. 이렇게하면 기껏해야 몇 바이트 만 절약됩니다. 여기
내가 생각 코드가 명확하고 수행 같은 일 :
var base = "equestAnimationFrame" // the base string
var alternatives = window["r"+base] || // try the basic option first
['moz', 'ms', 'o', 'webkit'].map(function(x){
return x+"R" + base; // all the options
}).filter(function(x){ // check if in window
return x in window;
})[0];
내 생각은 그 이후가 [벤더 + 'R'+ equestAnimationFrame]' – matsjoyce