PHP Classes

File: plugins/Crop/src/zoomer.js

Recommend this page to a friend!
  Classes of Laudir Bispo   PHP Real Estate Website   plugins/Crop/src/zoomer.js   Download  
File: plugins/Crop/src/zoomer.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: PHP Real Estate Website
Manage the properties of a real estate business
Author: By
Last change:
Date: 3 years ago
Size: 1,227 bytes
 

Contents

Class file image Download
class Zoomer { constructor() { this.minZoom = this.maxZoom = 1; } setup({ imageSize, previewSize, exportZoom, maxZoom, minZoom, smallImage }) { const widthRatio = previewSize.width / imageSize.width; const heightRatio = previewSize.height / imageSize.height; if (minZoom === 'fit') { this.minZoom = Math.min(widthRatio, heightRatio); } else { this.minZoom = Math.max(widthRatio, heightRatio); } if (smallImage === 'allow') { this.minZoom = Math.min(this.minZoom, 1); } this.maxZoom = Math.max(this.minZoom, maxZoom / exportZoom); } getZoom(sliderPos) { if (!this.minZoom || !this.maxZoom) { return null; } return sliderPos * (this.maxZoom - this.minZoom) + this.minZoom; } getSliderPos(zoom) { if (!this.minZoom || !this.maxZoom) { return null; } if (this.minZoom === this.maxZoom) { return 0; } else { return (zoom - this.minZoom) / (this.maxZoom - this.minZoom); } } isZoomable() { if (!this.minZoom || !this.maxZoom) { return null; } return this.minZoom !== this.maxZoom; } fixZoom(zoom) { return Math.max(this.minZoom, Math.min(this.maxZoom, zoom)); } } export default Zoomer;