Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
syntax highlighting
  • Loading branch information
mhkeller committed Jan 15, 2016
commit 2af6ae9c7bcab3593436c7b240f6ea214cd26efe
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ Simple scrolling events for [d3](https://github.com/mbostock/d3) graphs. Based o

`graphScroll` takes a selection of explanatory text sections and dispatches `active` events as different sections are scrolled into to view. These `active` events can be used to update a chart's state.

```
```js
graphScroll()
.sections(d3.selectAll('#sections > div'))
.on('active', function(i){ console.log(i + 'th section active') })
```

The top most element scrolled fully into view is classed `graph-scroll-active`. This makes it easy to highlight the active section with css:

```
```css
#sections > div{
opacity: .3
}
Expand All @@ -26,7 +26,7 @@ The top most element scrolled fully into view is classed `graph-scroll-active`.

To support headers and intro images/text, we use a container element containing the explanatory text and graph.

```
```html
<h1>Page Title</div>
<div id='container'>
<div id='sections'>
Expand All @@ -42,7 +42,7 @@ To support headers and intro images/text, we use a container element containing

If these elements are passed to graphScroll as selections with `container` and `graph`, every element in the graph selection will be classed `graph-scroll-graph` if the top of the container is out of view.

```
```js
graphScroll()
.graph(d3.selectAll('#graph'))
.container(d3.select('#container'))
Expand All @@ -54,7 +54,7 @@ graphScroll()
With a little bit of css, the graph element snaps to the top of the page while the text scrolls by.


```
```css
#container{
position: relative;
overflow: auto;
Expand All @@ -81,7 +81,7 @@ With a little bit of css, the graph element snaps to the top of the page while t

As the bottom of the container approaches the top of the page, the graph is classed with `graph-scroll-below`. A little more css allows the graph slide out of view gracefully:

```
```css
#graph.graph-scroll-below{
position: absolute;
bottom: 0px;
Expand Down