It's my first time using skrollr so the last few hours I've been trying lots of things in order to get to grips with it.
The plan is to have a 3d image of a building and as I scroll the building will turn 360degrees. I'm currently using a car as an example and it's in a large bg image where I change the position of the background depending where I am. Here is a snippet of my code:
<div data-0="" data-900="" class="skrollable skrollable-before ">
<div id="wrap">
<div class="car" data-0="dispay:block;" data-50="display:none;background-position:!0 0px;"></div>
<div class="car" data-0="display:none;" data-50="display:block;background-position:!0 -500px;" data-100="display:none;"></div>
<div class="car" data-0="display:none;" data-100="display:block;background-position:!0 -1000px;" data-150="display:none;"></div>
<div class="car" data-0="display:none;" data-150="display:block;background-position:!0 -1500px;" data-200="display:none;"></div>
<div class="car" data-0="display:none;" data-200="display:block;background-position:!0 -2000px;" data-250="display:none;"></div>
<div class="car" data-0="display:none;" data-250="display:block;background-position:!0 -2500px;" data-300="display:none;"></div>
</div>
</div>
This is working correctly!
However, this is going to be on a long page filled with other content. What I'd like to do is have the building so it's fixed to the page as it's rotating. I've tried using position fix but it just seems a bit funny as all my other content then gets pulled around.
Am I missing something how could this be done?
I've seen examples of other websites achieve it and I've tried inspecting the code to get an idea of how it's done but I can't seem to spot it.
Any help would be appreciated!
Edit ** This is what I ended up with in the end:
<div class="wrap"
data-0="margin-top: -250px;"
data-_foobar--50="opacity: 0;"
data-_foobar-0="opacity: 1; display: block;"
<div class="building"
data-_foobar-50="background-position:!0 0px;"
data-_foobar-100="background-position:!0 -500px;"
data-_foobar-150="background-position:!0 -1000px;"
data-_foobar-200="background-position:!0 -1500px;"
data-_foobar-250="background-position:!0 -2000px;"
data-_foobar-300="background-position:!0 -2500px;"
>
</div>
</div>
I fixed the position of 'wrap' and set it to hide and then show once it was in the viewport using constants.
var viewportHeight = $(window).height();
var constantsData = Math.floor(viewportHeight * 1);
var s = skrollr.init({
constants: {
foobar: constantsData
}
});