Skip to content
This repository has been archived by the owner on Oct 3, 2024. It is now read-only.

Listen to events from cropper #15

Open
stianjensen opened this issue Aug 3, 2015 · 3 comments
Open

Listen to events from cropper #15

stianjensen opened this issue Aug 3, 2015 · 3 comments

Comments

@stianjensen
Copy link

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
Copy link
Owner

koorgoo commented Aug 3, 2015

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
Copy link

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
Copy link
Author

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)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants