10 examples of 'automatic scrolling div' in JavaScript

Every line of 'automatic scrolling 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
208function smoothScrolling() {
209 //Special case for chat
210 if ($(".active").attr('id') === "chat") {
211 smoothScrollBottom();
212 }
213}
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

202startScrolling() {
203 let i = 0;
204 const tick = () => {
205 const {scaleX, scaleY, container} = this;
206 const {strengthMultiplier, onScrollChange} = this.props;
207
208 // stop scrolling if there's nothing to do
209 if (strengthMultiplier === 0 || scaleX + scaleY === 0) {
210 this.stopScrolling();
211 return;
212 }
213
214 // there's a bug in safari where it seems like we can't get
215 // mousemove events from a container that also emits a scroll
216 // event that same frame. So we double the strengthMultiplier and only adjust
217 // the scroll position at 30fps
218 if (i++ % 2) {
219 const {
220 scrollLeft,
221 scrollTop,
222 scrollWidth,
223 scrollHeight,
224 clientWidth,
225 clientHeight
226 } = container;
227
228 const newLeft = scaleX ? container.scrollLeft = intBetween(
229 0,
230 scrollWidth - clientWidth,
231 scrollLeft + (scaleX * strengthMultiplier)
232 ) : scrollLeft;
233
234 const newTop = scaleY ? container.scrollTop = intBetween(
235 0,
236 scrollHeight - clientHeight,
237 scrollTop + (scaleY * strengthMultiplier)
238 ) : scrollTop;
239
240 onScrollChange(newLeft, newTop);
241 }
242 this.frame = raf(tick);
243 };
244
245 tick();
246}
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}
37preventScrolling () {
38 if (this.locked === true) {
39 return
40 }
41 lockingCounter = lockingCounter + 1
42 this.locked = true
43
44 // only lock the first time the component is mounted.
45 if (lockingCounter === 1) {
46 const body = document.getElementsByTagName('body')[0]
47 originalBodyOverflow = body.style.overflow
48 body.style.overflow = 'hidden'
49 }
50}
48allowScrolling() {
49 if (this.locked === true) {
50 lockingCounter = lockingCounter - 1;
51 this.locked = false;
52 }
53
54 if (lockingCounter === 0 && originalBodyOverflow !== null) {
55 const body = document.getElementsByTagName('body')[0];
56 body.style.overflow = originalBodyOverflow || '';
57 originalBodyOverflow = null;
58 }
59}
21function scrollToBottomOfDiv($div) {
22 var scrollHeight = $div[0].scrollHeight;
23 $div.scrollTop(scrollHeight);
24}
194function scrollContent(y, isWheel, isJump)
195{
196 //console.log('scrolling');
197 var delta = y;
198
199 var fromTop = parseInt($(me).attr('data-fromtop'));
200 if(!fromTop){
201 fromTop = 0;
202 }
203
204 if (isWheel)
205 {
206 // move bar with mouse wheel
207
208
209 delta = parseInt(fromTop) + y * wheelStep / 100 * me.outerHeight();
210
211 // move bar, make sure it doesn't go out
212 // var maxTop = me.outerHeight() - bar.outerHeight();
213 // delta = Math.min(Math.max(delta, 0), maxTop);
214
215 // scroll the scrollbar
216 // bar.css({ top: delta + 'px' });
217 }
218
219 //percentScroll = parseInt(fromTop) / me.outerHeight();
220 //delta = percentScroll * (me[0].scrollHeight - me.outerHeight());
221
222 if (isJump){
223 delta = y;
224 var offsetTop = delta / me[0].scrollHeight * me.outerHeight();
225 }
226
227 if(delta < 0){
228 delta = 0;
229 }
230 $(me).attr('data-fromtop',delta)
231
232 // scroll content
233 me.scrollTop(delta);
234
235 // ensure bar is visible
236 //showBar();
237
238 // trigger hide when scroll is stopped
239 //hideBar();
240}
35function scrollDown(){
36 var psconsole = $('#G2_output');
37 psconsole.scrollTop(
38 psconsole[0].scrollHeight - psconsole.height()
39 );
40}
74function scrollToBottom(div_id) {
75 $("#"+div_id).animate({scrollTop: $("#"+div_id)[0].scrollHeight});
76}
36function scroll_to(delta) {
37
38 if (delta < 0 ) {
39
40 delta = -scrollinc;
41 } else {
42
43 delta = scrollinc;
44 }
45
46 delta = delta * deltaKoef;
47
48 var listWidth = scroller.find('.dslca-section-scroller-content').width();
49 var contentWidth = scroller.width();
50
51 if ( listWidth <= contentWidth ) return false;
52
53 var scrollMax = listWidth - contentWidth + 10;
54
55 delta = parseInt(scrollInner.style.left || 0) - delta;
56 delta = delta >= 0 ? 0 : delta;
57 delta = delta <= -scrollMax ? -scrollMax : delta;
58
59 scrollInner.style.left = delta + 'px';
60}

Related snippets