jquery - Skrollr animate an element inside, relative to a scrolling div -
i having issue trying element animate inside moving div;
imagine have div
(blue 800 wide x 100 high) off screen, below screen , when scroll down comes screen , continues , disappears out of top of screen. call div
"container".
now imagine if have smaller div
inside "container" div
, called "box" , apply animation "box" moving left right.
i expect when scroll down box move left right inside container, container moves screen. (resulting in box looking moving diagonally screen)
the result container moves screen, expected, box outside of it's container , moves right left across bottom of screen
i cannot figure out how make box move inside it's parent container , scroll it.
i think need use relative
mode (or view-port mode) can't work @ all.
spacer div:
<div id="justaspacer" style="height:1000px;"></div>
(container div):
<div id="container" style="width:800px; background:#d1e3ed; height:100px; margin:auto;></div>
(box div):
<div id="box" style="background:#00f; width:100px; height:100px;" data-anchor-target="#container" data-100-bottom="left:100%; opacity:0;" data--100-bottom="left:50%;opacity:1;" data-top="top:80%;">"</div>"
this results in container scrolling , and box fly in off screen removed container.
that code, no other css ,
<script type="text/javascript" src="dist/skrollr.min.js"></script> <!--[if lt ie 9]> <script type="text/javascript" src="dist/skrollr.ie.min.js"></script> <![endif]--> <script type="text/javascript"> var s = skrollr.init({ edgestrategy: 'set', easing: { wtf: math.random, inverted: function(p) { return 1-p; } } }); </script>
this javascript
any appreciated
been driving me crazy
hope can
like dan said in comment, need position container relative , box absolute. should learn css before trying skrollr.
<div id="container" style="width:800px; background:#d1e3ed; height:100px; margin:auto;position:relative;"></div>
<div id="box" style="background:#00f; width:100px; height:100px;position:absolute;" data-anchor-target="#container" data-bottom="left:100%;margin-left:-100px;" data-top="left:0%;margin-left:0px;"></div>
Comments
Post a Comment