@@ -17,7 +17,7 @@ import 'rxjs/add/operator/debounceTime';
1717
1818import * as classes from './shared/classes' ;
1919import * as events from './shared/events' ;
20- import { ImageLoadedEvent , ResponsiveImage , RetinaImage , Size , Breakpoint , Retina } from './shared' ;
20+ import { ImageLoadedEvent , ResponsiveImage , RetinaImage , Size , Breakpoint } from './shared' ;
2121import { WindowRef } from '@thisissoon/angular-inviewport' ;
2222
2323/**
@@ -30,8 +30,8 @@ import { WindowRef } from '@thisissoon/angular-inviewport';
3030 * [image]="image"
3131 * [sizes]="sizes"
3232 * imgClass="foo"
33- * (imagePlaceholderLoaded )="onPlaceholderLoad($event)"
34- * (imageLoaded)="onFullResLoad ($event)"
33+ * (placeholderLoaded )="onPlaceholderLoad($event)"
34+ * (imageLoaded)="onImageLoad ($event)"
3535 * alt="lorem ipsum">
3636 * </sn-image-loader>
3737 * ```
@@ -156,7 +156,7 @@ export class ImageLoaderComponent implements OnInit, AfterViewInit, OnDestroy {
156156 * @memberof ImageLoaderComponent
157157 */
158158 @Output ( )
159- public imagePlaceholderLoaded : EventEmitter < ImageLoadedEvent > = new EventEmitter < ImageLoadedEvent > ( ) ;
159+ public placeholderLoaded : EventEmitter < ImageLoadedEvent > = new EventEmitter < ImageLoadedEvent > ( ) ;
160160 /**
161161 * Output for full res image loaded event.
162162 *
@@ -272,8 +272,9 @@ export class ImageLoaderComponent implements OnInit, AfterViewInit, OnDestroy {
272272 */
273273 public preloadImage ( ) : void {
274274 if ( this . inViewport && this . notLoaded ) {
275- const imageNormal = this . image [ this . size ] [ '@1x' ] ;
276- const imageRetina = this . image [ this . size ] [ '@2x' ] ;
275+ const retinaImg = this . image . images . filter ( retinaImage => retinaImage . size === this . size ) [ 0 ] ;
276+ const imageNormal = retinaImg . x1 ;
277+ const imageRetina = retinaImg . x2 ;
277278 this . supportsSrcSet ?
278279 this . preloadSrcset = `${ imageNormal } 1x, ${ imageRetina } 2x` :
279280 this . preloadSrc = `${ imageNormal } ` ;
@@ -286,8 +287,9 @@ export class ImageLoaderComponent implements OnInit, AfterViewInit, OnDestroy {
286287 * @memberof ImageLoaderComponent
287288 */
288289 public onImagePreload ( ) : void {
289- const imageNormal = this . image [ this . size ] [ '@1x' ] ;
290- const imageRetina = this . image [ this . size ] [ '@2x' ] ;
290+ const retinaImg = this . image . images . filter ( retinaImage => retinaImage . size === this . size ) [ 0 ] ;
291+ const imageNormal = retinaImg . x1 ;
292+ const imageRetina = retinaImg . x2 ;
291293 this . supportsSrcSet ?
292294 this . srcset = `${ imageNormal } 1x, ${ imageRetina } 2x` :
293295 this . src = this . preloadSrc ;
@@ -306,7 +308,7 @@ export class ImageLoaderComponent implements OnInit, AfterViewInit, OnDestroy {
306308 srcset : this . srcset
307309 } ;
308310 if ( ! this . loaded ) {
309- this . imagePlaceholderLoaded . emit ( eventData ) ;
311+ this . placeholderLoaded . emit ( eventData ) ;
310312 return ;
311313 }
312314 this . imageLoaded . emit ( eventData ) ;
0 commit comments