Jump to content
Search Community

ScrollTrigger resize not resetting/updating height value

madebysix test
Moderator Tag

Recommended Posts

Hi there,

During window resize the 'scroll trigger' seems to be working correctly, however the 'pinned' element doesn't receive the correct height/calculation. (Based on my 'setUp' function)

I'm just trying to update the '.container' element with the correct height, after resize.

Unless you know of a better approach to achieving a similar effect - where the hero scrolls over the top to reveal the page content, which then begins to scroll the page.

Thanks.

See the Pen LYyYoWv?editors=1010 by Jack_Six (@Jack_Six) on CodePen

Link to comment
Share on other sites

Hi madebysix!

 

I don't think you're getting the current offset. I didn't dive deep into your code, but this seems to work.

 

const init = () => {
  
  timeline = gsap.to(".panel:not(:last-child)", {
    y: getOffset, 
    ease: "none",
    scrollTrigger: {
      trigger: ".container",
      start: "top top",
      end: getOffset,
      scrub: true,
      pin: true,
      markers: true,
      invalidateOnRefresh: true,
      pinSpacing: false
    }
  })
}

function getOffset() {
  resetValues()
  setUp()
  return `+=${-(heroOffset)}`;
}

 

 

  • Like 2
Link to comment
Share on other sites

On 7/3/2021 at 2:22 AM, OSUblake said:

Hi madebysix!

 

I don't think you're getting the current offset. I didn't dive deep into your code, but this seems to work.

 


const init = () => {
  
  timeline = gsap.to(".panel:not(:last-child)", {
    y: getOffset, 
    ease: "none",
    scrollTrigger: {
      trigger: ".container",
      start: "top top",
      end: getOffset,
      scrub: true,
      pin: true,
      markers: true,
      invalidateOnRefresh: true,
      pinSpacing: false
    }
  })
}

function getOffset() {
  resetValues()
  setUp()
  return `+=${-(heroOffset)}`;
}

 

 

Hi, OSUblake )) i have some questions
1. what does it meanheroOffset ?
2. 
what does it mean - getOffset ?

3. what does it mean function  resetValues() and what return comeback ? 

resetValues
resetValues
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...