10 examples of 'enable scroll in div' in JavaScript

Every line of 'enable scroll in div' 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
105function bodyScrollEnable(enable) {
106 const body = zuix.$(document.body);
107 if (enable === false) body.addClass('noscroll');
108 else body.removeClass('noscroll');
109}
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

172function enableScroll(ele) {
173 if (ele && ele.addEventListener) {
174 ele.addEventListener('touchstart', function () {
175 if (ele.scrollTop == 0) {
176 ele.scrollTop = 1;
177 }
178
179 });
180
181 ele.addEventListener('touchmove', function (e) {
182 if (ele.scrollTop > 0) {
183 e.stopPropagation();
184 }
185
186 }, false);
187 }
188}
3function scroll () {
4 if (window.location.hash === '') return
5 const anchor = $j('a[href="' + window.location.hash + '"]')
6 if (anchor) $j(window).scrollTop(anchor.offset().top)
7}
37function doScroll() {
38 var scroll = $(window).scrollTop();
39 var windowHeight = $(window).height();
40 var documentHeight = $(document).height();
41
42 var heightLessScroll = (documentHeight - windowHeight) - scroll;
43
44 if (heightLessScroll <= MINIMUM_HEIGHT_FOR_TO_LOAD) {
45 // $('.show-more').trigger('click');
46 }
47}
209scroll(offset=0, line=null) {
210 let start_div = document.getElementById(`input-start-${this.uuid}`)
211 let start_ypos = scroll_position(start_div, offset)
212
213 let end_div = document.getElementById(`input-end-${this.uuid}`)
214 let end_ypos = scroll_position(end_div, offset)
215
216 // TODO: Filter out lines containing whitespace only
217 let delta = (start_ypos - end_ypos) / this.source.split("\n").length
218 let ypos = ((this.mode == 'code') && (line==null)) ? (start_ypos + delta) : start_ypos
219 let line_offset = (line != null) ? (delta*line) : 0
220 window.scroll({top : ypos - line_offset + offset,
221 left : 0, behavior : 'smooth'})
222}
145function scrollUpdate(){
146 try{
147 if(window.topScrollCount > 0 && window.topScrollItem){
148 var newpos = window.topScrollItem.offset().top;
149 if(newpos-window.topScrollPos > 0){
150 window.scrollBy(0, newpos-window.topScrollPos);
151 }
152 window.topScrollPos = newpos;
153 window.topScrollCount--;
154 window.topScrollID = window.setTimeout(scrollUpdate, 200);
155 }
156 }catch(error){
157 window.topScrollCount = 0;
158 window.topScrollItem = null;
159 }
160}
24_addScroll() {
25 if (this._getScrollTop() >= 50) {
26 this.refs.navElement.classList.add('scroll');
27 } else {
28 this.refs.navElement.classList.remove('scroll');
29 }
30}
8function scrollNotVisible($container) {
9 return (getScrollHeight($container) - $container.height() - 150 <= 0);
10}
51function isOverlayTotallyScrolled () {
52 // https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight#Problems_and_solutions
53 return _overlay.scrollHeight - _overlay.scrollTop <= _overlay.clientHeight
54}
85export function lockBodyScroll(self) {
86 let bodyPad = parseInt((self.$body.css('padding-right') || 0), 10),
87 hasScrollbar = self.$body.get(0).scrollHeight > document.documentElement.clientHeight &&
88 'hidden' !== self.$body.css('overflow-y');
89
90 if (hasScrollbar) {
91 self.originalBodyPad = document.body.style.paddingRight || '';
92 self.originalBodyOverflowY = document.body.style.overflowY || '';
93
94 self.$body.css({
95 'padding-right': (bodyPad + self.nativeScrollWidth) + 'px',
96 'overflow-y': 'hidden'
97 });
98
99 triggerEvent('lock-body-scroll', self, self.nativeScrollWidth);
100 }
101}

Related snippets