Jump to content
Search Community

ScrollTrigger.normalizeScroll() is not a function

WaReZoR test
Moderator Tag

Go to solution Solved by WaReZoR,

Recommended Posts

ScrollTrigger.normalizeScroll(true);
const mainSliderSection = gsap.timeline({
			scrollTrigger: {
			trigger: '#sc1',
			scrub: true,
			pin: true,
			start: "bottom bottom",
			end: '+=100%'
			}
		})
		mainSliderSection
			.addLabel('sc1')
			.fromTo('.pagination-main', { autoAlpha: 1 }, { autoAlpha: 0 })
			.to('#sc1', { autoAlpha: 0 }, '<+=0.2')

Hi all, sorry in advance for asking a probably stupid question. I am a newbie. Faced with a problem in iOS browsers and in general with the work of gsap on mobile devices, after studying the documentation found ScrollTrigger.normalizeScroll();
But how to use it or make it work, I did not understand. With the above code I get the following message:

Quote

Uncaught TypeError: gsap_ScrollTrigger_js__WEBPACK_IMPORTED_MODULE_3__.ScrollTrigger.normalizeScroll is not a function

 

Link to comment
Share on other sites

Unfortunately the page contains a very large amount of media, without a premium subscription will not be able to lay it out, at the moment in our country at war and spend money on such things has become too expensive, I can only provide a link to the landing page. https://shl.mediacreator.agency/test
The latest version is used, which is installed from the npm

link without media, 

See the Pen KKZGgeR by warezor-ua (@warezor-ua) on CodePen

Link to comment
Share on other sites

Thank you for your feedback, here are the results of the console log outputimage.png.5f10521d069052b1efe842c90b1889fb.png

 

In the example that I posted this error does not exist, because I commented out the string, and in the link to the working test page, I wanted to show the problem I encountered on mobile devices

Link to comment
Share on other sites

The error is gone, but the result is not visible, the bug with the moving address bar in the browsers remained.
Maybe in addition to ScrollTrigger.normalizeScroll(true); I need to do something else?

image.thumb.png.17808aaf4626a55c5c514f6e44c70e99.png

telegram-cloud-photo-size-2-5386340287623838374-y.thumb.jpg.036a7a4af1c715ec153ba137115e79fb.jpg

 

The page consists of full-screen blocks, when you crawl back and forth, it leaves an empty space for a while, it breaks all perception of the effects and the page as a whole on mobile devices and why it lags very much?

Link to comment
Share on other sites

I'm not sure I understand your question, but if you want to have ScrollTrigger avoid doing a refresh() (to recalculate the start/end values when the viewport resizes from the address bar showing/hiding), you could:

ScrollTrigger.config({ ignoreMobileResize: true });

And you don't need to .normalizeScroll(true) if you don't like that effect. 

Link to comment
Share on other sites

I added a line with the parameter above, after the address bar showing/hiding, the size of the content has stopped changing, but a white piece of page at the bottom remains, it looks terrible.
I think that without ignoreMobileResize: true the browser is trying to do everything right, but since everything is slow, the resizing is not so fast that the white bar from the address bar quickly disappears.
About the lags on the site when the animation is on, it happens without normalizeScroll, the animation itself is not complicated, but when you turn it on there is something incomprehensible to me, which the phone can not cope.

 

If I could show you a video from my phone of what's going on, maybe you would understand what the problem is.

Link to comment
Share on other sites

I disabled normalizeScroll, the lag is almost gone, but the behavior of the 100vh block is still confusing to me.

When scrolling, the block is partially scrolled up as much as the address bar takes up space before it disappears, then only the pin is triggered.

Is there any way to set the height so that it ignores the address bar and always the content is under it?

Link to comment
Share on other sites

Yeah, it's very difficult to troubleshoot blind. 

 

By default, ScrollTrigger will WAIT to .refresh() until scrolling stops because otherwise, the .refresh() will stop the momentum scroll. You can force a refresh in a "resize" event handler on the window, of course, to make it happen right away. 

 

