airfranceklm / ng-lazy-image

Angular directive for loading responsive image when container (which is preventing reflow) is in viewport.
http://afklm.github.io/ng-lazy-image/
MIT License
351 stars 64 forks source link

Way to keep control on <img> attributes #15

Closed maximelebreton closed 9 years ago

maximelebreton commented 9 years ago

Hi, and thanks for your work!

I can't find a way to keep control on tag attributes with your directive. For example, if i want to add .my-custom-class on the img tag, i cant :

// this output is not possible:
<img class="afkl-lazy-image my-custom-class" />

// because the 'afkl-lazy-image' directive is on the container, and create a new img tag:
<div afkl-lazy-image="{{src}}"></div>

So maybe this could be more flexible?

<div afkl-lazy-container="{{src}}">
  <img afkl-lazy-image class="my-custom-class" />
</div>

Thx!

SquadraCorse commented 9 years ago

Can't you simply style the given class "afkl-lazy-image" which is given by the component? An empty image is not handy browser wise (IE can crash). Maybe className can become an option as well, lets see.

maximelebreton commented 9 years ago

yeah, but the problem is more complex, because it's not just about css. For example if you want to use dave desandro's imagesloaded, to detect when images have been loaded, the plugin check the images classnames.

SquadraCorse commented 9 years ago

Ok, i will add the className as an option. This directive has initial image load event as well, i will activate the trigger on the instance since other people needed it as well.

SquadraCorse commented 9 years ago

Load event for image is in now, also can set your own className