Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
@microsoft/fast-animation
Advanced tools
An animation library that simplifies interactions and animations using the Web Animation API.
Fast Animation is a library for simplifying the creation of animations and interactions using the Web Animation API.
npm install @microsoft/fast-animation
The primary tools for creating animations are the AnimateTo
and AnimateFrom
classes. These classes allow you to apply animations to HTML elements:
var myHtmlElement = document.getElementById("myElement");
var myAnimation = new AnimateTo(myHtmlElement, { x: "30%", scale: 2 }, { duration: 300, delay: 20 });
// Play the animation.
myAnimation.play();
Sequencing and grouping classes are provided to help orchestrate more elaborate animations:
var mySequence = new AnimateSequence([
new AnimateTo(element1, { x: 20 }),
new AnimateTo(element2, { x: 20 }),
new AnimateTo(element3, { x: 20 })
]);
// Attach an onFinish callback.
mySequence.onFinish = () => {
window.prompt("Did you like our animations?");
}
// Play all animations, one after another. When completed, ask the user if they liked the animation sequence.
mySequence.play();
TheAnimateTo
and AnimateFrom
classes can be used to create a variety of complex animations. These classes allow you to specify which properties should be animating as well as information like easing curves, duration, delay, and more.
constructor(el: HTMLElement, options?: Options, timing?: EffectTiming)
Both AnimateTo
and AnimateFrom
accept one required parameter and two optional parameters:
var myAnimation = new AnimateTo(myHtmlElement, { x: 20 }, { duration: 250 });
The following options are used to construct the animation and configure which properties the animation should change:
x: { number | string }
adjusts the element's horizontal position. This property adjusts the transform
property.y: { number | string }
adjusts the element's vertical position. This property adjusts the transform
property.scale: { number[] | number }
adjusts the scale of the element. If given a number, scale applies to both x and y-axes. If given an array of two numbers, x and y scale independently. This property adjusts the transform
property.rotate: { number }
adjusts the rotation of the object by a number of degrees. This property adjusts the transform
property.top: { string | number }
adjusts the top
property.right: { string | number }
adjusts the right
property.bottom: { string | number }
adjusts the bottom
property.left: { string | number }
adjusts the left
property.transformOrigin: { string }
adjusts the origin of any transform effects applied via the animation.transformStyle: { string }
applies the value to the transfrom-style
property of the element.The EffectTiming
object is passed directly to the WAAPI and should conform to the AnimationEffectTiming.
The public methods exposed by the AnimateTo
and AnimateFrom
classes are play
, pause
, finish
, cancel
, and reverse
. For more information on what these methods do, see the corresponding method exposed by the WAAPI Animation object.
onFinish: () => void
is provided, onFinish
is called when the animation has completed.onCancel: () => void
is provided, onCancel
is called when (and if) the animation is canceled.The AnimateGroup
and AnimateSequence
classes are both classes that allow you to group and play animations together. Each takes an array of AnimateTo or AnimateFrom objects and provides an API to play
, pause
, finish
, cancel
, and reverse
the collection of animations. AnimateGroup
allows you to control all animations simultaneously while AnimateSequence
allows you to control all animations in a sequence:
var myAnimationGroup = new AnimateGroup([
new AnimateTo(element1),
new AnimateTo(element2)
]);
var myAnimationSequence = new AnimateSequence([
new AnimateTo(element3),
new AnimateTo(element4)
]);
// AnimateGroup plays all animations at the same time.
myAnimationGroup.play();
// AnimateSequence plays all animations one after another in array order.
myAnimationSequence.play();
Both AnimateGroup
and AnimateSequence
accept an array of AnimateTo
and AnimateFrom
objects:
constructor(AnimateTo[] | AnimateFrom[])
The public methods exposed by the AnimateGroup
and AnimateSequence
classes are play
, pause
, finish
, cancel
, and reverse
.
If onFinish: () => void
is provided, onFinish
is called when the animation has completed.
yarn dev-server:react
to view the React examples (localhost:9005).yarn test
to run unit-tests.This system uses the emerging Web Animations API that is not supported in all browsers. To provide the broadest support, we recommend you include the web animations polyfill (use the 'next' version).
The polyfill assumes several global variables exist, and in our experience, it has caused polymorphic JavaScript to fail to compile with tools like TypeScript and Babel. There are also other advantages to CDN files, so we've chosen to take the Web Animations API polyfill as a peer dependency.
Find the polyfill and documentation here.
FAQs
An animation library that simplifies interactions and animations using the Web Animation API.
The npm package @microsoft/fast-animation receives a total of 0 weekly downloads. As such, @microsoft/fast-animation popularity was classified as not popular.
We found that @microsoft/fast-animation demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.