Skip to content

Commit 31aee45

Browse files
refactor(image-loader component): Name change, placeholderLoaded and fullResLoaded updated to imageL
BREAKING CHANGE: Variable name changes affect the image-loader component API
1 parent 44b154f commit 31aee45

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

src/app/app.component.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<h1>Scroll down ↓</h1>
2-
<h3>Placeholder image loaded: <span class="placeholder-boolean">{{ placeholderLoaded }}</span></h3>
2+
<h3>Placeholder image loaded: <span class="placeholder-boolean">{{ imagePlaceholderLoaded }}</span></h3>
33
<div class="spacer"></div>
4-
<h3>fullResLoaded event count: <span class="full-res-count">{{ fullResLoadedEventCount }}</span></h3>
4+
<h3>imageLoaded event count: <span class="full-res-count">{{ imageLoadedEventCount }}</span></h3>
55
<sn-image-loader
66
[image]="image"
77
[sizes]="sizes"
88
imgClass="foo"
99
alt="lorem ipsum"
10-
(placeholderLoaded)="onPlaceholderLoad($event)"
11-
(fullResLoaded)="onFullResLoad($event)"
10+
(imagePlaceholderLoaded)="onPlaceholderLoad($event)"
11+
(imageLoaded)="onFullResLoad($event)"
1212
></sn-image-loader>
1313
<div class="spacer"></div>

src/app/app.component.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ export class AppComponent {
3737
* @type {boolean}
3838
* @memberof AppComponent
3939
*/
40-
placeholderLoaded = false;
40+
imagePlaceholderLoaded = false;
4141

4242
/**
4343
* Incremented on each image load event.
4444
*
4545
* @type {number}
4646
* @memberof AppComponent
4747
*/
48-
fullResLoadedEventCount = 0;
48+
imageLoadedEventCount = 0;
4949

5050
/**
5151
* Increments event count on each image loaded event.
@@ -54,7 +54,7 @@ export class AppComponent {
5454
* @memberof AppComponent
5555
*/
5656
public onPlaceholderLoad(imageLoadedEvent: ImageLoadedEvent) {
57-
this.placeholderLoaded = true;
57+
this.imagePlaceholderLoaded = true;
5858
}
5959

6060
/**
@@ -64,6 +64,6 @@ export class AppComponent {
6464
* @memberof AppComponent
6565
*/
6666
public onFullResLoad(imageLoadedEvent: ImageLoadedEvent) {
67-
this.fullResLoadedEventCount++;
67+
this.imageLoadedEventCount++;
6868
}
6969
}

src/app/image-loader/image-loader.component.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ describe('ImageLoaderComponent', () => {
5959
});
6060

6161
it('should set fire placeholder loaded event on image load when loaded is false', () => {
62-
const spy = spyOn(component.placeholderLoaded, 'emit');
62+
const spy = spyOn(component.imagePlaceholderLoaded, 'emit');
6363
component.loaded = false;
6464
const imageElement = fixture.debugElement.query(By.css('img'));
6565
imageElement.triggerEventHandler('load', null);
@@ -156,7 +156,7 @@ describe('ImageLoaderComponent', () => {
156156
});
157157

158158
it('should emit a full res loaded event on image load when loaded is true', () => {
159-
const spy = spyOn(component.fullResLoaded, 'emit');
159+
const spy = spyOn(component.imageLoaded, 'emit');
160160
component.loaded = true;
161161
const imageElement = fixture.debugElement.query(By.css('img'));
162162
imageElement.triggerEventHandler('load', null);

src/app/image-loader/image-loader.component.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ import { ImageLoadedEvent, ResponsiveImage, RetinaImage, Size, Breakpoint, Retin
2929
* [image]="image"
3030
* [sizes]="sizes"
3131
* imgClass="foo"
32-
* (placeholderLoaded)="onPlaceholderLoad($event)"
33-
* (fullResLoaded)="onFullResLoad($event)"
32+
* (imagePlaceholderLoaded)="onPlaceholderLoad($event)"
33+
* (imageLoaded)="onFullResLoad($event)"
3434
* alt="lorem ipsum">
3535
* </sn-image-loader>
3636
* ```
@@ -155,15 +155,15 @@ export class ImageLoaderComponent implements OnInit, AfterViewInit, OnDestroy {
155155
* @memberof ImageLoaderComponent
156156
*/
157157
@Output()
158-
public placeholderLoaded: EventEmitter<ImageLoadedEvent> = new EventEmitter<ImageLoadedEvent>();
158+
public imagePlaceholderLoaded: EventEmitter<ImageLoadedEvent> = new EventEmitter<ImageLoadedEvent>();
159159
/**
160160
* Output for full res image loaded event.
161161
*
162162
* @type {EventEmitter}
163163
* @memberof ImageLoaderComponent
164164
*/
165165
@Output()
166-
public fullResLoaded: EventEmitter<ImageLoadedEvent> = new EventEmitter<ImageLoadedEvent>();
166+
public imageLoaded: EventEmitter<ImageLoadedEvent> = new EventEmitter<ImageLoadedEvent>();
167167
/**
168168
* If true means the image has not been loaded yet and
169169
* the placeholder image is currently displayed
@@ -297,10 +297,10 @@ export class ImageLoaderComponent implements OnInit, AfterViewInit, OnDestroy {
297297
srcset: this.srcset
298298
};
299299
if (!this.loaded) {
300-
this.placeholderLoaded.emit(eventData);
300+
this.imagePlaceholderLoaded.emit(eventData);
301301
return;
302302
}
303-
this.fullResLoaded.emit(eventData);
303+
this.imageLoaded.emit(eventData);
304304
}
305305
/**
306306
* Trigger `ngUnsubscribe` complete on

0 commit comments

Comments
 (0)