10 examples of 'animate div on scroll jquery' in JavaScript

Every line of 'animate div on scroll 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.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
44(function animateScroll() {
45 currentTime += increment;
46 const val = easeInOutQuad(currentTime, start, change, speed);
47 window.scroll(0, val);
48 if (currentTime < speed) setTimeout(animateScroll, increment);
49})();
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

70function scrollToDiv(target){
71 if (target != undefined){
72 $('html,body').animate({
73 scrollTop: target.offset().top
74 }, 1000)
75 }
76}
52function animate(element) {
53 var speed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 500;
54 var offset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
55 var start = (0, _safeScrollTop.default)();
56 var target = getElementOffsetTop(element);
57 var change = target - start - offset;
58 var increment = 20;
59 var currentTime = 0;
60
61 (function animateScroll() {
62 currentTime += increment;
63 var val = easeInOutQuad(currentTime, start, change, speed);
64 window.scroll(0, val);
65 if (currentTime < speed) setTimeout(animateScroll, increment);
66 })();
67}
258function scrollAnimation()
259{
260 var percent = (new Date() - startTime) / 1000;
261
262 if(percent > 1) window.scrollTo(0, goalY);
263 else
264 {
265 window.scrollTo(0, Math.round(startY + (goalY - startY) * curve(percent)));
266 setTimeout('scrollAnimation()', 10);
267 }
268}
65function animated_scroll(el, pos){
66 var isWin = el==window;
67 var startpos = isWin?pageYOffset:el.scrollTop; //pageyOffset seems like somethings wrong
68 if(startpos == pos) return;
69 var time = Math.min(1000,2*Math.sqrt(42*Math.abs(pos-startpos)));
70 var fn, target = +new Date + time;
71 ;(fn = function(){
72 var progress = Math.min(1, 1 - ((target - new Date)/time));
73
74 var val = (pos-startpos)*((-Math.cos(progress*Math.PI)/2) + 0.5) + startpos;
75
76 if(isWin) scrollTo(0, val); else{
77 el.scrollTop = val;
78 }
79 if(progress < 1) setTimeout(fn, 0);
80 })()
81}
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}
74function scrollToBottom(div_id) {
75 $("#"+div_id).animate({scrollTop: $("#"+div_id)[0].scrollHeight});
76}
5function scrollTo(el, duration, easingType, scrollOffset) {
6 scrollOffset = scrollOffset == null ? 0 : scrollOffset;
7 var easing = easingType ? ease[easingType] : ease['linear'];
8 var stop = false;
9 var start = Date.now();
10 var html = document.getElementsByTagName('html')[0];
11 var fromY = document.body.scrollTop || html.scrollTop;
12 var toY = fromY + offset(el).top + scrollOffset;
13
14 function animate() {
15 var now = Date.now();
16 if (now - start >= duration) stop = true;
17 var p = (now - start) / duration;
18 var tick = Math.round(fromY + (toY - fromY) * easing(p));
19 document.body.scrollTop = tick;
20 html.scrollTop = tick;
21 if (!stop) raf(animate);
22 }
23
24 animate();
25}
208function smoothScrolling() {
209 //Special case for chat
210 if ($(".active").attr('id') === "chat") {
211 smoothScrollBottom();
212 }
213}
64function scrollTo(id)
65{
66 $('html,body').animate({scrollTop: $("#"+id).offset().top},'fast');
67}

Related snippets