Last active
December 16, 2015 08:19
-
-
Save stephen-james/5405023 to your computer and use it in GitHub Desktop.
regex for decomposing transition css declarations (using this in the arc menu widget)
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
| (.*)(left|top|opacity|height|width|transform|-webkit-transform)\s*(initial|\s*-?[0-9]*\.?[0-9]*m?s?)\s*(initial|linear|ease(?:-in|-out|-in-out)?|cubic-bezier\((?:\s*-?[0-9]*?\.?[0-9]*?\s*,?)*?\))?(initial|\s*-?[0-9]*\.?[0-9]*m?s?)?(.*) | |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Decomposing CSS3 Transition declarations
I had a few behavioural issues modifying attributes individually when dealing with elements which had multiple properties in transition. So I put this together to help me decompose the transition so that I could update the attribute for the property I wanted and re-assign the whole transition rule back with
$(el).css("transition", updatedCssStatement)Capture Groups
Previous Statements
This catches statements for other properties previous to this one in the
transitionrule.Property
This captures the
transition-propertyspecified in the rule. If you are dealing with multiple properties, change this to only be the one you want to modify to match only that statement.Duration
This captures the
transition-durationTiming Function
This captures the
transition-timing-function, eg.linear,ease,ease-in,ease-out,cubic-bezierDelay
This captures the
transition-delayOther Statements
This catches statements for other properties after this one in the
transitionrule.