Created
April 30, 2012 19:05
-
-
Save frostney/2561433 to your computer and use it in GitHub Desktop.
Small jQuery plugin for using CSS3 properties with vendor prefixes. Also includes functions for scaling and rotating.
This file contains 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
(function($) { | |
var vendorPrefix = ['webkit', 'o', 'ms', 'moz']; | |
$.fn.vendorProperty = function(property, argument) { | |
var self = this; | |
self.css(property, argument); | |
$.each(vendorPrefix, function(index, value) { | |
self.css('-' + value + '-' + property, argument); | |
}); | |
} | |
$.fn.transform = function(transformArgument) { | |
if (typeof transformArgument === "undefined") { | |
return; | |
} | |
this.vendorProperty('transform', transformArgument); | |
} | |
$.fn.transformOrigin = function(originX, originY) { | |
var originArgument = originX + ' ' + originY; | |
this.vendorProperty('transform-origin', originArgument); | |
} | |
$.fn.scale = function(scaleX, scaleY) { | |
if (typeof scaleY === "undefined") { | |
scaleY = scaleX; | |
} | |
this.transform('scale(' + scaleX + ', ' + scaleY + ')'); | |
} | |
$.fn.rotate = function(angle) { | |
if (typeof angle !== "number") { | |
return; | |
} | |
this.transform('rotate(' + angle + 'deg)'); | |
} | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment