Skip to main content
MushroomInternet
Known Participant
March 9, 2017
Question

Smooth Scroll to Link with Anchor

  • March 9, 2017
  • 1 reply
  • 1049 views

Hi,

I having the following code working on a HTML5 canvas animation:

stage.enableMouseOver(25);

this.movieclip.cursor = "pointer";

this.movieclip.addEventListener("click", ScrollToAnchor);

function ScrollToAnchor() {

  window.open("http://websitedomain.com#anchorname", "_self");

}

I would like to set up the page to smoothly scroll down to the anchor on the current page when a movieclip is clicked on at the top of the page. Is this possible? If so, please can someone point me in the right direction?

Kind regards,

Peter

This topic has been closed for replies.

1 reply

Legend
March 9, 2017

This is not an Animate question, it's a general HTML/JavaScript question.

Pasting the title of this thread into Google yields many possible solutions.

MushroomInternet
Known Participant
March 9, 2017

Hi ClayUUID,

I have tried various Javascript code snippets to make scrolling to an anchor smooth but because the hyperlink snippet I'm using, as shown above, is within a HTML5 canvas it doesn't pick it up which is why I am looking for other suggestions.

Kind regards,

Peter

Colin Holgate
Inspiring
March 9, 2017

Is the canvas tall enough that it includes the initial button and the content of the anchor point? Is the whole experience all that exists in the window? Do you want the user to be able to use the window scroll bars as another way to get to the anchor point?