Last active
August 29, 2015 14:23
-
-
Save sck/be40012f4fe75c4f3c01 to your computer and use it in GitHub Desktop.
Scale Animation And Transition Durations: Use to debug CSS animations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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