Skip to content

Commit

Permalink
Add an example of position: 'sticky'
Browse files Browse the repository at this point in the history
  • Loading branch information
mauriciopoppe committed Oct 26, 2024
1 parent 66cfdc5 commit a792b6f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
18 changes: 18 additions & 0 deletions site/js/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,24 @@ function onSiteDependenciesLoaded() {
data: [{ fn: 'sqrt(1 - x * x)' }, { fn: '-sqrt(1 - x * x)' }]
})

/**
* ### Sticky axes
*
* Set `position: 'sticky'` on an axis to keep it centered
* in the screen and constrained to the viewport on pan and zoom.
*/
functionPlot({
target: '#sticky',
x: {
position: 'sticky'
},
y: {
position: 'sticky'
},
grid: true,
data: [{ fn: 'cos(x)' }]
})

/**
* ### Domain
*
Expand Down
14 changes: 13 additions & 1 deletion site/partials/examples.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,19 @@
},
grid: true,
data: [{ fn: 'sqrt(1 - x * x)' }, { fn: '-sqrt(1 - x * x)' }]
})</code></pre></div></div><div class="col-md-6 center-block demos"><span class="graph" id="grid"></span></div></div></div></div><div class="example"><div class="container"><div class="row"><div class="col-md-6"><div class="comment"><h3>Domain</h3>
})</code></pre></div></div><div class="col-md-6 center-block demos"><span class="graph" id="grid"></span></div></div></div></div><div class="example"><div class="container"><div class="row"><div class="col-md-6"><div class="comment"><h3>Sticky axes</h3>
<p>Set <code>position: 'sticky'</code> on an axis to keep it centered
in the screen and constrained to the viewport on pan and zoom.</p></div><div class="code"><pre><code class="javascript">functionPlot({
target: '#sticky',
x: {
position: 'sticky'
},
y: {
position: 'sticky'
},
grid: true,
data: [{ fn: 'cos(x)' }]
})</code></pre></div></div><div class="col-md-6 center-block demos"><span class="graph" id="sticky"></span></div></div></div></div><div class="example"><div class="container"><div class="row"><div class="col-md-6"><div class="comment"><h3>Domain</h3>
<p>The domains of both axes can be changed with the following configurations:</p>
<ul>
<li><code>xDomain</code>, defaults to <code>[-7, 7]</code></li>
Expand Down

0 comments on commit a792b6f

Please sign in to comment.