d3.graphScroll() .sections(d3.selectAll('#sections > div')) .on('active', function(i){ console.log(i + 'th section active') })
#sections > div{ opacity: .3 } #sections div.graph-scroll-active{ opacity: 1; }
<h1>Page Title</div> <div id='container'> <div id='graph'></div> <div id='sections'> <div>Section 0</div> <div>Section 1</div> <div>Section 2</div> </div> </div> <h1>Footer</h1>and passed to graphScroll
d3.graphScroll() .graph(d3.select('#graph')) .container(d3.select('#container'))
#container{ position: relative; } #sections{ width: 340px; } #graph{ margin-left: 40px; width: 500px; position: sticky; top: 0px; float: right; }
@media (max-width: 925px) { #graph{ width: 100%; transform: translate(-50%, 0); margin-left: 50%; } #sections{ position: relative; margin: 0px auto; padding-top: 400px; } }
- Simple examples
- Self explanatory graphics
- Swiper