Jump to content
Search Community

Visual-Q last won the day on April 3 2021

Visual-Q had the most liked content!

Visual-Q

Moderators
  • Posts

    503
  • Joined

  • Last visited

  • Days Won

    4

Posts posted by Visual-Q

  1. Kind of hard to tell as I can never manage to commit Regex rules to memory. but if as you say it only fails with numbers including "," that would seem to point to a failure in the Regex. I would try logging out those values to be sure they are yielding the right results.

     

    Assuming an issue with Regex maybe this will help.

    https://stackoverflow.com/questions/6649327/regex-to-remove-letters-symbols-except-numbers

     

    If no luck with this please try making a codepen if possible so we can take a closer look.

     

  2. 20 minutes ago, iDad5 said:

    I agree that would be the best way, only to register GSAP and his/her own script if(is_front_page()...) in functions.php but from the way the question is asked I surmised that this would probably lead to more questions and those would be to 'wordpressy' ;-) 

     

    Assuming assets are propery enueued in php they would already be accustomed to working in the functions file.

     

    If they are manually added then yeah you could do it all in js something like:

     

    if ($("body").hasClass("home")) { //check your home page to see what unique classes are appended to the body
        // do stuff
    }

    or

     

    if (document.body.classList.contains('home"')) { //check your home page to see what unique classes are appended to the body
        // do stuff
    }

     

    • Like 4
  3. Hey Samuel welcome to the forum.

     

    It's a bit hard to diagnose without context so hopefully you'll be able to get a codepen up. A simplified test case is usually easier to diagnose than a complex example so you might try something basic just to illustrate your issue.

     

    In the meantime check out this page it covers a lot of common issues people have and includes a section about nested scroll triggers which might apply to your situation.

     

     

    • Like 3
  4. Zachs answer about animating different elements made me think you might also animate different properties to move the same elements as well. Possibly set  up the css so you can use Left,Top with one animation and the x,y transforms with the other. I believe this could solve the conflict and should allow everything to end up in the right place.

     

    Or you could use x,y with xPercent yPercent: https://greensock.com/docs/v3/GSAP/CorePlugins/CSSPlugin

     

    See the Pen WNoLYMB by Visual-Q (@Visual-Q) on CodePen

     

     

    • Like 3
  5. Jack's is definitely a better solution though it still creates intermittent problems depending on when you scroll.

     

    It's an interesting issue though, even if it hasn't come up before I can certainly see how people might want an initial animation that subsequently reacts to scroll input. The question is how best to handle it so it doesn't break the user experience.

  6. The issue is if you start scrolling before the initial animation is done the scrub and start animation fight for control. You could try disabling scrolling till the first animation is complete but that might be confusing for people. At the very least make the fist animation faster so the scroll disable doesn't last so long.

     

    See the Pen VwmqKMN by Visual-Q (@Visual-Q) on CodePen

     

     

    • Like 3
  7. There's number of examples of horizontal slider sliders on this page https://greensock.com/st-demos/

     

    Based on the example from the site your showed and given that you want a timed auto slide and user initated swipe type action you might just be able to setup a timeline that changes at required intervals and then use a wheel event, and any other interactive events that are anticipated, to manually trigger  a slide, you could use the event to advance the timeline at the same time perhaps to a label to keep things running smooth.

     

    https://developer.mozilla.org/en-US/docs/Web/API/Element/wheel_event

     

    Repeat delay might also be useful here https://greensock.com/docs/v3/GSAP/Timeline/repeatDelay()

     

    As far as adding removing classes a callback could do that so yeah you can add in functions wherever you need them. See call() and add() in the docs:

     

    https://greensock.com/docs/v3/GSAP/Timeline

     

    One more thing of course Zachs tips are a good place to start when thinking about this type of thing

    https://css-tricks.com/tips-for-writing-animation-code-efficiently/

     

    • Like 1
  8. You can get the height of an element a couple of different ways, here's a couple of links to methods for that. Using it within the timeline you could use a callback at an appropriate point to get the values when you need them. Not sure what you're meaning to do with it so hopefully this points you in the right direction.

     

    https://www.w3schools.com/jsref/met_element_getboundingclientrect.asp

     

    https://www.w3schools.com/jsref/prop_element_offsetheight.asp

     

     

    • Like 1
×
×
  • Create New...