mihnsen / ui-carousel

A simple, lightweight module for carousel in your AngularJS app, Inspired from slick carousel.
http://mihnsen.github.io/ui-carousel/
MIT License
77 stars 67 forks source link

Scrolling to Last Slide on Load #23

Closed FIL1994 closed 7 years ago

FIL1994 commented 7 years ago

It always scrolls to the last slide when I load my app. I have autoplay set to false and initial-slide set to 1

<div class="row">
        <div class="small-6 large-centered columns">
            <ui-carousel
                slides="info.item.forecast"
                slides-to-show="3"
                slides-to-scroll="3"
                initial-slide="1"
                dots="true"
                arrows="true"
                autoplay="false"
                speed="600">

                <carousel-item>
                    <div class="card" style="height:200px">
                        <div class="card-divider">
                            {{item.date}}
                        </div>
                        <div class="card-section">
                            <h5>{{item.text}}</h5>
                            <p>
                                High: {{item.high}} <br>
                                Low: {{item.low}}
                            </p>
                        </div>
                    </div>
                </carousel-item>
            </ui-carousel>
        </div>
    </div>
klem231188 commented 7 years ago

Hi, I have the same issue with version 0.1.9.

martinmanzo commented 6 years ago

I'm still having this issue in v0.1.10

Assdi commented 6 years ago

I managed to solve this issue :)

MarwaAbuEssa commented 6 years ago

same here even in version 0.1.10? any solution please

Assdi commented 6 years ago

hi @martinmanzo and @MarwaAbuEssa you can load it correctly by ng-if load it after your data has been loaded otherwise keep ng-if false

e.g

<ui-carousel
                    slides="vm.Recommended"
                    slides-to-show="4"
                    slides-to-scroll="4"
                     infinite=false
                     initialSlide=0
                     on-init=""
                     on-before-change="vm.MoreRecommendedByTags(currentSlide)"
                     ng-if="vm.show"
                    >

when your data (vm.Recommended) is loaded by ajax call then make vm.show = true

MarwaAbuEssa commented 6 years ago

@Assdi thank you so much it worked 👍 😄

Assdi commented 6 years ago

my pleasure @MarwaAbuEssa