Questions tagged [onscroll]

The onscroll is HTML DOM event occurs when an element's scrollbar is being scrolled.

The onscroll is HTML DOM event occurs when an element's scrollbar is being scrolled.

Useful links

334 questions
216
votes
17 answers

Detecting scroll direction

So I am trying to use the JavaScript on scroll to call a function. But I wanted to know if I could detect the direction of the the scroll without using jQuery. If not then are there any workarounds? I was thinking of just putting a 'to top' button…
dwinnbrown
  • 3,789
  • 9
  • 35
  • 60
115
votes
6 answers

javascript scroll event for iPhone/iPad?

I can't seem to capture the scroll event on an iPad. None of these work, what I am doing…
ck_
  • 3,353
  • 5
  • 31
  • 33
42
votes
9 answers

Implementation of onScrollListener to detect the end of scrolling in a ListView

I've a ListView displaying some items. I'd like to perform some operation on the items that are currently displayed in the visible portion of the ListView, depending on how the ListView has been scrolled; thus I thought to implements the…
e-cal
  • 1,661
  • 2
  • 20
  • 28
35
votes
5 answers

onScroll gets called when I set listView.onScrollListener(this), but without any touch

When I set the onScrollListener for my ListView, it calls onScroll. This causes a crash because certain things haven't been initialized. Is this normal? Note: this is happening without me even touching the phone. public class MainActivity1 extends…
Siavash
  • 7,583
  • 13
  • 49
  • 69
18
votes
5 answers

Creating a "sticky" fixed-position item that works on iOS Safari

On iOS safari, one-finger panning doesn’t generate any events until the user stops panning. An onscroll event is only generated when the page stops moving and redrawn. I need a way to detect real time scrolling. Specifically, I want to make a…
woran
  • 1,317
  • 2
  • 16
  • 22
17
votes
1 answer

onScroll event triggers function in Angular4

I am trying to display a paginated list, terefore, when the user scrolls down, I want to trigger a function that loads more items. But I cannot call the function on 'scroll' event. This is how my HTML doc looks like:
Emanuela Colta
  • 2,129
  • 4
  • 18
  • 31
16
votes
2 answers

Javascript OnScroll performance comparison

Update: Similiar question with a very good answer that shows how to use requestAnimationFrame with scroll in a useful way: scroll events: requestAnimationFrame VS requestIdleCallback VS passive event listeners So let's say I want to add some…
user127091
  • 2,071
  • 2
  • 9
  • 16
15
votes
1 answer

How can I move a div on scroll?

I have to move a div when the the user scrolls, but need to use pure JavaScript. position: fixed; will not work with the layout. The div's original position is relative to something else. Is there a simple implementation using an event like…
rubixibuc
  • 7,111
  • 18
  • 59
  • 98
15
votes
6 answers

stop scrollView in the middle of the scroll

I have a scrollview with a lot of content. Now when user do a fling or scroll down, I want the scrollview to stop at a particular view location, where I am doing some animation, and then user can again fling or scroll down. I have tried the…
Deepak Senapati
  • 1,103
  • 2
  • 11
  • 30
12
votes
0 answers

BHO IE 9 Capture OnScroll Event if a site has the meta tag content="IE=9"

I recently noticed that I'm unable to capture the OnSroll events of the "top" window in my BHO if I'm showing a page in IE9 and the page contais the tag: . I capture the scroll by sinking the…
João Augusto
  • 2,285
  • 24
  • 28
12
votes
3 answers

Javascript - execute multiple different window.onscroll

I am facing a little problem here. I have basic knowledge about Javascript and i want to do the following: Right now, when you scroll down, the menu will get smaller. when you go back up, it will return to normal. I call this event with…
Saypontigohe
  • 311
  • 1
  • 2
  • 15
11
votes
6 answers

Why window onscroll event does not work?

I want to execute the window onscroll event, but I don't know why it doesn't work on all browsers(firefox, chrome, etc), and there is no errors occurred. Full code: var elem = document.getElementById('repeat'); var show =…
Lion King
  • 32,851
  • 25
  • 81
  • 143
10
votes
3 answers

How can I make multiple on scroll fixed headers/navbars that stick at the very top of the page?

Does anyone know how to make multiple on scroll fixed headers? I've already checked answers such as this. I want the first header, that's already fixed at the top of the screen, to stop before the second header, and when the first header gets…
MWR
  • 304
  • 1
  • 2
  • 12
9
votes
1 answer

How to make a View follow my finger using onScroll and GestureDetector - Android

I have a RelativeLayout with a TextView in the middle. I've got it to detect onFling, onDown, and onScroll events using SimpleOnGestureListener(). I would like the TextView to follow my finger around the screen (can be just in the x axis), and when…
Sandy
  • 2,572
  • 7
  • 40
  • 61
9
votes
2 answers

What is the difference between window.onscroll and window.addEventListener

I can't find the difference between doing: window.onscroll = () => console.log("scroll") and this: window.addEventListener('scroll', () => console.log("scroll")) except for browser compatibility which both seems to be unsupported in most IE…
Nour
  • 5,252
  • 3
  • 41
  • 66
1
2 3
22 23