Created
June 8, 2014 17:55
-
-
Save weishai/249b8723dbc74c7f9880 to your computer and use it in GitHub Desktop.
jQuery Rotate On Axis In IE
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
/** | |
* jQuery Rotate On Axis In IE Plugin 1.0.0 | |
* | |
* Copyright (c) 2014 Aryeh Citron | |
* | |
* Licensed under MIT: http://www.opensource.org/licenses/mit-license.php | |
*/ | |
(function ($) | |
{ | |
$.fn.rotateOnAxisInIE = function (options) | |
{ | |
var settings = $.extend( | |
{ | |
spinSpeed: "slow", | |
}, options); | |
return this.each(function () | |
{ | |
var startingInterval; | |
switch (settings.spinSpeed) | |
{ | |
case "slow": startingInterval = 0.006; break; | |
case "medium": startingInterval = 0.01; break; | |
case "fast": startingInterval = 0.03; break; | |
default: startingInterval = 0.01; break; | |
} | |
var image = this; | |
var imageWidth = 1; | |
var gettingSmaller = true; | |
var fullRotation = true; | |
var interval = startingInterval; | |
var increment = startingInterval / 4; | |
var refreshRateInMilliseconds = 35; | |
setInterval(function () | |
{ | |
$(image).css("msTransform", "scaleX(" + imageWidth + ")"); | |
if (gettingSmaller) | |
{ | |
interval = interval + increment; | |
imageWidth = imageWidth - interval; | |
} | |
else | |
{ | |
interval = interval - increment; | |
imageWidth = imageWidth + interval; | |
} | |
if (imageWidth <= 0) | |
{ | |
gettingSmaller = false; | |
if ($(image).css("filter") == "") | |
$(image).css("filter", "fliph"); | |
else | |
$(image).css("filter", ""); | |
imageWidth = 0.01; | |
} | |
if (imageWidth >= 1) | |
{ | |
gettingSmaller = true; | |
} | |
if (gettingSmaller && interval < 0) | |
interval = 0; | |
}, refreshRateInMilliseconds); | |
}); | |
}; | |
}(jQuery)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment