Load page at bottom

scrolling

(Matthew kennedy) #1

Hi

Im a total novice but making a animated website using hype which needs to load at the bottom of the page. users will then scroll up to the top.

how can I do this?

Help very much appreciated!

thanks
matt


Jump to the bottom of the page
#2

Hi Matt!

Put this code in the “On Scene Load” handler of the “Scene inspector”:

window.scrollTo(0, document.body.scrollHeight);


(Matthew kennedy) #3

Legend! Thanks so much,


(Matthew kennedy) #4

another question. do you know how I make the page load centred as well? So at the bottom and centred? at the moment I have to scroll across to the right to centre it.

thanks


#5

Here’s one way (which you could run as a JavaScript Function)

document.body.scrollLeft = (document.body.scrollWidth - document.body.clientWidth) / 2

via http://stackoverflow.com/a/22230738


(Matthew kennedy) #6

Thanks. So it would be this in full as I can’t get it to work?

Ive out that in a script to run on loading but doesn’t work for me…


#7

Here’s a downloadable example which scrolls to the middle of the page as an ‘On Scene Load’ action:

testscroll.hype.zip (15.2 KB)

The document is 2500 pixels wide, and the center calculated by the script is 1,250.


(Matthew kennedy) #8

Great! Thanks! Got it working. lifesaver.