Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$ionicScrollDelegate.getScrollPosition().top always return 0 after deploy to device #1931

Closed
jianbo opened this issue Aug 5, 2014 · 8 comments

Comments

@jianbo
Copy link

jianbo commented Aug 5, 2014

I am using v1.0.0-beta.10, I want to detect the scroll position using $ionicScrollDelegate.getScrollPosition().top method.

It returns the correct value when using a chrome browser, but once I deploy to my device, $ionicScrollDelegate.getScrollPosition().top always returns 0.

my code:

  <ion-view hide-back-button="true">
 <ion-content has-bouncing="true" class="has-header has-subheader" id="store-container" on-scroll="onScoll()">
 </ion-content>

.controller('HomeStoresCtrl', function($state, $ionicScrollDelegate, ...
     $scope.onScoll = function() {
         console.log($ionicScrollDelegate.getScrollPosition().top)
    }
@jianbo jianbo closed this as completed Aug 5, 2014
@shfaizanali
Copy link

I am having the same issue. How do you resolve it ?

@Aulie
Copy link

Aulie commented Mar 16, 2015

I experience the same issue, also in the browser using ionic serve.

@Fayozjon
Copy link

Aulie

http://nmr.co.ke/tik

16.03.2015, 19:48, "Aulie" notifications@github.com:I experience the same issue, also in the browser using ionic serve.

—Reply to this email directly or .

@fabicious
Copy link

Same problem here. No solution so far?

@DaDanny
Copy link

DaDanny commented Oct 21, 2015

I experienced the same issue as well, so my workaround was doing this:

document.getElementById(YOUR ELEMENT).getBoundingClientRect().top;

And this let me determine the position of whatever element I wanted. Not exactly the same use case as getScrollPosition, but once I got this working, I was able to re-think how I could do scrolling.

Hope this helps!

@shyamal890
Copy link

shyamal890 commented May 10, 2016

+1 @danbucholtz Can you please open this issue. Facing the same in Ionic 1.2.4

@saguilerao
Copy link

+1 Same one here.... "version": "1.3.1",

@saguilerao
Copy link

saguilerao commented May 24, 2016

My workaround by now is this function.

function getElementOffset(element){
    var de = document.documentElement;
    var box = element.getBoundingClientRect();
    var top = box.top + window.pageYOffset - de.clientTop;
    var left = box.left + window.pageXOffset - de.clientLeft;
    return { top: top, left: left };
}

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants