-1

I am new to Angular and I made an app using angular material stepper that has some steps and some steps have longer content and so the page becomes scrollable. So I am looking for a way to detect if a page or its content is bigger than screen height so I could show a "Scroll Down" image or animation. If it is not scrollable, I don't want to show that animation.

I know that on the right a scroll bar appears, but I want to add this anyway. How do I approach resolving this issue?

6
  • Does this answer your question? Angular - Button Scroll to Top Commented Jul 4, 2022 at 8:09
  • check this stackoverflow.com/questions/54605298/… Commented Jul 4, 2022 at 8:12
  • You can create a directive that will hold the element reference and then make some mathematic logic for the scroll bar using the height of your container. does this answer your question? Commented Jul 4, 2022 at 8:16
  • add an intersection observer to the footer (or one other element at the bottom of the page) If it is not intersecting, it means it can be scrolled into view. Commented Jul 4, 2022 at 8:50
  • @PK2995 Yes this is something that I'm looking for but the accepted answer isn't working for me Commented Jul 15, 2022 at 7:28

1 Answer 1

0

You can compare the document scroll height vs the window height.

setInterval(function() {
  console.log(x = document.documentElement.clientHeight);
  console.log(y = document.body.scrollHeight);
  console.log("document has scroll: ", y > x)
}, 1000)
<div style="height: 600px">
 a div... go to full page and scroll will be gone
</div>

Sign up to request clarification or add additional context in comments.

1 Comment

Sorry but this is not what I'm looking for

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.