ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

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

Open Set2005 opened this issue 12 years ago • 8 comments

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)
    }

Set2005 avatar Aug 05 '14 04:08 Set2005

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

shfaizanali avatar Mar 07 '15 17:03 shfaizanali

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

Aulie avatar Mar 16 '15 16:03 Aulie

Aulie

http://nmr.co.ke/tik

16.03.2015, 19:48, "Aulie" [email protected]:I experience the same issue, also in the browser using ionic serve.

—Reply to this email directly or .

Fayozjon avatar Mar 25 '15 01:03 Fayozjon

Same problem here. No solution so far?

fabicious avatar May 08 '15 07:05 fabicious

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!

DaDanny avatar Oct 21 '15 04:10 DaDanny

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

shyamal890 avatar May 10 '16 19:05 shyamal890

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

saguilerao avatar May 24 '16 20:05 saguilerao

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 };
}

saguilerao avatar May 24 '16 21:05 saguilerao