Show next scene - goes back to beginning at end


(Dylan Winn-Brown) #1

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;

#2

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


(Dylan Winn-Brown) #3

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


#4

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


Scrolling to change scene
(Dylan Winn-Brown) #6

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.


(Steven J. Daniels) #7

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


(Dylan Winn-Brown) #8

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?


(Steven J. Daniels) #9

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.


(Steven J. Daniels) #10

HypeSite.hype.zip (11.1 KB)

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


(Alex) #11

Hi @sjdaniels,

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