Motion
module Motion| Assembly | Partas.Nacara.Plugins.Motion |
| Attributes | [<RequireQualifiedAccess>] |
Hovers drawn in Figma, configured and compiled from F#.
compile applies every override and fails on a hover or a change the document does not have.
Functions and values
[<Literal>] CdnUrl: string = "https://cdn.jsdelivr.net/npm/animejs@4.5.0/dist/bundles/anime.esm.min.js"
[<Literal>] CdnUrl: string = "https://cdn.jsdelivr.net/npm/animejs@4.5.0/dist/bundles/anime.esm.min.js"The anime.js module url used by animeFromCdn.
[<Literal>] LayerName: string = "motion"
[<Literal>] LayerName: string = "motion"The name of the style layer the CSS hovers are offered to the theme in.
animeFromCdn (options: MotionOptions) : MotionOptions
animeFromCdn (options: MotionOptions) : MotionOptionsLoads anime.js from the jsDelivr CDN instead of the bundled copy.
Defaults to the bundled copy.
| Parameter | |
|---|---|
options | The options to change. |
animeSource (source: AnimeSource) (options: MotionOptions) : MotionOptions
animeSource (source: AnimeSource) (options: MotionOptions) : MotionOptionsSets where anime.js comes from.
Defaults to Bundled.
| Parameter | |
|---|---|
source | Where anime.js comes from. |
options | The options to change. |
compile (options: MotionOptions) (document: MotionDocument) : Result<CompiledMotion,string>
compile (options: MotionOptions) (document: MotionDocument) : Result<CompiledMotion,string>Applies the options to a document and splits its hovers by engine.
Fails, naming the known ones, when the options name a hover or a change the document does not have. Fails, too, when a hover with a spring or spring preset easing is given a duration, when an easing override names a spring preset that is not one, and when two hovers of the document share a name.
| Parameter | |
|---|---|
options | The options. |
document | The parsed document. |
create () : IPlugin
create () : IPluginThe plugin, with the default options.
Loads the motion document at once and fails, naming the path, when it is missing.
createWith (configure: MotionOptions -> MotionOptions) : IPlugin
createWith (configure: MotionOptions -> MotionOptions) : IPluginThe plugin, with options changed by configure.
Loads the motion document at once, offers its CSS to the theme once, and fails when either cannot be done.
| Parameter | |
|---|---|
configure | Changes the default options. |
defaults: MotionOptions
defaults: MotionOptionsThe options a site starts from.
disable (name: string) (options: MotionOptions) : MotionOptions
disable (name: string) (options: MotionOptions) : MotionOptionsLeaves one hover out of the output.
Defaults to every hover being written.
| Parameter | |
|---|---|
name | The hover's name in the document. |
options | The options to change. |
document (path: string) (options: MotionOptions) : MotionOptions
document (path: string) (options: MotionOptions) : MotionOptionsReads the motion document from a path.
Resolved against the working directory. Defaults to "design/tokens/motion.json".
| Parameter | |
|---|---|
path | The path of the exported document. |
options | The options to change. |
duration (name: string) (ms: int) (options: MotionOptions) : MotionOptions
duration (name: string) (ms: int) (options: MotionOptions) : MotionOptionsSets the duration of one hover in milliseconds.
Applies to a linear or cubic-bezier easing. A spring plays over its settling time and a spring preset over 1200ms, so compile fails when the hover's easing, after any easing override, is a spring or a preset. Defaults to the document's duration.
| Parameter | |
|---|---|
name | The hover's name in the document. |
ms | The duration in milliseconds. |
options | The options to change. |
easing (name: string) (easing: Easing) (options: MotionOptions) : MotionOptions
easing (name: string) (easing: Easing) (options: MotionOptions) : MotionOptionsSets the easing of one hover.
A SpringPreset is one of "GENTLE", "QUICK", "BOUNCY" and "SLOW"; compile fails on any other name. Defaults to the document's easing.
| Parameter | |
|---|---|
name | The hover's name in the document. |
easing | The easing. |
options | The options to change. |
engine (engine: MotionEngine) (options: MotionOptions) : MotionOptions
engine (engine: MotionEngine) (options: MotionOptions) : MotionOptionsSets the engine that plays the hovers.
Defaults to Css.
| Parameter | |
|---|---|
engine | The engine. |
options | The options to change. |
hoverEngine (name: string) (engine: MotionEngine) (options: MotionOptions) : MotionOptions
hoverEngine (name: string) (engine: MotionEngine) (options: MotionOptions) : MotionOptionsSets the engine of one hover.
Defaults to the plugin's engine.
| Parameter | |
|---|---|
name | The hover's name in the document. |
engine | The engine that plays this hover. |
options | The options to change. |
load (options: MotionOptions) : Result<CompiledMotion,string>
load (options: MotionOptions) : Result<CompiledMotion,string>Reads the options' document, then compiles it.
A relative document path is taken from the project root. Fails, naming the resolved path and how to export the document, when the file is missing.
| Parameter | |
|---|---|
options | The options. |
projectRoot () : string
projectRoot () : stringThe project root Nacara builds this site from.
The value after --root on the command line when there is one, otherwise the directory of the site's project file, the same lookup Nacara makes.
reducedMotion (policy: ReducedMotion) (options: MotionOptions) : MotionOptions
reducedMotion (policy: ReducedMotion) (options: MotionOptions) : MotionOptionsSets what the stylesheet does for visitors who ask for reduced motion.
Defaults to Instant.
| Parameter | |
|---|---|
policy | The reduced-motion policy. |
options | The options to change. |
register (site: Site) : Site
register (site: Site) : SiteAdds the plugin to a site, with the default options.
| Parameter | |
|---|---|
site | The site. |
registerWith (configure: MotionOptions -> MotionOptions) (site: Site) : Site
registerWith (configure: MotionOptions -> MotionOptions) (site: Site) : SiteAdds the plugin to a site, with options changed by configure.
| Parameter | |
|---|---|
configure | Changes the default options. |
site | The site. |
resolve (root: string) (path: string) : string
resolve (root: string) (path: string) : stringThe full path of a document, a relative one taken from the project root.
An absolute path is returned as it is.
| Parameter | |
|---|---|
root | The site's project root. |
path | The document's path, as the options name it. |
value (name: string) (key: string) (css: string) (options: MotionOptions) : MotionOptions
value (name: string) (key: string) (css: string) (options: MotionOptions) : MotionOptionsReplaces the hovered value of one change with a CSS value.
Defaults to the document's value.
| Parameter | |
|---|---|
name | The hover's name in the document. |
key | The property for the root element, or Layer/property for a part. |
css | The CSS value. |
options | The options to change. |