Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GSAP - Types error #47

Closed
ivodolenc opened this issue May 18, 2023 Discussed in #46 · 0 comments · Fixed by #48
Closed

GSAP - Types error #47

ivodolenc opened this issue May 18, 2023 Discussed in #46 · 0 comments · Fixed by #48
Labels
bug Confirmed issue

Comments

@ivodolenc
Copy link
Member

Discussed in #46

Originally posted by GuillaumeDgr May 18, 2023
Hi,
Could you pls provide a small example of effect with scroll trigger (fade in effect for example / with Nuxt 3)? I cannot make this work...
Many thanks.

nuxt.config.js :
modules: [ "@hypernym/nuxt-gsap", ], gsap: { extraPlugins: { scrollTrigger: true, }, },

Component :

<div id="js-trigger">
<h2 class="itemA">Test</h2>
<p class="itemB">Test</p>
</div>

<script setup lang="ts">
const { $gsap, $ScrollTrigger } = useNuxtApp();

function firstTween() {
$gsap.to(".itemA", {
  scrollTrigger: {
    id: "firstTween",
    trigger: "#js-trigger",
    start: "center 25%",
    end: "center 75%",
    scrub: 1,
    markers: true,
  },
  x: 300,
  opacity: 0,
  stagger: 0.1,
});
}

function secondTween() {
$gsap.fromTo(
  ".itemB",
  {
    x: 300,
    opacity: 0,
    stagger: 0.1,
  },
  {
    scrollTrigger: {
      id: "secondTween",
      trigger: "#js-trigger",
      start: "center 15%",
      end: "center 95%",
      scrub: 1,
      markers: true,
    },
    x: 0,
    opacity: 1,
    stagger: 0.1,
  }
);
}

onMounted(() => {
firstTween();
secondTween();
});

onBeforeUnmount(() => {
// Returns the ScrollTrigger with unique Id
// and kills it before route change
$ScrollTrigger.getById('firstTween').kill()
$ScrollTrigger.getById('secondTween').kill()
});
</script>

No effect is working and error is shown : "Property 'getById' does not exist on type '_ScrollTrigger'. Did you mean to access the static member '_ScrollTrigger.getById' instead?Vetur(2576)"

Thanks

@ivodolenc ivodolenc added the bug Confirmed issue label May 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant