Jump to content
Search Community

Triggering GSAP with an event handler

Scarybelles test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Greetings, friends.

 

Inspired by 

See the Pen aqaYxr?editors=0010 by kscarabello (@kscarabello) on CodePen

 that came out this week (the animal that watches you type in your email, and covers it's eyes when you write in a password), I'm trying to test my skills to see if I can recreate something similar. Where I am at right now is trying to get any sort of animation to work upon focusing on the password input bar. I intended to target the 'star' in the animation, and (in following the model of the other codepen), am wondering what I'm missing to make that animation trigger. Doesn't have to be pretty - just want to get the targeting an animations to work correctly.

 

 

 

See the Pen OQwWRb?editors=1010 by kscarabello (@kscarabello) on CodePen

Link to comment
Share on other sites

You didn't select the 'email' element. And a polygon doesn't have a 'width' and 'height' property. You could use scale or scaleX and scaleY for that.

 

var star = document.getElementById('star')
var email = document.querySelector(".email")

var onEmailFocus = (e) => {
  TweenMax.to(star, 5, {x: '+=1000', y: '-=1000'})
}

email.addEventListener('focus', onEmailFocus)

 

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