How to move objects with scrolling? 🤔

Thank you so much @MaxZieb!
I tried your code immediately and I can say the transition between the scenes works better, but in my case the tricky moment is that I want to stop users in the end of the first scene where the slider appears. The user must pull the slider all the way and only then will be able to continue to the next scene.

This is my file with your code: Parallax_v4.zip (2.7 МБ)

I also noticed something very positive in your code! It works better than the previous one in that I can interrupt the animation from trigger "Pause Timeline" to trigger "Pause Timeline" if I change direction with the mouse scroll! This is a big improvement for me!
I would prefer it, but then how do I deal with the other problem? Do you have any idea how can I set such a limit on the slider?

1 Like

The code is as said not for a specific solution but you could just add the line

if (sceneNames.indexOf(hypeDocument.currentSceneName()) == 0) return;

when checking if you want to go forward.

This will not forward if on the first scene now:
scrollingWithWheelDontContinueFirstScene.hype.zip (25,8 KB)

Hope that helps.

1 Like

I'm glad @MaxZieb's solution worked out!

It does appear the root of the issue in the older code was a bug; basically the logic was:

  1. if scrolling up AND the timeline is greater than 2 seconds, play in reverse
  2. otherwise play forward

The problem in the second clause is that it doesn't actually check the direction of the scroll :slight_smile:, so if you are less than two seconds and scroll up it would still play forward.

In the wheel2 function the final else should instead be:

} else if (event.detail > 0) {

And in wheel it should be:

} else if (event.wheelDeltaY < 0) {

The second problem has more to do with integration into making this a multi-scene effort. I assume the "2 seconds" bit was about showing some initial animation. But in the code I sent you there wouldn't be a way to get back to the top if you go beyond this marker since the play in reverse will only work when the timeline is greater than 2 seconds and the check for seeing if you are at the 0 time.

Let me know if you'd like ideas on fixing this, but it sounds like you aren't going forward with the original code :slight_smile:.

2 Likes

@MaxZieb, I didn't understand how the magic works but what when I want several scenes with sliders and not only the first one? The places of my sliders will be random.

scrollingWithWheelDontContinueSeveralScenes.zip (39.6 КБ)

@jonathan, it seems your solution works fine right now! Thank you!

But I'm still wondering if it can work with @MaxZieb's code, because it will save me from making the "dummy" scene!

Also I found a big issue with on mobile. When you reach the end of the scene and you swipe up this automatically send you the to very beginning of the current scene instead of doing nothing. This happens maybe because I set "On swipe Up" to Continue Timeline:

Screen Shot 2020-09-03 at 9.39.27

Thank you guys!

This has some improvements.

  • It doesn't scroll to next scene if (stop) is in the scene name (configurable)
  • You can configure the default transition time
  • It prevents wheel inputs while being in regular transitions.

scrollingWithWheelDontContinueCondition.hype.zip (36,3 KB)

3 Likes

@MaxZieb, I just don't know how to thank you! This solution is incredible simple and genius! It works!!! I'm very very grateful! :astonished:

Can I ask you about the swipe issue on mobile? Maybe I should use another function instead of "Continue Timeline" trigger? Can I use the same code and just replace "wheel" with "swipe" or something?

This version allows swipe… it also just requires the init on the first scene now:
scrollingWithWheelConditionSwipe.hype.zip (38,8 KB)

This is the same but has the init code in head HTML:
scrollingWithWheelConditionSwipeHead.hype.zip (39,0 KB)

Functionality is the same on both, if you don't understand or care about the differences go with the version without the head HTML. Head HTML has some advantages but also some pitfalls when using it in WordPress setups etc.

3 Likes

Thank you @MaxZieb!
I'm feeling completely satisfied!

Thank you all guys!

1 Like

You have to set the duration of the scene otherwise the video will set the duration for you. It's the little blue line above the timeline.

① This little blue line indicates the length of a scene. It is automatically calculated by the last action key frame or the last animation ending
② Make sure to set the scene length with an user-defined value because else the video length sets the scene duration for you in its automatic mode

2 Likes

Thank you, Max! I'll try as soon as possible!

Max, I think there is a bug in Hype!
When I set the duration to be the minimum (1 sec) and save the document, after relaunch I found the duration back to the original length! Maybe thats why every time I tried to set the duration the scroll didn't worked!

Here you can see: https://we.tl/t-29NwmSSezY

Is this a bug or I don't understand something?

Seams to be a bug… the length is always reset to the video length.
One thing I can think of would be … sticking the video in a symbol.

① Make a symbol from the video
② remove any symbol actions

③ Add a start timeline on symbol load

Hope that helps

1 Like

Yes, now the duration stays of 1 sec but still I need to scroll up three or more times to go back when I'm on video scene. Moving forward works better. In 90% of cases when I scroll down it works from the first try!

Thank you, Max!

Thanks - this is in fact a bug. The correct behavior for the duration field is that it cannot get smaller than the last animation. This should include the duration of a video, but it does not. Our notes show that adding another animation will reset it, as would closing and reopening the document. We have this filed. Thanks!