ionic-team / ionic-framework

A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.
https://ionicframework.com
MIT License
50.71k stars 13.51k forks source link

bug: ion-content scrolling methods not working if fired on/near page initialization #19149

Closed reed-lawrence closed 4 years ago

reed-lawrence commented 4 years ago

Dependencies: "@angular/animations": "^8.2.0", "@angular/common": "~8.1.2", "@angular/compiler": "~8.1.2", "@angular/core": "~8.1.2", "@angular/forms": "~8.1.2", "@angular/platform-browser": "~8.1.2", "@angular/platform-browser-dynamic": "~8.1.2", "@angular/router": "~8.1.2",Ï "@ionic-native/core": "^5.0.0", "@ionic-native/date-picker": "^5.12.0", "@ionic-native/document-viewer": "^5.12.0", "@ionic-native/file": "^5.12.0", "@ionic-native/splash-screen": "^5.0.0", "@ionic-native/status-bar": "^5.0.0", "@ionic-native/taptic-engine": "^5.11.0", "@ionic/angular": "^4.7.1", "@ionic/storage": "^2.2.0",

Minimum verifiable example

ngAfterViewInit() {
    const content: HTMLIonContentElement | null = document.querySelector('ion-content');
    if(content){
       content.scrollToPoint(null, 60, 0);
    }
}

The above will not work. However, with a sufficient timeout it will. Is there a reason that it shouldn't scroll immediately after loading? The purpose of this functionality is to hide the search bar at the top until a user pulls down to reveal it.

wslaghekke commented 4 years ago

Hello,

I've tried to reproduce the scenario you're describing, but when i add the ngAfterViewInit like the snipped you added it scrolls normally.

Are you using this in a specific page that you switch to or is it the main page of your app?

liamdebeasi commented 4 years ago

Thanks for the issue. Is this still an issue with the latest version of Ionic Framework? If so, please provide a repo with the code required to reproduce this issue.

ionitron-bot[bot] commented 4 years ago

Thanks for the issue! This issue is being closed due to the lack of a reply. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

Thank you for using Ionic!