Jump to content
Search Community

stíobhart

Members
  • Posts

    1
  • Joined

  • Last visited

Posts posted by stíobhart

  1. Hi all.

     

    Complete newbie to GSAP here. i'm looking forward to getting to grips with it to add some animation to a site I'm currently redesigning.

     

    At the minute though there's one legacy script on the site, which relies on jQuery. It's just a wee utility script which will animate scrolling to any element on a page with an ID attribute set. [see the Codepen]

     

    I want to "translate" this to GSAP instead, as it seems daft loading jQuery as well as GSAP, just for this one feature. However my JavaScript Fu is a bit rusty and I'm not having much luck working out how to GSAP-ise my selector.

     

    The function is supposed to be triggered when a link is clicked with an href of `#someID` but not for an href of `#`.  GSAP doesn't seem to like the `:not` selector... or my attempts to adapt the syntax are wrong.

     

    Here's the jQuery version:

    $(function() {
      $('a[href*="#"]:not([href="#"])').click(function() {
    
    // do stuff
    
    });
    });
    

    Could anyone give me a few hints?

     

    See the Pen PNmwyK by stiobhart (@stiobhart) on CodePen

×
×
  • Create New...