10 examples of 'get current scroll position javascript' in JavaScript

Every line of 'get current scroll position javascript' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
465public getScrollPosition(): IScrollPosition {
466 return this._scrollable.getCurrentScrollPosition();
467}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

34function getCurrentScroll() {
35 return window.pageYOffset || document.documentElement.scrollTop;
36}
60function scrollValue(position) {
61 return document.documentElement[position] || document.body[position];
62}
120scrollTop(value) {
121 if (arguments.length) {
122 this.getElementsCore('body')
123 .forEach(element => element.scrollTop = value);
124
125 return;
126 }
127
128 return this.getElement().scrollTop;
129}
106scrollTop(value) {
107 if (arguments.length) {
108 this.getElementsCore('body')
109 .forEach(element => element.scrollTop = value);
110 }
111
112 return this.getElement().scrollTop;
113}
280getScrollTop() {
281 return (
282 window.pageYOffset ||
283 document.documentElement.scrollTop ||
284 document.body.scrollTop ||
285 0
286 )
287}
54public getCurrentPosition(): number {
55 return document.body.scrollTop / document.body.scrollHeight;
56}
72get scrollTop() {
73 if (!this.content) { return 0; }
74
75 return this.content.scrollTop;
76}
112get _scrollTop() {
113 return this['scroll-top'];
114}
101setScrollPosition (scrollPos) {
102 if (platform.inBrowser) {
103 document.body.scrollTop = scrollPos
104 }
105}

Related snippets