Skip to content
This repository has been archived by the owner on Nov 25, 2022. It is now read-only.

Cannot read property 'scrollTop' of undefined when using jQuery #11

Open
bglogic opened this issue Apr 9, 2015 · 5 comments
Open

Cannot read property 'scrollTop' of undefined when using jQuery #11

bglogic opened this issue Apr 9, 2015 · 5 comments

Comments

@bglogic
Copy link

bglogic commented Apr 9, 2015

When using jQuery in a project the following line gives the error in the title:
var scrollTop = e.detail.scrollTop;

It has to be replaced with this line to work:
var scrollTop = e.originalEvent.detail.scrollTop;

An if statement has to be used to detect if jQuery is used but I don't know how to do that.

Update
This fix seems to work in iOS but not in Android. This can be seen in both chrome developer tools device mode and the actual devices.

@bglogic bglogic changed the title Cannot read property 'scrollTop' of undefined [jQuery] Cannot read property 'scrollTop' of undefined Apr 9, 2015
@bglogic bglogic changed the title [jQuery] Cannot read property 'scrollTop' of undefined Cannot read property 'scrollTop' of undefined when using jQuery Apr 25, 2015
@yohokuno
Copy link

I have the same issue.

@anuragranjan242
Copy link

its work for me---
document.getElementById('scrollT').onscroll = function(evt) {
if (navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/BlackBerry/i) || navigator.userAgent.match(/Windows Phone/i)) {
console.log('app', evt.target.scrollTop);
if (evt.target.scrollTop > 250) {
$ionicNavBarDelegate.title($scope.food.name);
} else {
$ionicNavBarDelegate.title('');
}
} else {
console.log('web', evt.detail.scrollTop);
if (evt.detail.scrollTop > 260) {
$ionicNavBarDelegate.title($scope.food.name);
} else {
$ionicNavBarDelegate.title('');
}
}

        }

@mihaisavezi
Copy link

Hi guys,

I landed here by looking for a way to hide my sub-header on scroll and found this codepen:

http://codepen.io/anon/pen/rOXLzY

It didn't work for me by failing at a similar line to where you guys are having the problem:

if(e.detail.scrollTop < $rootScope.pixelLimit) { $rootScope.slideHeader = false;

I wasn't using jQuery though. It worked for me by changing e.detail.scrollTop with e.target.scrollTop now I'm not getting errors.

@supgeek-rod
Copy link

I have the same issue.

@m1012290
Copy link

This error is because of disabling jsscrolling -
$ionicConfigProvider.scrolling.jsScrolling(false);

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

6 participants