mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-03-21 17:27:48 +01:00
updateVars is now called when the image finished loading
This commit is contained in:
parent
338fa5bdb2
commit
8998b84027
1 changed files with 16 additions and 13 deletions
|
@ -16,17 +16,7 @@
|
||||||
cropper = ($ '#profile-picture-cropper')
|
cropper = ($ '#profile-picture-cropper')
|
||||||
preview = ($ '#profile-picture-preview')
|
preview = ($ '#profile-picture-preview')
|
||||||
|
|
||||||
cropper.on 'load', ->
|
updateVars = (data, action) ->
|
||||||
side = if cropper[0].naturalWidth > cropper[0].naturalHeight
|
|
||||||
cropper[0].naturalHeight
|
|
||||||
else
|
|
||||||
cropper[0].naturalWidth
|
|
||||||
|
|
||||||
cropper.guillotine
|
|
||||||
width: side
|
|
||||||
height: side
|
|
||||||
onChange: (data, action) ->
|
|
||||||
console.log data
|
|
||||||
($ '#crop_x').val Math.floor(data.x / data.scale)
|
($ '#crop_x').val Math.floor(data.x / data.scale)
|
||||||
($ '#crop_y').val Math.floor(data.y / data.scale)
|
($ '#crop_y').val Math.floor(data.y / data.scale)
|
||||||
($ '#crop_w').val Math.floor(data.w / data.scale)
|
($ '#crop_w').val Math.floor(data.w / data.scale)
|
||||||
|
@ -39,6 +29,19 @@
|
||||||
# marginLeft: '-' + Math.round(rx * data.x) + 'px'
|
# marginLeft: '-' + Math.round(rx * data.x) + 'px'
|
||||||
# marginTop: '-' + Math.round(ry * data.y) + 'px'
|
# marginTop: '-' + Math.round(ry * data.y) + 'px'
|
||||||
|
|
||||||
|
cropper.on 'load', ->
|
||||||
|
side = if cropper[0].naturalWidth > cropper[0].naturalHeight
|
||||||
|
cropper[0].naturalHeight
|
||||||
|
else
|
||||||
|
cropper[0].naturalWidth
|
||||||
|
|
||||||
|
cropper.guillotine
|
||||||
|
width: side
|
||||||
|
height: side
|
||||||
|
onChange: updateVars
|
||||||
|
|
||||||
|
updateVars cropper.guillotine('getData'), 'drag' # just because
|
||||||
|
|
||||||
($ '#cropper-zoom-out').click -> cropper.guillotine 'zoomOut'
|
($ '#cropper-zoom-out').click -> cropper.guillotine 'zoomOut'
|
||||||
($ '#cropper-zoom-in').click -> cropper.guillotine 'zoomIn'
|
($ '#cropper-zoom-in').click -> cropper.guillotine 'zoomIn'
|
||||||
($ '#profile-picture-crop-controls').slideDown()
|
($ '#profile-picture-crop-controls').slideDown()
|
||||||
|
|
Loading…
Reference in a new issue