Move to top of page when scene changes

scrolling

#1

Hello,

I have some a long page in the first scene - how may i return position to top of page when the scene changes?

Thank you!
Pea


Simple project created with Hype - Postr
(Hans-Gerd Claßen) #2

onsceneunload:

element.scrollTop = 0


#3

Thank you - apologies for my simple question :grin:


#4

shoot does that go in “Trigger Custom Behavior” ? doesn’t seem to be working :expressionless:


#5

Sorry it’s not text I’m trying to scroll its the whole scene - with images and text boxes etc.

Any ideas are very appreciated thank you!


#6

place it in a "Run Javascript… " -> “New Function” on scene unload.

“element” will point to the entire scene.


#7

Great thank you sir!


#8

hmmm am i missing something here ? thank you for your help!


#9

try

document.body.scrollTop = 0;

#10

This also works:

(There are many ways)

window.scrollTo(0, 0);

#11

Ok that did the trick thank you so much!


#12

Is there any way that it can happen smoothly?


#13

Here’s how to smooth that movement: Scroll smoothly to the bottom of the page


#14

This is not working… I past the lines onto the HEAD but it does not change anything. What would be the solution for, when the scene change, the page goes up smoothly instead of staying at the same place?


#15

Here’s an example of that. On Scene load, I have the scroller animate to the top of the scene. You can see it in action by clicking the right box at the bottom of scene 1:
smoothscrolling-SceneTop.zip (64.3 KB)


#17

For a reason or another, it’s not working… Maybe Chrome?

Here’s my website : www.martineaulachance.com

When you click a word it goes to another scene where I animated the title, from there everything’s cool but for the ones more down, when you click I wish the page to go up with the rest. On small screen the new scene stay at the same position as the HOME scene making the transition kind of awkward. Just look at “COMME ÇA” for example.

I’m trying the code you put but it’s not working.


#18

All good I figured out.