Jump to content
Search Community

ScrollToPlugin dont defined

mastergubs test
Moderator Tag

Go to solution Solved by mastergubs,

Recommended Posts

Hello, i have my scripts in the end of my html 

<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.5/gsap.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/gsap@3.12.5/dist/TextPlugin.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.5/ScrollTrigger.min.js"></script> et in file js i write in my first line 
gsap.registerPlugin(TextPlugin,ScrollTrigger,ScrollToPlugin) all my code works without scrolltoplugin and when i add this in my registerPlugin my website dont work.My second question if this code seems be to good to scroll in section of my horizontal scroll 
const lis=document.querySelectorAll("li")
 
console.log(lis)
 
lis.forEach((li, index) => {
console.log("foreach")
li.addEventListener("click", () => {
console.log("clicked")
gsap.to(window, {duration: 1, scrollTo:{x:".races div:nth-child(" + (index + 1) + ")", offsetX:70}});
});
});
 
 
 thank you and good day
Link to comment
Share on other sites

You have a typo in your script tag. It's src and you have scr in your tag:

<!-- Wrong -->
<script scr=" https://cdn.jsdelivr.net/npm/gsap@3.12.5/dist/ScrollToPlugin.min.js"></script>

<!-- Right -->
<script src=" https://cdn.jsdelivr.net/npm/gsap@3.12.5/dist/ScrollToPlugin.min.js"></script>

 

Hopefully this helps.

Happy Tweening!

Link to comment
Share on other sites

thank you it was what i said in my last post, its good i havent errors but my code dont work.I need a solution to use ScrollToPlugin  with my horizontal scroll.I dont know if i need to use ScrollToPlugin with my scrollTrigger or to do use it alone.

Link to comment
Share on other sites

Without a minimal demo, it's very difficult to troubleshoot; the issue could be caused by CSS, markup, a third party library, a 3rd party script, etc. Would you please provide a very simple CodePen or Stackblitz that illustrates the issue? 

 

Please don't include your whole project. Just some colored <div> elements and the GSAP code is best. See if you can recreate the issue with as few dependencies as possible. Start minimal and then incrementally add code bit by bit until it breaks. Usually people solve their own issues during this process! If not, at least we have a reduced test case which greatly increases your chances of getting a relevant answer.

 

See the Pen aYYOdN by GreenSock (@GreenSock) on CodePen

that loads all the plugins. Just click "fork" at the bottom right and make your minimal demo

 

Using a framework/library like React, Vue, Next, etc.? 

CodePen isn't always ideal for these tools, so here are some Stackblitz starter templates that you can fork and import the gsap-trial NPM package for using any of the bonus plugins: 

 

Please share the StackBlitz link directly to the file in question (where you've put the GSAP code) so we don't need to hunt through all the files. 

 

Once we see an isolated demo, we'll do our best to jump in and help with your GSAP-specific questions. 

Link to comment
Share on other sites

hello,see my code is like the code of Carl the teacher.

See the Pen dyabKKg by snorkltv (@snorkltv) on CodePen

In this code,if i want to add menu to going on the race without scrolling,what i need?

My try is this and i dont know if this good direction.Than you again.

 

HTML

<div class="menu">
<ul>
<li>Austria</li>
<li>Hungary</li>
<li>Italy</li>
<li>Great Britain</li>
<li>Bahrain</li>
</ul>
</div>
 
JS
lis.forEach((li, index) => {
console.log("foreach")
li.addEventListener("click", () => {
console.log("clicked")
gsap.to(window, {duration: 1, scrollTo:{y:".races div:nth-child(" + (index + 1) + ")"}}});
});
});
lis.forEach((li, index) => {
    console.log("foreach")
    li.addEventListener("click", () => {
        console.log("clicked")
      gsap.to(window, {duration: 1, scrollTo:{y:".races div:nth-child(" + (index + 1) + ")"}}});
    });
});
lis.forEach((li, index) => {
    console.log("foreach")
    li.addEventListener("click", () => {
        console.log("clicked")
      gsap.to(window, {duration: 1, scrollTo:{y:".races div:nth-child(" + (index + 1) + ")"}}});
    });
}
Link to comment
Share on other sites

Hi,

 

You have an error when creating the getScrollLookup instance, you're supposed to pass the horizontal Tween not the ScrollTrigger instance:

// Wrong
let getPosition = getScrollLookup(".race", {
  start: "center center",
  containerAnimation: horizon // ScrollTrigger instance
});

// Right
let getPosition = getScrollLookup(".race", {
  start: "center center",
  containerAnimation: tween // GSAP Tween
});

The helper function needs the actual Tween that is moving the elements horizontally, not the ScrollTrigger instance that creates that particular effect. Here is a fork of your demo:

See the Pen qBwevOW by GreenSock (@GreenSock) on CodePen

 

Hopefully this helps.

Happy Tweenning!

  • 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...