6 Replies - 482 Views - Last Post: 15 January 2018 - 06:57 AM

#1 [email protected]   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 180
  • Joined: 24-February 15

scrollTop with animation

Posted 15 January 2018 - 03:51 AM

Can someone help me how to add a animation to my scrollTop, now I have a side dot navigation, when you click on a dot you go to that section, what I want is that it will flow smoothly to the other section.

function dotNavigation(element) {		
		var id = element.id.substr(3);
		var s = ($(window).height()-96) * (id-1) 
		$(document).scrollTop(s)
	}


Is This A Good Question/Topic? 0
  • +

Replies To: scrollTop with animation

#2 andrewsw   User is offline

  • never lube your breaks
  • member icon

Reputation: 6823
  • View blog
  • Posts: 28,271
  • Joined: 12-December 12

Re: scrollTop with animation

Posted 15 January 2018 - 04:03 AM

scrollTop can be animated:

Quote

In addition to style properties, some non-style properties such as scrollTop and scrollLeft, as well as custom properties, can be animated.


Moved to jQuery subforum.
Was This Post Helpful? 0
  • +
  • -

#3 [email protected]   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 180
  • Joined: 24-February 15

Re: scrollTop with animation

Posted 15 January 2018 - 05:12 AM

To begin with I'm already going the right way if I start like this?
$(document).scrollTop(s).animate{(

			)}


This post has been edited by [email protected]: 15 January 2018 - 05:15 AM

Was This Post Helpful? 0
  • +
  • -

#4 andrewsw   User is offline

  • never lube your breaks
  • member icon

Reputation: 6823
  • View blog
  • Posts: 28,271
  • Joined: 12-December 12

Re: scrollTop with animation

Posted 15 January 2018 - 05:18 AM

No. Search "jquery animate scrolltop" and you'll quickly find examples. (Guessing is not the way to continue.)
Was This Post Helpful? 0
  • +
  • -

#5 [email protected]   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 180
  • Joined: 24-February 15

Re: scrollTop with animation

Posted 15 January 2018 - 06:34 AM

Well I looked at the jQuery documentation at that's how the example looks like,
I got something like this

function dotNavigation(element) {		
		var id = element.id.substr(3);
		var s = ($(window).height()-96) * (id-1) 
		$(document).animate({
		    scrollTop(s):
		  }, 5000, function() {
		    // Animation complete.
		  });
	}


Was This Post Helpful? 0
  • +
  • -

#6 andrewsw   User is offline

  • never lube your breaks
  • member icon

Reputation: 6823
  • View blog
  • Posts: 28,271
  • Joined: 12-December 12

Re: scrollTop with animation

Posted 15 January 2018 - 06:39 AM

No. It isn't like that, scrollTop(s): nada , it is like this $("html, body").animate({ scrollTop: "300px" }); (using the search term I already provided).

When you come across something new get a few very basic examples working first. Understand the method. Then attempt to apply it to your circumstances.
Was This Post Helpful? 0
  • +
  • -

#7 [email protected]   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 180
  • Joined: 24-February 15

Re: scrollTop with animation

Posted 15 January 2018 - 06:57 AM

I have searched all of that, it doesn't work, and you also removing my variable(S) which I need.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1