Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...

Zahurul

Members
  • Posts

    10
  • Joined

  • Last visited

Posts posted by Zahurul

  1. I was preparing to do it by scrollmagic cos before i have done something like this for website sidebar, but mainly i wanted to do it in GSAP 3 cos i already used it for other animation and scroll related function but for this issue couldn't find a simple solution. Thanks a lot @mikel for your very simplified solution, will implement it on my upcoming website very soon. Greensock rocks... 👍

  2. Hi, I am trying to pin ".sun" element on bottom right of the page as fixed from start of the page till it reach the ".landscape" element, when ".sun" enter the ".landscape" element then it should scroll as normal with page. I am trying to achieve it by gsap 3 with scroll trigger plugin easiest and efficient way. on my codepen it doing totally opposite what i am trying to achieve. can anybody help please.

     

    See the Pen KKMEwMW by aboutzahurul (@aboutzahurul) on CodePen

  3. Hi, i am not that expart on it but i think the logic maybe:

    1.  get the viewport/scroll-container/section clientHeight
    2. then get the desire height where you want to show/pin/animate the download button by devide (clientHeight - viewport height) by 2 for half height
    3. then put your logic on ScrollTrigger onUpdate property (https://greensock.com/docs/v3/Plugins/ScrollTrigger) based on calculated height vs onUpdate progress onUpdate: ({progress, direction, isActive}) => console.log(progress, direction, isActive)  
    4. then do the animation as needed on timeline. 

    Hope it may give you some idea to think about. sorry if i am wrong.... 😂

    Thanks.

     

  4. Hi, @akapowl it seems your solution working here, thanks for your solution 👍... on other hand on ajax page load killing scroll and handling timer bit more work to do 😅...

     

    Ater reading some more documantation i found that, adding ScrollTrigger.refresh(true); on main timeline function revealItemsOnScroll(); resolved the issue simply. so main function changed to: 

     

    function revealItemsOnScroll(){
      if ( jQuery("#content .item").length ) {
        var revealItems = gsap.utils.toArray('#content .item');
        revealItems.forEach( function(revealItem, index){
          var singleImage = revealItem.querySelector("div > img");
          var singleTitle = revealItem.querySelector("h2 > span");
          var pageElement = gsap.timeline();
          
          ScrollTrigger.refresh(true);
          
          if( typeof(singleImage) != 'undefined' && singleImage != null ){
            pageElement.to( singleImage, {
              scrollTrigger: {
                trigger: singleImage,
                end: 'bottom top',
                start: 'top bottom',
                markers: true
                onEnter: () => { singleImage.classList.add("active"); },
                onLeaveBack: () => { singleImage.classList.remove("active"); },
              }
            });
          }
          if( typeof(singleTitle) != 'undefined' && singleTitle != null ){
            pageElement.to( singleTitle, {
              scrollTrigger: {
                trigger: singleTitle,
                end: 'bottom top',
                start: 'top 90%',
                markers: {startColor: "blue", endColor: "lime"},
                onEnter: () => { singleTitle.classList.add("active"); },
                onLeaveBack: () => { singleTitle.classList.remove("active"); }
              }
            });
          }
        });
      }
    }

     

    I have also updated the codepane and it seems now working:

    See the Pen OJXaamP by aboutzahurul (@aboutzahurul) on CodePen

     

    on my live code its also working fine, will check if there any more issue or not... now my next goal to add smooth scroll into it, i am trying to follow this codepen:

    See the Pen 89f1e24fbc30e59edbc186a4c961f35c by osublake (@osublake) on CodePen

     

    let me know if you guys have any suggession....

     

    Thanks you guys, very happy to see your quick respons 👍

     

    Cheers,

    Zahurul

  5. 44 minutes ago, akapowl said:

    That seems to be more jquery related than anything with GSAP.

    Can't tell you anything about that, sorry.

     

    sorry... yes page load handelled by jquery... I tried kill but no luck yet, still trying to resolve...

     

    I just updated the codepen a bit so it switch content, you can see on content element change it seems working but if you see the markers and content height etc it still a bit mess, can anybuddy suggest?

     

    See the Pen OJXaamP by aboutzahurul (@aboutzahurul) on CodePen

     

    Thanks...

     

  6. thanks  @76748-akapowl for your replay and for you suggestion, will try it...

    i tried to recreate the issue differently in codepen by replace html but seems like working:

     

    See the Pen OJXaamP by aboutzahurul (@aboutzahurul) on CodePen

     

    but on my real code not working 🤔....  is it beacuse i load them by jquery(). load()? my actual load content code like below:

     

    jQuery("#main-content").load( link + ' #main-content section', function( responseText, textStatus, jqXHR ){
      if( textStatus == 'success'){
        var pageTitle = jQuery(responseText).filter('title').text();
        //Letting browser to know new page loaded and added to browser history
        window.history.pushState( null, pageTitle, link );
        //setting browser title if current browsers don't support pushState title attribute
        document.title = pageTitle;
        //scrolling to top
        window.scrollTo(0,0);
        console.log( link, textStatus + ' (' + jqXHR.status + ')' );
        //Trigger custom events
        jQuery(document).trigger('page.loaded',[link]);
      }
      if( textStatus == 'error'){
        console.log( textStatus + ': ' + jqXHR.status + ' loading failed' );
      }
    });
    
    jQuery( window ).on("load page.loaded", function(e) {
      revealItemsOnScroll();
    });

    Is there something i am doing wrong?

    Thanks

  7. Hi, I am new to GSAP and trying to reload GSAP/ScrollTigger on DOM #content element change, which can done by many ways, my case: jQuery("#content").load("/somePageURL #content") then the new content replace current page DOM content, and at this stage my code dont work.

     

    On my code pen example  everything works fine on page load (not sure if its the correct way or not) but as if i change #content by calling jQuery("#content").load("/somePageURL #content"); and i replace current content and add custom jquery trigger jQuery(document).trigger('page.loaded',[link]);  so i can reload the main timeline function based on the custom trigger page.Loaded but it never load correctly and GSAP animation breaks, only it work if i reload the page on browser. sorry on my Codepen example i didn't added the ajax function to jQuery("#content").load(); cos i am not very expart on codepen but i hope you guys got the idea. On my newly replaced #content may have more .item element or less or empty so i tried to do some checks before i call GSAP timeline.

     

    Current HTML:

    <div id="content">
      <div class="item">
        <div class="img-box"><img src="https://via.placeholder.com/300x300?text=001" /></div>
        <h2><span>title1</span></h2>
      </div>
      <div class="item">
        <div class="img-box"><img src="https://via.placeholder.com/300x300?text=002" /></div>
        <h2><span>title2</span></h2>
      </div>
      <div class="item">
        <div class="img-box"><img src="https://via.placeholder.com/300x300?text=003" /></div>
        <h2><span>title3</span></h2>
      </div>
    </div>

     

    after jQuery("#content").load("/somePageURL #content"); call newly replaced HTML (#content) may be like this:

    <div id="content">
      <div class="item">
        <h2><span>title1</span></h2>
      </div>
      <div class="item">
        <div class="img-box"><img src="https://via.placeholder.com/300x300?text=002" /></div>
      </div>
      <div class="item">
        <div class="img-box"><img src="https://via.placeholder.com/300x300?text=003" /></div>
        <h2><span>title3</span></h2>
      </div>
      <div class="item">
        <div class="img-box"><img src="https://via.placeholder.com/300x300?text=004" /></div>
        <h2><span>title4</span></h2>
      </div>
      <div class="item">
        <div class="img-box"><img src="https://via.placeholder.com/300x300?text=005" /></div>
      </div>
      <div class="item">
        <div class="img-box"><img src="https://via.placeholder.com/300x300?text=006" /></div>
        <h2><span>title6</span></h2>
      </div>
    </div>

     

    So now, how can i reload the scroll triggered animation correctly without reloading the page? Please help...

    Thanks.

    See the Pen bGeQKvy by aboutzahurul (@aboutzahurul) on CodePen

×