question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

duration: "100%" gets the size of viewport not container

See original GitHub issue

Hi! 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:closed
  • Created 3 years ago
  • Comments:15 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
jonkwheelercommented, May 12, 2020

Yeah, that’s accurate. That’s how ScrollMagic works. http://scrollmagic.io/docs/ScrollMagic.Scene.html#duration

0reactions
jonkwheelercommented, May 15, 2020

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

const scrollScene = new ScrollScene({
  triggerElement,
  toggle: {
    element: containerElement,
    className: "turn-blue",
    reverse: true,
  },
  triggerHook: 0.25,
  duration: triggerElement,
});

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found