Skip to content

Instantly share code, notes, and snippets.

@sck
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sck/be40012f4fe75c4f3c01 to your computer and use it in GitHub Desktop.
Save sck/be40012f4fe75c4f3c01 to your computer and use it in GitHub Desktop.
Scale Animation And Transition Durations: Use to debug CSS animations
var debug = true
function scale_animation_and_transition_durations(factor) {
var cssRuleCode = document.all ? 'rules' : 'cssRules'
var ss = document.styleSheets
for (var i = 0, size = ss.length; i < size; i++) {
var r = ss[i][cssRuleCode]
for (var j = 0, s = r.length; j < s; j++) {
var rule = r[j]
var sel = rule.selectorText;
["animationDuration", "transitionDuration"].forEach(function(f) {
var v = rule.style ? rule.style[f] : false
var pi = parseFloat(v)
if (v != "" && !isNaN(pi)) {
var l = String(pi).length
var unit = v.substr(l, 99)
if (debug) console.log("["+sel + ":" + f+"] " + pi + " * " + factor + unit)
rule.style[f] = String(pi * factor) + unit
}
})
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment