3.0.1 • Published 3 years ago

d3-ease v3.0.1

Weekly downloads
1,492,202
License
BSD-3-Clause
Repository
github
Last release
3 years ago

d3-ease

Easing is a method of distorting time to control apparent motion in animation. It is most commonly used for slow-in, slow-out. By easing time, animated transitions are smoother and exhibit more plausible motion.

The easing types in this module implement the ease method, which takes a normalized time t and returns the corresponding “eased” time . Both the normalized time and the eased time are typically in the range 0,1, where 0 represents the start of the animation and 1 represents the end; some easing types, such as elastic, may return eased times slightly outside this range. A good easing type should return 0 if t = 0 and 1 if t = 1. See the easing explorer for a visual demonstration.

These easing types are largely based on work by Robert Penner.

Installing

If you use npm, npm install d3-ease. You can also download the latest release on GitHub. For vanilla HTML in modern browsers, import d3-ease from Skypack:

<script type="module">

import {easeCubic} from "https://cdn.skypack.dev/d3-ease@3";

const e = easeCubic(0.25);

</script>

For legacy environments, you can load d3-ease’s UMD bundle from an npm-based CDN such as jsDelivr; a d3 global is exported:

<script src="https://cdn.jsdelivr.net/npm/d3-ease@3"></script>
<script>

const e = d3.easeCubic(0.25);

</script>

Try d3-ease in your browser.

API Reference

# ease(t)

Given the specified normalized time t, typically in the range 0,1, returns the “eased” time , also typically in 0,1. 0 represents the start of the animation and 1 represents the end. A good implementation returns 0 if t = 0 and 1 if t = 1. See the easing explorer for a visual demonstration. For example, to apply cubic easing:

const te = d3.easeCubic(t);

Similarly, to apply custom elastic easing:

// Before the animation starts, create your easing function.
const customElastic = d3.easeElastic.period(0.4);

// During the animation, apply the easing function.
const te = customElastic(t);

# d3.easeLinear(t) <>

Linear easing; the identity function; linear(t) returns t.

# d3.easePolyIn(t) <>

Polynomial easing; raises t to the specified exponent. If the exponent is not specified, it defaults to 3, equivalent to cubicIn.

# d3.easePolyOut(t) <>

Reverse polynomial easing; equivalent to 1 - polyIn(1 - t). If the exponent is not specified, it defaults to 3, equivalent to cubicOut.

# d3.easePoly(t) <> # d3.easePolyInOut(t) <>

Symmetric polynomial easing; scales polyIn for t in 0, 0.5 and polyOut for t in 0.5, 1. If the exponent is not specified, it defaults to 3, equivalent to cubic.

# poly.exponent(e) <>

Returns a new polynomial easing with the specified exponent e. For example, to create equivalents of linear, quad, and cubic:

const linear = d3.easePoly.exponent(1);
const quad = d3.easePoly.exponent(2);
const cubic = d3.easePoly.exponent(3);

# d3.easeQuadIn(t) <>

Quadratic easing; equivalent to polyIn.exponent(2).

# d3.easeQuadOut(t) <>

Reverse quadratic easing; equivalent to 1 - quadIn(1 - t). Also equivalent to polyOut.exponent(2).

# d3.easeQuad(t) <> # d3.easeQuadInOut(t) <>

Symmetric quadratic easing; scales quadIn for t in 0, 0.5 and quadOut for t in 0.5, 1. Also equivalent to poly.exponent(2).

# d3.easeCubicIn(t) <>

Cubic easing; equivalent to polyIn.exponent(3).

# d3.easeCubicOut(t) <>

Reverse cubic easing; equivalent to 1 - cubicIn(1 - t). Also equivalent to polyOut.exponent(3).

# d3.easeCubic(t) <> # d3.easeCubicInOut(t) <>

Symmetric cubic easing; scales cubicIn for t in 0, 0.5 and cubicOut for t in 0.5, 1. Also equivalent to poly.exponent(3).

# d3.easeSinIn(t) <>

Sinusoidal easing; returns sin(t).

# d3.easeSinOut(t) <>

Reverse sinusoidal easing; equivalent to 1 - sinIn(1 - t).

# d3.easeSin(t) <> # d3.easeSinInOut(t) <>

Symmetric sinusoidal easing; scales sinIn for t in 0, 0.5 and sinOut for t in 0.5, 1.

# d3.easeExpIn(t) <>

Exponential easing; raises 2 to the exponent 10 * (t - 1).

# d3.easeExpOut(t) <>

Reverse exponential easing; equivalent to 1 - expIn(1 - t).

# d3.easeExp(t) <> # d3.easeExpInOut(t) <>

Symmetric exponential easing; scales expIn for t in 0, 0.5 and expOut for t in 0.5, 1.

# d3.easeCircleIn(t) <>

Circular easing.

# d3.easeCircleOut(t) <>

Reverse circular easing; equivalent to 1 - circleIn(1 - t).

# d3.easeCircle(t) <> # d3.easeCircleInOut(t) <>

Symmetric circular easing; scales circleIn for t in 0, 0.5 and circleOut for t in 0.5, 1.

# d3.easeElasticIn(t) <>

Elastic easing, like a rubber band. The amplitude and period of the oscillation are configurable; if not specified, they default to 1 and 0.3, respectively.

# d3.easeElastic(t) <> # d3.easeElasticOut(t) <>

Reverse elastic easing; equivalent to 1 - elasticIn(1 - t).

# d3.easeElasticInOut(t) <>

Symmetric elastic easing; scales elasticIn for t in 0, 0.5 and elasticOut for t in 0.5, 1.

# elastic.amplitude(a) <>

Returns a new elastic easing with the specified amplitude a.

# elastic.period(p) <>

Returns a new elastic easing with the specified period p.

# d3.easeBackIn(t) <>

Anticipatory easing, like a dancer bending his knees before jumping off the floor. The degree of overshoot is configurable; if not specified, it defaults to 1.70158.

# d3.easeBackOut(t) <>

Reverse anticipatory easing; equivalent to 1 - backIn(1 - t).

# d3.easeBack(t) <> # d3.easeBackInOut(t) <>

Symmetric anticipatory easing; scales backIn for t in 0, 0.5 and backOut for t in 0.5, 1.

# back.overshoot(s) <>

Returns a new back easing with the specified overshoot s.

# d3.easeBounceIn(t) <>

Bounce easing, like a rubber ball.

# d3.easeBounce(t) <> # d3.easeBounceOut(t) <>

Reverse bounce easing; equivalent to 1 - bounceIn(1 - t).

# d3.easeBounceInOut(t) <>

Symmetric bounce easing; scales bounceIn for t in 0, 0.5 and bounceOut for t in 0.5, 1.

d3d3-transition@d3-chart/d3atlasgroup-react-atlantic@dhi-ui/componentsdhi-ui-componentsdhi-ui-learnstorybookgraph-testvaluecoupongras-react-boilerplatesvg-regular-polygonscontentclustersunmindcib-flowmap@alpinemath/pfsc-moose@infinitebrahmanuniverse/nolb-d3@everything-registry/sub-chunk-1436@zach.winter/d3-vue@hyperobjekt/mapbox@hyperobjekt/untd-map@indigocore/mapexplorer-core@indigoframework/mapexplorer-core@ichef/transcharts-animation@ingruz/spaceyard@hikeman/react-graphviz@haskkor/react-native-pincode@graphique/geom-point@graphique/geom-vline@graphique/geom-tile@graphique/geom-bar@graphique/geom-col@graphique/geom-hline@graphique/geom-label@graphique/geom-line@graphique/geom-area@hopara/vega-deck.gl@gitpad/slide-it@gorillait/ngx-charts@long3009/ngx-graph-fixed-posdesdeo-componentsdeckgl-heatmap-v2@juanezm/terriajs@midiate/app-chord-recognizer@nearform/bubbleprof@neo4j-devtools/arc@nightvisi0n/terriajs@namcbugdb/react-public-map@namcbugdb/react-pubmap@kenetto/react-native-pincoded3-serviced3-simple-gauged3-simple-sliderd3-ng2-cortevad3-ng2-serviced3v4d3v410d3-funneld3-kpi-gaugedaedalum@latusinski/ngx-graphd3-transition-bkid3-view-componentsd3-latestd3-bundle-elementd3nicd3asyd3-fluidd3-fgd3-flame-graphd3-flame-graph-fix-by-sshd3-clockd-theiaddk-map@liferay/dxp-7.3@liferay/dxp-7.4@liferay/portal-7.2@liferay/portal-7.3@liferay/portal-7.4@liferay/dxp-7.2@ghalex/vue-d3-charts@gjmcn/atomic-agents@genome-spy/core@globalfishingwatch/map-components@globalfishingwatch/timebar@lusa/mindmap-plusdeepscatter@listen360/alexandria@meniga/graphs@meniga/d3@meghdad/mindmap@memgraph/orb@hellohutao/mindmap@hellowuxin/mindmap@hengkx/react-native-pincode@huoli/react-ui@msrvida/vega-deck.gl@msrvida/vega-morphcharts@nautiluslabs/plottabletechstars-nuka-carouselterriajs
3.0.1

3 years ago

3.0.0

3 years ago

2.0.0

4 years ago

1.0.7

4 years ago

2.0.0-rc.1

4 years ago

1.0.6

4 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

8 years ago

1.0.0

8 years ago

0.8.0

8 years ago

0.7.0

8 years ago

0.6.0

8 years ago

0.5.2

8 years ago

0.5.1

8 years ago

0.5.0

8 years ago

0.4.0

8 years ago

0.3.1

8 years ago

0.3.0

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.5

8 years ago

0.1.4

8 years ago

0.1.3

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago

0.0.0

10 years ago