Created
February 12, 2012 19:12
-
-
Save DracoBlue/1810322 to your computer and use it in GitHub Desktop.
AutoScale to 320x480, part of swarmfight.com, released under the Public Domain
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
AutoScale = function(dom_element) { | |
var that = this; | |
this.dom_element = dom_element; | |
var style = dom_element.style; | |
var transform_property = (style.TransitionDuration === '' && 'Transform'); | |
transform_property = transform_property || (style.MozTransitionDuration === '' && 'MozTransform'); | |
transform_property = transform_property || (style.WebkitTransitionDuration === '' && 'WebkitTransform'); | |
transform_property = transform_property || (style.OTransitionDuration === '' && 'OTransform'); | |
transform_property = transform_property || (style.MsTransitionDuration === '' && 'MsTransform'); | |
this.transform_property = transform_property; | |
jQuery(window).bind('resize', function() { | |
that.refresh(); | |
}); | |
that.refresh(); | |
}; | |
AutoScale.prototype.refresh = function() | |
{ | |
this.dom_element.style[this.transform_property] = 'scale(0.1)'; | |
var max_scale = Math.min((jQuery(window).height()/320), jQuery(window).width()/480); | |
this.dom_element.style[this.transform_property] = 'scale(' + max_scale + ')'; | |
}; | |
jsb.registerHandler('auto_scale', AutoScale); |
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
<div class="viewport"> | |
<input class="jsb_ jsb_auto_scale" type="hidden" value="" /> | |
<div class="view"> | |
Display! :) | |
</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment