@@ -3,7 +3,9 @@ const CanvasSelection = require('./canvasSelection');
33
44class PhotoCut {
55
6- constructor ( canvas ) {
6+ constructor ( canvas , { maxImageSize} = { } ) {
7+ this . maxImageSize = maxImageSize || 200 ;
8+
79 this . canvas = canvas ;
810
911 this . canvas . onmousedown = event => this . onMouseDown ( event ) ;
@@ -28,12 +30,11 @@ class PhotoCut {
2830
2931 setImage ( img ) {
3032 // fit into document & 400px
31- var maxImageSize = Math . min ( document . documentElement . clientHeight , document . documentElement . clientWidth , 300 ) ;
3233
3334 this . img = img ;
3435
3536 // fit to canvas
36- this . scale = Math . min ( maxImageSize / img . width , maxImageSize / img . height ) ;
37+ this . scale = Math . min ( this . maxImageSize / img . width , this . maxImageSize / img . height ) ;
3738
3839 this . fullImageCanvas = document . createElement ( 'canvas' ) ;
3940 this . fullImageCtx = this . fullImageCanvas . getContext ( '2d' ) ;
@@ -125,7 +126,6 @@ class PhotoCut {
125126 onMouseMove ( event ) {
126127 // coords may be anywhere in the document
127128
128- console . log ( "HERE!!!" , event . clientX ) ;
129129 // recalculate relative to canvas image edge
130130 var coords = this . getEventCoordsRelativeCanvasImage ( event ) ;
131131
@@ -135,9 +135,6 @@ class PhotoCut {
135135 if ( coords . y < 0 ) coords . y = 0 ;
136136 if ( coords . y > this . height ) coords . y = this . height ;
137137
138- console . log ( coords ) ;
139-
140- console . log ( this . state ) ;
141138 switch ( this . state ) {
142139 case false :
143140 this . showCursorAtCoords ( coords ) ;
@@ -176,8 +173,6 @@ class PhotoCut {
176173 coords . x > center . x && coords . y < center . y ? 'ne' :
177174 'se' ;
178175
179- console . log ( direction ) ;
180-
181176 switch ( direction ) {
182177 case 'nw' :
183178 this . selectionStartCoords = {
@@ -209,7 +204,6 @@ class PhotoCut {
209204 }
210205
211206 moveSelection ( coords ) {
212- // console.log("moveSelection");
213207 var x = Math . min ( coords . x - this . mouseDownShift . x , this . width - this . selection . size ) ;
214208 var y = Math . min ( coords . y - this . mouseDownShift . y , this . height - this . selection . size ) ;
215209 if ( x < 0 ) x = 0 ;
@@ -279,7 +273,6 @@ class PhotoCut {
279273 }
280274
281275 onMouseUp ( event ) {
282- //console.log(event.type, event.clientX, event.clientY);
283276 if ( ! this . state ) return ;
284277 this . state = false ;
285278
0 commit comments