Skip to content

Commit 4982c27

Browse files
authored
Merge pull request #12 from thisissoon/fix/on-changes
fix(image loader): clear src and srcset on changes and pre load image
2 parents 07fd2a8 + 7c10efd commit 4982c27

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ script:
2424
- export CHROME_BIN=chromium-browser
2525
- xvfb-run -a npm run test -- --no-progress --single-run --code-coverage --browser=ChromeNoSandbox
2626
- xvfb-run -a npm run e2e -- --no-progress
27+
- npm run coverage

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,4 +218,10 @@ describe('ImageLoaderComponent', () => {
218218
component.ngOnChanges();
219219
expect(spy).toHaveBeenCalled();
220220
});
221+
222+
it('should preload image on changes', () => {
223+
const spy = spyOn(component, 'preloadImage');
224+
component.ngOnChanges();
225+
expect(spy).toHaveBeenCalled();
226+
});
221227
});

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,9 @@ export class ImageLoaderComponent implements OnInit, AfterViewInit, OnDestroy, O
340340
* @memberof ImageLoaderComponent
341341
*/
342342
public ngOnChanges(): void {
343+
this.src = '';
344+
this.srcset = '';
343345
this.setPlaceholder();
346+
this.preloadImage();
344347
}
345348
}

0 commit comments

Comments
 (0)