Skip to content
This repository has been archived by the owner on Sep 26, 2020. It is now read-only.

Images do not load until mouseover of slide #49

Open
jbenhardus opened this issue Feb 20, 2020 · 1 comment
Open

Images do not load until mouseover of slide #49

jbenhardus opened this issue Feb 20, 2020 · 1 comment
Assignees
Labels
bug Something isn't working needs investigation This issue needs further investigation

Comments

@jbenhardus
Copy link

jbenhardus commented Feb 20, 2020

I added the carousel to my angular 8 app, and it works great, except I noticed that the images do not appear until I mouse over a slide. Instead it loads the carousel in the correct proportions with a blank slide, like this:
blank-slide

The rendered html looks like this:
blank-slide-html

Once I mouseover the the slide, the image and other content load and display properly. The code for the carousel I am using is as follows

<mat-carousel
timings="500ms ease-in"
[autoplay]="false"
color="primary"
maxWidth="auto"
[maintainAspectRatio]="false"
[slideHeight]="'500px'"
proportion="25"
slides="5"
[loop]="false"
[hideArrows]="false"
[hideIndicators]="false"
[useKeyboard]="true"
[useMouseWheel]="false"
orientation="ltr"

  <mat-carousel-slide [image]="'assets/images/screenshots/goals.png'" [hideOverlay]="true">
     <div class="slide-caption-container">
        <div class="slide-caption">
           <div class="slide-header">
              Goals
           </div>
           <div class="slide-description">
              Set a long term vision for your organization and track your progress.
           </div>
        </div>
     </div>
  </mat-carousel-slide>
  <mat-carousel-slide [image]="'assets/images/screenshots/rocks.png'" [hideOverlay]="true">
     <div class="slide-caption-container">
        <div class="slide-caption">
           <div class="slide-header">
              Rocks
           </div>
           <div class="slide-description">
              Bridge the gap between where you are and where you need to be. Rocks are targeted,
              90 day initiatives that focus departments towards improving in a specific,
              measureable manner.
           </div>
        </div>
     </div>
  </mat-carousel-slide>

Note: I do have a workaround for this. I discovered that forcing change detection in ngAfterViewInit caused the slides to display correctly. Ideally though, this should not be required.

@gbrlsnchs gbrlsnchs self-assigned this Feb 20, 2020
@gbrlsnchs gbrlsnchs added bug Something isn't working needs investigation This issue needs further investigation labels Feb 20, 2020
@gbrlsnchs gbrlsnchs added this to the Launch stable version milestone Feb 20, 2020
@Wintermute79
Copy link

I had a similar issue. Triggering change detection fixed it for me:

Inject a ChangeDetectorRef in your constructor like so

constructor(
    private cd: ChangeDetectorRef
}

and then detect changes after view is initialized

ngAfterViewInit(): void {
    this.cd.detectChanges();
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working needs investigation This issue needs further investigation
Projects
None yet
Development

No branches or pull requests

3 participants