| 430 | } |
| 431 | |
| 432 | autoscale(containerWidth, containerHeight) { |
| 433 | let scaleRatio; |
| 434 | |
| 435 | if (containerWidth === 0 || containerHeight === 0) { |
| 436 | scaleRatio = 0; |
| 437 | |
| 438 | } else { |
| 439 | |
| 440 | const vp = this._viewportLoc; |
| 441 | const targetAspectRatio = containerWidth / containerHeight; |
| 442 | const fbAspectRatio = vp.w / vp.h; |
| 443 | |
| 444 | if (fbAspectRatio >= targetAspectRatio) { |
| 445 | scaleRatio = containerWidth / vp.w; |
| 446 | } else { |
| 447 | scaleRatio = containerHeight / vp.h; |
| 448 | } |
| 449 | } |
| 450 | |
| 451 | this._rescale(scaleRatio); |
| 452 | } |
| 453 | |
| 454 | // ===== PRIVATE METHODS ===== |
| 455 | |