Scroll to specific element in horizontal scroll bar


#1

I have a footer with multiple divs that can be scrolled horizontally. For horizontal scrolling I’ve used ion-scroll. Now if I click on any of these div then all the divs should get scrolled automatically so as to bring the clicked div to the center position of the footer view.

I tried scrollTo and scrollIntoView but these didn’t work. I need the help to get this implementation done.


#2

Hi, can you please show me your source code? (view, controller)


#3
<ion-footer>
    <ion-toolbar>
        <ion-scroll direction="x" scrollX="true" class="wide-as-needed" id="test" overflow-scroll="false">
            <div [attr.id]="'polygon-' + i" *ngFor="let item of myList; let i=index" (click)="OnDivClick(item)" class="PolygonDiv">
                <polygon [summaryList]="item"></polygon>
            </div>
        </ion-scroll>
    </ion-toolbar>
</ion-footer>

Here I’m looping over a list to create multiple div which contain the custom component. On click on any of these divs I want that div to be scrolled automatically to the center of the footer.


#4

have you found the solution?