I want to maintain proportion, but scale it to fit in the view port.0Got some PHP code laying around that does just that. Should be easy to convert to JS: ------------------------------------------------------------------------------------------------------------------------------------------------ function fitObjectInBox($objectWidth, $objectHeight, $boxWidth, $boxHeight) { // Fit's our image in a box with a given width and heigth while proportions remain, // *or* resizes it based on one site proportionally if only width or height is given $widthRatio = @($boxWidth / $objectWidth); $heightRatio = @($boxHeight / $objectHeight); if (($widthRatio < $heightRatio) && ($widthRatio!=0) || ($heightRatio==0)) { $ratio = $widthRatio; } else { $ratio = $heightRatio; } $new_width = ceil($objectWidth * $ratio); $new_height = ceil($objectHeight * $ratio); return array($new_width, $new_height); } ------------------------------------------------------------------------------------------------------------------------------------------------ HTH, Felix Glen Lipka wrote: Sorry, working on it right now. :) |
- [jQuery] Re: Overlay plugin? Felix Geisendörfer
- [jQuery] Re: Overlay plugin? Glen Lipka