Jump to content
Search Community

Approach to invalid property on Vue refs.

kananomegane test
Moderator Tag

Recommended Posts

Good day GSAP forum, I'm looking for an approach for creating of reusable gsap animations in vue/nuxt from versed people.

Here's an example of what I tried to make, but I got an invalid property error. I understand that you can't animate DOM elements.
As I was searching the forums, I got an answer to use the selector utility. However, I'm quite lost on how should I apply it. I tried the stuffs that appeared from my search and asked an AI but didn't give me results.
 

export function useGSAP() {
  const elementRef = ref(null);

  const linkHover = () => {
    gsap.to(elementRef.value, { y: -3, duration: 0.3 });
  };

  const linkLeave = () => {
    gsap.to(elementRef.value, { y: 0, duration: 0.3 });
  };

  return {
    elementRef,
    linkHover,
    linkLeave,
  };
}


Hope people can give me on insights, thank you in advance!

Link to comment
Share on other sites

Solved it by debugging the return value of the ref.value. I don't know if this will limit my options on more advanced reusable animations, so inputs are still accepted ^^
 

export function useGSAP() {
  const elementRef = ref(null);

  const linkHover = () => {
    gsap.to(elementRef.value.$el, { y: -3, duration: 0.3 });
  };

  const linkLeave = () => {
    gsap.to(elementRef.value.$el, { y: 0, duration: 0.3 });
  };

  return {
    elementRef,
    linkHover,
    linkLeave,
  };
}

 

Link to comment
Share on other sites

  • kananomegane changed the title to Approach to invalid property on Vue refs.

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