Return scroll position in Vanilla js

(function (window, document) { "use strict"; var Module = function () { return { init: function () { window.onscroll=function(){changeMenu()}; function changeMenu() { var scrollBarPosition = window.pageYOffset | document.body.scrollTop; console.log(scrollBarPosition); } } }; }; (function () { var module = new Module(); module.init(); })(); }(window, document));
Simple module in order to work with the scroll position. All in Vanilla JS. No jQuery!

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.