class SAPO.Component.ImageCropper
 requires SAPO.Dom.Event
 requires SAPO.Dom.Element
 requires SAPO.Dom.Css

 TODO: distance to option, border read in CSS (check TODOs inline)
 
Defined in Component/ImageCropper/0.1/lib.js

Constructor Summary
ImageCropper (String|DomElement img, Object options)

Function Summary
changeAspectRatio (float ar)
alters the aspect ratio constraint, setting the biggest possible window starting on (0,0)
destroys component UI
setWindow (Number x, Number y, Number w, Number h)
sets the cropping window

Constructor Details

constructor ImageCropper

ImageCropper(String|DomElement img, Object options)
Parameters:
img - img element which will be used for cropping
options
  • [ String[] trackInputs ] - list of 4 input ids to track for changes
  • [ Number maxDist ] - distance to crop border which activates cropping operation
  • [ Number aspectRatio ] - if passed, ratio (w/h) is fixed. default off.
  • [ Number viewScale ] - scale to apply to the widget
  • [ Number minCropSide ] - minimum allowed crop side (width or height). defaults to 32 pixels.
  • [ Number[] maxUnscaledSize ] - pass on this option if you have limited page space (while image doesn't fit in rect, scales down 2x)
  • [ Function(x, y, w, h) onWindowChanged ] - callback that passes on the updated window params everytime they change

Function Details

function changeAspectRatio

changeAspectRatio(float ar)
alters the aspect ratio constraint, setting the biggest possible window starting on (0,0)
Parameters:
ar

function destroy

destroy()
destroys component UI

function setWindow

setWindow(Number x, Number y, Number w, Number h)
sets the cropping window
Parameters:
x start of cropping window (left coord)
y start of cropping window (top coord)
w width of cropping window
h height of cropping window