koorgoo / ngCropper

AngularJS wrapper for https://github.com/fengyuanchen/cropper
107 stars 72 forks source link

Listen to events from cropper #15

Open stianjensen opened 9 years ago

stianjensen commented 9 years ago

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.

koorgoo commented 9 years ago

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.

nachoargentina commented 8 years ago

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!

stianjensen commented 8 years ago

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)