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
// Choose the area constraint. | |
// Here the image can't occupy more than 20% of its container. | |
const maxArea = container.width * container.height * 0.2; | |
// Choose the height and width constraints. | |
// In this case the container minus 20px on each side for padding. | |
const maxWidth = container.width - 20 * 2; | |
const maxHeight = container.height - 20 * 2; | |
// Get the native aspect ratio of the image. |