Created
May 26, 2014 20:34
-
-
Save ICarpenter/0c30d304dee899741fd4 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
ngular.module('Fn') | |
.factory('ImageService', function () { | |
return { | |
calculateOffset: function(width, height) { | |
if (width === height) { | |
return false; | |
} | |
var bigger, smaller, side; | |
var style = {}; | |
if(width > height) { | |
bigger = width; | |
smaller = height; | |
side = 'top'; | |
} else { | |
bigger = height; | |
smaller = width; | |
side = 'left'; | |
} | |
style[side] = (((bigger - smaller) / bigger) * 50) + '%'; | |
return style; | |
} | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment