Every line of 'scroll to element jquery' 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.
88 function scrollHightlight(element) { 89 var $headers = $(element); 90 91 $(window).scroll(function() { 92 var currentScroll = $(this).scrollTop(); 93 var $currentSection; 94 95 $headers.each(function() { 96 var divPosition = $(this).offset().top - 100; 97 if (divPosition - 1 < currentScroll) { 98 $currentSection = $(this); 99 } 100 if ($currentSection && $currentSection.attr('id')) { 101 var id = $currentSection.attr('id'); 102 } 103 104 $('.sidebar-header-2 a').removeClass('active'); 105 id = "'#" + id + "'"; 106 $('.sidebar-header-2 [href=' + id + ']').addClass('active'); 107 }); 108 }); 109 }
3 function 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 }
97 function scrollElement(element: Element, x: number, y: number) { 98 element.scrollLeft = x; 99 element.scrollTop = y; 100 }
18 function scrollParent($el){ 19 var $scroller = $(window); 20 $el.parents().each(function(i, el){ 21 var $el = $(el); 22 if(['auto', 'scroll'].indexOf($el.css('overflow-y')) > -1){ 23 $scroller = $el; 24 return false; 25 } 26 }); 27 28 return $scroller; 29 }
36 function 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 }
251 function scrollToElement(element) { 252 var currScrollY = null; 253 254 var targetScrollY = 0; 255 var op = element; 256 while (op.offsetParent !== null) { 257 targetScrollY += op.offsetTop; 258 op = op.offsetParent; 259 } 260 261 if (window.pageYOffset !== undefined) { 262 currScrollY = window.pageYOffset; 263 } else if (document.documentElement.scrollTop !== undefined) { 264 currScrollY = document.documentElement.scrollTop; 265 } else if (document.body.scrollTop !== undefined) { 266 currScrollY = document.body.scrollTop; 267 } 268 269 270 if (currScrollY !== targetScrollY) { 271 var maxTick = 1; 272 var interval = setInterval(function() { 273 var sign = 1; 274 if (currScrollY > targetScrollY) { 275 sign = -1; 276 } 277 var scrollBy = sign * Math.ceil(Math.max(1, Math.min(maxTick, (Math.abs(targetScrollY - currScrollY) * 0.25)))); 278 currScrollY += scrollBy; 279 window.scrollBy(0, scrollBy); 280 281 if (currScrollY === targetScrollY) { 282 clearInterval(interval); 283 } else { 284 maxTick = Math.min(maxTick + 0.5, Math.abs(targetScrollY - currScrollY)); 285 } 286 }, 20); 287 }//end if 288 }
5 function scrollIntoView (element) { 6 if (element){ 7 const scrollY = element.getBoundingClientRect().top + (window.scrollY || window.pageYOffset); 8 window.scroll({ top: scrollY, left: 0, behavior: 'smooth' }); 9 } 10 }
2280 function _scrollParentToElement (parent, element) { 2281 parent.scrollTop = element.offsetTop - parent.offsetTop; 2282 }
73 function scrollToElement(element) { 74 75 if (isElementInView(element)) { 76 return; 77 } 78 79 try { 80 element.scrollIntoView({ 81 behavior: "smooth" 82 }); 83 } 84 catch (error) { 85 console.error(error); 86 } 87 }
222 public async scrollTo(direction: Direction, elementToSearch, yOffset: number = 0, xOffset: number = 0) { 223 //await this._driver.execute("mobile: scroll", [{direction: 'up'}]) 224 //await this._driver.execute('mobile: scroll', { direction: direction === 0 ? "down" : "up", element: this._element.ELEMENT }); 225 let el: UIElement = null; 226 let retries = 7; 227 while (el === null && retries >= 0) { 228 try { 229 el = await elementToSearch(); 230 if (!el || el === null || !(await el.isDisplayed())) { 231 el = null; 232 await this.scroll(direction, yOffset, xOffset); 233 } 234 } catch (error) { 235 await this.scroll(direction, yOffset, xOffset); 236 } 237 238 retries--; 239 } 240 return el; 241 }