-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Start with a pinned element in a "fixed" position #226
Comments
Hi Urs, Out of curiosity: Which plugin did you use before and why were you dissatisfied with it? |
Waypoints. I just don't get its logic. I'll look into your proposition with positioning it absolutely - i've tried fixed, but then I had huge jumps when changing to position:relative when scrolling. Probably absolute is better. If you'd like to see what I mean: neu.ofosu.ch - the yellow part at the bottom should peek out only a few pixels (one yellow line) at the beginning, but scroll up and down normally later on. I also thought about measuring the screen height and pushing down the object the required distance, keeping it relative. Which would probably not need scrollmagic anymore then. By the way, is it possible and would it make sense to use scrollmagic without GSAP, just to detect the scroll position in a comfortable way? Which would lead us back to waypoints, which I failed to understand... |
Positioning it absolutely was meant as an alternative to pinning/fixing it at all. Now you changed that definition by saying it should peek out for a while and then scroll up later on. If you want the element to be pinned right from the start and then unpin after some time, just create a scene with the duration you want your element to be pinned for and start it right from the start. As to your second question: Best regards from Lausanne to Bern, PS.: When making the above example I stumbled over a problem with bottom positioned elements that are pinned. The height isn't transferred to the spacer and thus the positioning is off. I will fix this bug for 2.0 as well... |
When using `bottom` or `right` to position absolutely positioned elements the positions were off. Fixed by copying the size to the spacer. More info here: #226 (comment) 7
Hi Jan thanks so much for your help! The thing is that I want the container to be bigger than displayed. Now I've made a very barebones positioning thing, #carpet being the #element. function setCarpet(){
var _rowwidth = $("#mainrow").width();
var _viewportHeight = $(window).height();
var _carpetOffset = _viewportHeight - 16;
$('#carpet').css({
"width": _rowwidth,
"height": _rowwidth,
"position": "absolute"
}).offset({top: _carpetOffset});
$('#carpet-wrapper').css({
"height": _rowwidth+500
});
} This is called on page load and on resize. I admit it's not that elegant. Actually, I think I could add a ScrollMagic scene on top of that positioning to have the #carpet element scroll by itself first until it bumps into the content, couldn't I? But I hesitate, thinking about reducing dependencies. So I'll probably just leave it barebones as is. That said, I think I've found the perfect scrolling effects library! And I'll look into the v2 for sure. Cheers |
Hi Urs, Do not position elements using javascript!It is (sadly) a very common practice to sort of brute force elements to be positioned somewhere on the page using javascript. I'm not sure what you mean by "the container to be bigger than displayed". But if you mean it should extend below the viewport that's no problem at all, see here: http://jsfiddle.net/mbuod494/3/ If you create a js fiddle of your example (working with your script above) I can show you how to do it in pure css. |
Ok, I'll try again! Let you know. |
Ah, maybe I can word this better: in your fiddle, I want the green box to On the academic part: without looking at the code, I thought that GSAP and |
I've been thinking: I guess a "pin" is not what I mean at all. I think by pin, you mean "not scroll with the page". What I was looking for was position:fixed or position:absolute.
Do I need ScrollMagic for this at all? If so, great! I'm just not sure |
Hi Urs,
That is beside the point. They are both javascript plugins that put a lot of experience, know-how and time into making these modifications as small and optimized as possible. This whole issue is actually a perfect example why you should always try to find a DOM/CSS solution for things like this first. The issue at hand If you want the following content to "peak" in, either set them to like 90% height or use negative margins to offset them by fixed pixel values. |
That's what I meant!!! And thank you so much for your examples. I got it working now. Three days and a so many detours to finish with a few lines of css.
Absolutely. I'm doing CSS for 10 yrs now and I'm still on the surface Thanks again! |
Hi Jan
Is it possible to start with an element pinned to the bottom of the viewport (n pixels above the bottom), IF there is enough space for it? So it would start like a
position:fixed
element, but when the scrolling begins, it would scroll normally?Sorry for the lazy question, I guess after a few hours with another scroll plugin it's more tired than lazy anyway... I've looked through a few issues here and I couldn't find the answer yet.
By the way, the visual debug information is awesome!
Cheers
Urs
The text was updated successfully, but these errors were encountered: