duration: "100%" gets the size of viewport not container
See original GitHub issueHi! First of all, thanks for this great plugin!!!
I’ve got an issue when using ScrollScene with duration:
import { ScrollScene, addIndicators } from 'scrollscene';
const domNode = document.querySelector('.test')
const anotherDomNode = document.querySelectorAll('.test .card')
const tl = gsap.timeline({ paused: true })
tl.to(anotherDomNode, {
x: -200,
duration: 1,
ease: "none",
})
const scrollScene = new ScrollScene({
triggerElement: domNode,
gsap: {
timeline: tl,
},
triggerHook: 1,
duration: "100%",
})
scrollScene.Scene.addIndicators({ name: 'pin scene', colorEnd: 'yellow' })
So indicators shows start and end of the duration, which is not the height of the container (900px), it’s the height of viewport (640px).
Am I doing something wrong? Can you help me, please?
Issue Analytics
- State:
- Created 3 years ago
- Comments:15 (10 by maintainers)
Top Results From Across the Web
How to make div occupy 100% of viewport height in browser
The problem has to do with the fact that the vh and vw units don't take the (added) scrollbar width/height into consideration.
Read more >Viewport concepts - CSS: Cascading Style Sheets | MDN
The size of the viewport depends on the size of the screen, whether the browser is in fullscreen mode or not, and whether...
Read more >CSS Viewport Units: A Quick Start - SitePoint
Viewport Maximum (vmax). This unit is based on the larger dimension of the viewport. If the viewport height is larger than the width,...
Read more >The Unexpected Power of Viewport Units in CSS - Lullabot
Without viewport units, we would need all the container elements of .image to have height: 100%; on them. Get the same result with...
Read more >CSS Height Full Page: CSS gotcha: How to fill page with a div?
In other words, 100vh = 100% of the viewport height ... If content is less than the length specified, min-height has no effect....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yeah, that’s accurate. That’s how ScrollMagic works. http://scrollmagic.io/docs/ScrollMagic.Scene.html#duration
I released a new update! It’s pretty dope. You can now set the
duration
as an HTMLElement, and now the scene will last the length of that element.https://scrollscene.jonkwheeler.now.sh/?path=/story/scrollscene-duration--duration-domnode
Check out the code here: https://github.com/jonkwheeler/ScrollScene/blob/master/src/stories/story.js#L706