ngCropper
ngCropper copied to clipboard
Listen to events from cropper
Is it possible to listen to the events from the cropper, like 'built.cropper' etc.?
I tried looking at the new proxy feature, but it only seems to work for method calling, not events.
A good practice is to $emit
events on $rootScope
. There is no $emit
ting in ngCropper yet.
The scenario to think about is when there are several croppers on the page. Need to know how to identify which cropper instance triggered the event.
Hi stianjensen! One thing that I did to be able to run things after the "built.cropper" event is emited, is defining a 'built' function inside the options object. For example:
$scope.options = {
maximize: true,
aspectRatio: 1/1,
built: function() {
$scope.determineAspectRatio(vm.fileTypeTitle);
};
}
This way you can define whatever function you want to run for each specific instance of a cropper. Hope that helps you in any way!
Thanks, @nachoargentina
I see that the cropper plugin has made some changes in v11.0 related to events:
Convert "crop" option to "crop" event
So to support the next version of cropper, some way of listening to events would be required.
(https://github.com/fengyuanchen/cropper/blob/master/CHANGELOG.md#0110-aug-10-2015)