Jump to content
Search Community

Nickicool

Members
  • Posts

    23
  • Joined

  • Last visited

Posts posted by Nickicool

  1. It may be simple, but I really can't figure out how to redo the usage example .batch () functions using timelines (instead of simple tweens). And I also need dynamically loaded elements by clicking on the button. I took the Codepen provided by user @ZachSaucier as a basis, but added SPAN to the DIV, for the complexity of the elements .card

     

    I wanted to use Timeline features like play() and reverse() to animate more complex objects .card than just an empty box...

    See the Pen JjRRyzr?editors=0010 by nickicool (@nickicool) on CodePen

  2. On 3/6/2020 at 9:20 PM, OSUblake said:

    @ZachSaucier your demo doesn't seem to snap correctly after dragging.

     

    But here's another way.

     

     

     

     

    Also, I would got rid of setting type: "x" on the Draggable as it will prevent dragging if you initially start dragging on the y axis, but then change direction.

     

    Why can't I make a fork of this pen? I would like to save it to my pens collection with a more understandable title than "Untitled"...

  3. 15 hours ago, ZachSaucier said:

    Hey Nickicool. It's more efficient to create the animations at the start and just use control methods to control the animations.

     

    Thanks for the answer @ZachSaucier! Yes, I read aboute that the best way to create animations at the start, not during execution. But, what if the number of elements is large and not every one of them will be "opened/closed" (in the case of the FAQ)?

     

    In my case, I don't see a problem with performance...

     

    Maybe I don't see the "hidden dangers".

  4. There was a problem, as it seemed to me in a simple situation. I need to toggle the class for an entry in the "FAQ" list. Opening the answer to the question (by clicking) add a class, and collapsing the answer-remove the class. I couldn't do it. I tried several options - none of them works correctly (all attempts are commented out in the code). The problem is that the class is added / removed randomly after a few clicks on the question (and its neighbors).

    See the Pen yLJrBaE by nickicool (@nickicool) on CodePen

  5. @ZachSaucier Thank you for the answer - you helped me a lot, directed me in the right direction! I made a one change in your example solutions:

    - content in ".item" can be more complex than a few paragraphs (this was just an example). That's why I wanted to use timeline instead of tweens to animate content.

     

    See the Pen gOMdgqx?editors=1010 by nickicool (@nickicool) on CodePen

     

    Now everything works the way I want it to! I also want to thank you for the link to your article-a great guide!

  6. I need to controll the animation with only one scroll trigger (in the example Codepen below):

    • Headers with "stagger" animation (this is easy to do, in the example it works)
    • Paragraphs ("<p>") with staggers effect in each of the ". item" (and how to do this I do not know - in the example, non-working, incorrect code, just to understand which way I'm thinking).

     

    Please help me!)

    See the Pen rNLZemG by nickicool (@nickicool) on CodePen

  7. Hi!

     

    I have a problem on starting the animation. Animation elements are not set to the start position ("from" point) of the animation "behind the scene". This happens right before the animation starts, so the animated elements "flash" at the start of the animation.

     

    Experimentally, I found that the reason is in the "ScrollTrigger.saveStyles"method. But without it (if comment it), the animation also works incorrectly when changing the media query. Although the "blinking" disappears when the animation starts.

     

    I do not know how to fix it... Please help me!

    See the Pen oNLzeog?editors=1010 by nickicool (@nickicool) on CodePen

  8. I am not a very experienced programmer, please help me with the right direction of thoughts. Do I understand correctly or not that the animation selection should be implemented inside each function (and not outside of them):

        var gsapFunctions = {
            blockExamples: function () {
            //...
            },
    
            blockFaq: function () {
              //...
            }
        }

    If I understand correctly, when resizing, I should kill the previous animation (anim.kill(); or aim.progress(0).kill()). To do this, I need access to the animation/timeline object... Am I right? In my code, functions don't return animation objects, and I don't have access to them.

  9. You mean that I should write my own custom handling of animation selection and resize control, instead of using the construction (?):

     

        ScrollTrigger.matchMedia({
            // desktop
            "(min-width: 800px)": function() {},
            // mobile
            "(max-width: 799px)": function() {},
            // all
            "all": function() {
            }
        });

     

  10. I have blocks on the page that are loaded dynamically (ajax). All blocks have a parameter that specifies the name of the function with GSAP animation.

    <section class="lazyload" id="examples" data-gsap-function="blockExamples"></section>
    <section class="lazyload" id="faq" data-gsap-function="blockFaq"></section>
    // this functions run by events (like click or after load content with ajax)
    var gsapFunctions = {
      blockExamples: function () {
        gsap.from("#examples img", {
          // ...
        });
      },
    
      blockFaq: function () {
        gsap.utils.toArray("#faq .item").forEach((item) => {
          var timeline = gsap.timeline({});
          timeline
          //...
        });
      }
    };

    After loading the block content, I run the function that contains the code for animating this block. In the Codepen example, I emulated loading Ajax content by clicking on a button.

    Everything works well. But now I need to make alternative functions for some blocks with animations for the mobile/desktop version. I don't understand how this can be done in my case. I mean, I would like to keep the ability to record animations for different blocks in separate functions. Perhaps this is the wrong approach - please show me how to do it correctly.

    See the Pen xxOZwjK by nickicool (@nickicool) on CodePen

  11. This is not exactly a GSAP question. Why in one of the parallax examples do you use offsetHeight, instead of a fixed value like this:

    const movement = (1000 * depth)If use offsetHeight, elements with different heights and the same depth will move at different speeds.

     

    I want to figure out whether I need it or not.

     

    I also found that the images added by the ajax method do not work parallax animation, because for some reason they have zero height (or something that).

    See the Pen OJyPmgX by GreenSock (@GreenSock) on CodePen

  12. 6 minutes ago, OSUblake said:

    Use a timeline.

    I tried earlier using Timeline, but it didn't work out at all. To show the result I make changes to the start Codepen (because I don't know how to insert a new one in the response):

    • The animation stops working for the individual completely - all .item behaves as a single unit.
    • Delay no longer works for pseudo elements - they are triggered immediately, but rather with a small delay (Yes, for .data-wrapper works well).

    Please help with the correct Timeline... This is my first animation.

     

    And about CSS vars - in my region, only 80% of the browser supports. I need a different solution... Is it possible to solve this if each .item has an additional unique class, such as .icon_x (where x is the ordinal number)? And in TImeline code use some like this .to(CSSRulePlugin.getRule("#js-traits-list .icon-1:before")?

     

     

    6 minutes ago, OSUblake said:

    And zoom is not standard. Use scale.

    https://developer.mozilla.org/en-US/docs/Web/CSS/zoom

    Thanks for the great tips!

  13. Trying to create my first animation on GSAP. But there is a problem... If you scroll the page, the animation of pseudo elements is played incorrectly - they react all at once, and as many times as the number of elements. Moreover, the container with the text and the container with the SVG icon are animated correctly - each at the time when it appears on the screen.

    I have 2 questions:

    1. What am I doing wrong, how do I do it right?
    2. And how can I optimize this example in terms of performance, given that everyone has the same scrollTarget.

     

     

    See the Pen zYqZEYZ?__cf_chl_jschl_tk__=70345f77e75071942f0b852760b6275261296917-1598379171-0-ATNiJruMI5o8mRZpd7Dz4prIuLbPo71p9FzVcvyYshTKUJwj-pzeAhrbupvWZzHnPJ6yzEVeMzkUq347mkPC5j360rEmc9VnDP8yPPLU7C46JGXnxPHI1k4_Dgxa_CcWQd8SWwv74Yz4 by nickicool (@nickicool) on CodePen

  14. I'm trying to animate the appearance of an svg icon with a description below it. The icon has a wrapper with the pseudo elements :before and :after with a different background color. I want to animate the zoom of a pseudo element, but nothing works. The background color changes, but the zoom doesn't work.

     

    gsap.registerPlugin(ScrollTrigger, CSSRulePlugin);
    
    gsap.to( CSSRulePlugin.getRule(".icon-wrapper:before"), {
            duration: 3, 
            cssRule: {
                transform: 'scale(3)',
                background: 'red'
            }
        });

    Help me, please. I don't know what to do.

×
×
  • Create New...