There's a fundamental logic issue at play: if you want your triggers to adjust to have the correct (new) start/end positions at the new viewport size, that requires a .refresh() call (which is somewhat expensive because all the optimizations are done up-front so while scrolling you get maximum performance). If you don't want things to adjust and you set ignoreMobileResize: true, then of course you don't get the shift that'd be caused by refreshing/correcting positions but you also don't get the accurate start/end trigger positions. It's not a bug in ScrollTrigger or anything - it's a fundamental logic thing. 

 

8 minutes ago, WaReZoR said:

Is there any way to set the height so that it ignores the address bar and always the content is under it?

You'd have to set that in your CSS so that it's not using vh, for example (because vh changes when the viewport height changes from the address bar showing/hiding). 

Link to comment
Share on other sites

Not quite so, what happens in fact, when the page is loaded, the first block takes 100vh, the content of this block is located under the address bar, thus occupies the entire height, after the start of scrolling the top of the block goes beyond the top edge of the screen, exactly as much space as the address bar at the bottom of the browser, and only at this point triggers ScrollTrigger pin and block freezes for animation.

Link to comment
Share on other sites

I'm not sure what you mean by "block freezes for animation" (are you referring to pinning?).

 

It kinda sounds like you're describing some CSS issue. If you have the height set to 100vh and you're saying that it goes UNDER the address bar, that definitely doesn't sound accurate. 

 

If you need more help with any GSAP-specific questions, please provide a minimal demo that focuses only on the problem you're facing (not your whole site - just a few colored boxes is fine) and we'd be happy to take a peek. 

Link to comment
Share on other sites

https://shl.mediacreator.agency/test
If it's not too much trouble, open this link on your mobile device, and try scrolling up and down the first block. It is actually 100vh high and should be fixed when you scroll because it triggers pinning, but in this place the entire body moves up beyond the visibility of the viewport. With my English it is very difficult to explain something, sorry, thank you for trying to understand and help. I'm trying to make a demo to replicate this.

Link to comment
Share on other sites

9 hours ago, WaReZoR said:

transferred more or less working version on codepen, just do not know how it helps to diagnose the mobile version and that particular problem.

Oh my goodness :) 

 

We cannot sift through 10,000+ lines of code for you - we were just asking for just a minimal demo, like a few colored <div> elements or something.

 

If you're triggering things with "bottom bottom", that kinda makes sense that it'd behave oddly when the bottom of the screen (where the address bar is showing/hiding) is shifting around and totally changing where things would line up. 

 

I'm also confused about why you have "width" and "height" function-based values in your timeline config. That won't do anything. Just curious what you were attempting there.

 

If you still need some help, we'd be happy to take a peek at a minimal demo and/or answer any GSAP-specific questions.

Link to comment
Share on other sites

3 hours ago, GreenSock said:

Oh my goodness :) 

I understand that, but I don't see how you could repeat the problem in a simplified way, sorry.

 

3 hours ago, GreenSock said:

If you're triggering things with "bottom bottom", that kinda makes sense that it'd behave oddly when the bottom of the screen (where the address bar is showing/hiding) is shifting around and totally changing where things would line up. 

Now I'll remember this I think for the rest of my life =).

 

3 hours ago, GreenSock said:

I'm also confused about why you have "width" and "height" function-based values in your timeline config. That won't do anything. Just curious what you were attempting there.

Do not pay attention to it please, it is the remnants of the experiments, I was trying to have at least some effect on the block and notice some changes. 

 

I have a couple more questions about the mechanics of gsap, can I ask them here or should I create a new thread?

Link to comment
Share on other sites

8 hours ago, WaReZoR said:

I understand that, but I don't see how you could repeat the problem in a simplified way, sorry.

No worries. It's almost surely possible to do it in a much more simplified way. This is a critical technique for troubleshooting in general - isolate, isolate, isolate. Yes, it takes time but it'll be far less time than trying to wrestle through 10k lines of code and all the inter-dependencies and complexities. I'd recommend starting with a few <div> elements that resemble part of your layout, and slowly build it up from there to be closer and closer like the "real" thing until it breaks. That'll make it very clear where the issue is. 

 

8 hours ago, WaReZoR said:

I have a couple more questions about the mechanics of gsap, can I ask them here or should I create a new thread?

Yep, it's always best to start a new thread for each question. Please be sure to include a minimal demo to exponentially increase your chances of getting a solid answer :)

 

Good luck!

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...