Show next scene - goes back to beginning at end

Hi There,
I am using a jQuery event to show the next scene when the user scrolls down however when I get to the last scene and the user scrolls down, it goes back to the previous scene. Is there anyway I can stop this from happening?

Thanks

This is my code:
(embedded within hype’s non editable function)

var position = $(window).scrollTop();

$(window).scroll(function() {
    var scroll = $(window).scrollTop();
    if(scroll > position) {
         // scrolling downwards
         hypeDocument.showNextScene(hypeDocument.kSceneTransitionPushBottomToTop, 1.1)    
         } else {
         hypeDocument.showPreviousScene(hypeDocument.kSceneTransitionPushTopToBottom, 1.1)
         }
    position = scroll;
});

return false;

Hi @dwinnbrown Is it possible to upload a zip of the document?

The “non editable function” is a place where you write functions to invoke in your document using the “Run Javascript” action.

I feel this is a script that should be placed in the edit Head HTML section of the document
(Document Inspector Tab 1)

I may be wrong :slight_smile: Javascript is not my strongest ability

Hope this helps!

D

Hi Thanks for your response.

Here is the project file:
HypeSite.hype.zip (24.2 KB)

As you can see, I have loaded the jQuery library in the head html and am running the script on load from the first scene.

I’m sure you’ll work it out :stuck_out_tongue:
Thanks

1 Like

Thanks. I understand what you’ve done now.

What about some kind of check to see what scene you’re on using

“hypeDocument.currentSceneName();”

like

var scene = hypeDocument.currentSceneName();

if (scene == section 3) {

} else {

}

and if you’re on Section 3 then don’t invoke any scrolling.

or something like that. again I’d code it if I knew how :slight_smile:

D

We’re getting there. I managed to prevent all scrolling but I can’t then scroll back up. Now I just have to prevent scrolling downward.

Did this ever get resolved? I would really appreciate getting my hands on a working zip.

I didn’t as ended up custom coding something in HTML…I do have a much better working knowledge of JS now however. Have you tried preventing downward scroll on the last scene?

Honestly, I have not tried yet.

I downloaded the sample and took a quick look. I was very impressed with it’s simplicity.

I have tried several other sources for this feature and there is way to much code and scripts involved in the other solutions.

If I figure it out, I will post it here.

HypeSite.hype.zip (11.1 KB)

Fixed. Change the speed in the Script from 1.00 to 0.5 and it is extremely fluid.

2 Likes

Hi @sjdaniels,

It looks great, but anyway to make the scrolling exactly smooth without animation between scenes please?