ngCropper icon indicating copy to clipboard operation
ngCropper copied to clipboard

Listen to events from cropper

Open stianjensen opened this issue 9 years ago • 3 comments

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.

stianjensen avatar Aug 03 '15 08:08 stianjensen

A good practice is to $emit events on $rootScope. There is no $emitting 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.

koorgoo avatar Aug 03 '15 08:08 koorgoo

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!

nachoargentina avatar Sep 16 '15 19:09 nachoargentina

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)

stianjensen avatar Sep 17 '15 08:09 stianjensen