Created
September 15, 2011 23:45
-
-
Save gnarf/1220819 to your computer and use it in GitHub Desktop.
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 rwhitespace = /\s+/; | |
// These hooks are used by animate to expand properties | |
$.each({ | |
margin: "margin*", | |
padding: "padding*", | |
borderWidth: "border*Width" | |
}, function( property, expandTemplate ) { | |
// order is important! | |
var cssExpand = [ "Top", "Right", "Bottom", "Left" ]; | |
$.cssHooks[ property ] = { | |
expand: function ( value ) { | |
var i, | |
type = $.type( value ), | |
// assumes a single number if not a string | |
parts = type === "string" ? value.split( rwhitespace ) : [ value ], | |
expanded = {}; | |
for ( i = 0; i < 4; i++ ) { | |
expanded[ expandTemplate.replace("*", cssExpand[i] ) ] = | |
parts[ i ] || parts[ i - 2 ] || parts[ 0 ]; | |
} | |
return expanded; | |
} | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment