Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OnError and OnSuccess - parameter #28

Open
adalbertpl opened this issue Sep 21, 2016 · 1 comment
Open

OnError and OnSuccess - parameter #28

adalbertpl opened this issue Sep 21, 2016 · 1 comment

Comments

@adalbertpl
Copy link

In documentation in configuration section we have information about onError and onSuccess function which should receive image paramater. But I cannot find description of the parameter in documentation.

  angular.module('your.module', [
    'angularLazyImg'
  ]).config(['lazyImgConfigProvider', function(lazyImgConfigProvider){
    var scrollable = document.querySelector('#scrollable');
    lazyImgConfigProvider.setOptions({
      offset: 100, // how early you want to load image (default = 100)
      errorClass: 'error', // in case of loading image failure what class should be added (default = null)
      successClass: 'success', // in case of loading image success what class should be added (default = null)
      onError: function(image){}, // function fired on loading error
      onSuccess: function(image){}, // function fired on loading success
      container: angular.element(scrollable) // if scrollable container is not $window then provide it here
    });
  }])
@adalbertpl
Copy link
Author

I found that the image parameter doesn't contain any information about an angular scope. I probably cannot get information about DOM element too.
I found additionally that I must myself run $scope.apply() to get information about class change. I attach to events with $rootScope.on('lazyImg:error') and $rootScope.on('lazyImg:success'), in which functions I run $scope.apply().

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

No branches or pull requests

1 participant