Files
react-native/docs/0.63/animatedvalue.html
2021-03-13 08:44:52 +00:00

52 lines
38 KiB
HTML

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="generator" content="Docusaurus v2.0.0-alpha.70">
<link rel="alternate" type="application/rss+xml" href="/blog/rss.xml" title="React Native Blog RSS Feed">
<link rel="alternate" type="application/atom+xml" href="/blog/atom.xml" title="React Native Blog Atom Feed">
<link rel="preconnect" href="https://www.google-analytics.com">
<script>window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)},ga.l=+new Date,ga("create","UA-41298772-2","auto"),ga("send","pageview")</script>
<script async src="https://www.google-analytics.com/analytics.js"></script>
<link rel="preconnect" href="https://www.google-analytics.com">
<link rel="preconnect" href="https://www.googletagmanager.com">
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-41298772-2"></script>
<script>function gtag(){dataLayer.push(arguments)}window.dataLayer=window.dataLayer||[],gtag("js",new Date),gtag("config","UA-41298772-2",{})</script>
<link rel="search" type="application/opensearchdescription+xml" title="React Native" href="/opensearch.xml">
<link rel="icon" href="/img/pwa/manifest-icon-512.png">
<link rel="manifest" href="/manifest.json">
<meta name="theme-color" content="#20232a">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="#20232a">
<link rel="apple-touch-icon" href="/img/pwa/manifest-icon-512.png">
<link rel="mask-icon" href="/img/pwa/manifest-icon-512.png" color="#06bcee">
<meta name="msapplication-TileImage" href="/img/pwa/manifest-icon-512.png">
<meta name="msapplication-TileColor" content="#20232a">
<script src="https://cdn.jsdelivr.net/npm/focus-visible@5.2.0/dist/focus-visible.min.js" defer="defer"></script>
<script src="https://snack.expo.io/embed.js" defer="defer"></script><title data-react-helmet="true">Animated.Value · React Native</title><meta data-react-helmet="true" name="twitter:image:alt" content="Image for React Native"><meta data-react-helmet="true" name="docsearch:language" content="en"><meta data-react-helmet="true" name="docsearch:version" content="0.63"><meta data-react-helmet="true" name="docsearch:docusaurus_tag" content="docs-default-0.63"><meta data-react-helmet="true" property="og:image" content="https://reactnative.dev/img/logo-og.png"><meta data-react-helmet="true" name="twitter:card" content="summary"><meta data-react-helmet="true" name="twitter:image" content="https://reactnative.dev/img/logo-og.png"><meta data-react-helmet="true" property="og:title" content="Animated.Value · React Native"><meta data-react-helmet="true" name="description" content="Standard value for driving animations. One Animated.Value can drive multiple properties in a synchronized fashion, but can only be driven by one mechanism at a time. Using a new mechanism (e.g. starting a new animation, or calling setValue) will stop any previous ones."><meta data-react-helmet="true" property="og:description" content="Standard value for driving animations. One Animated.Value can drive multiple properties in a synchronized fashion, but can only be driven by one mechanism at a time. Using a new mechanism (e.g. starting a new animation, or calling setValue) will stop any previous ones."><meta data-react-helmet="true" property="og:url" content="https://reactnative.dev/docs/0.63/animatedvalue"><link data-react-helmet="true" rel="shortcut icon" href="/img/favicon.ico"><link data-react-helmet="true" rel="preconnect" href="https://BH4D9OD16A-dsn.algolia.net" crossorigin="anonymous"><link data-react-helmet="true" rel="canonical" href="https://reactnative.dev/docs/0.63/animatedvalue"><link rel="stylesheet" href="/styles.f56da522.css">
<link rel="stylesheet" href="/main.3de2b5ef.css">
<link rel="preload" href="/styles.9d29dd5a.js" as="script">
<link rel="preload" href="/runtime~main.b00a5634.js" as="script">
<link rel="preload" href="/main.4103a08e.js" as="script">
<link rel="preload" href="/1.7a6193e2.js" as="script">
<link rel="preload" href="/2.9b40dc51.js" as="script">
<link rel="preload" href="/1089.caa7a648.js" as="script">
<link rel="preload" href="/ee5b3385.34621f56.js" as="script">
<link rel="preload" href="/17896441.b54b3e3c.js" as="script">
<link rel="preload" href="/21e9f77a.93e8c895.js" as="script">
</head>
<body>
<script>!function(){function t(t){document.documentElement.setAttribute("data-theme",t)}var e=function(){var t=null;try{t=localStorage.getItem("theme")}catch(t){}return t}();t(null!==e?e:"light")}()</script><div id="__docusaurus">
<nav aria-label="Skip navigation links"><button type="button" tabindex="0" class="skipToContent_3aLp">Skip to main content</button></nav><nav class="navbar navbar--fixed-top navbar--dark"><div class="navbar__inner"><div class="navbar__items"><div aria-label="Navigation bar toggle" class="navbar__toggle" role="button" tabindex="0"><svg aria-label="Menu" width="30" height="30" viewBox="0 0 30 30" role="img" focusable="false"><title>Menu</title><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></div><a class="navbar__brand" href="/"><img src="/img/header_logo.svg" alt="React Native" class="themedImage_phiS themedImage--light_VJaY navbar__logo"><img src="/img/header_logo.svg" alt="React Native" class="themedImage_phiS themedImage--dark_1NF3 navbar__logo"><strong class="navbar__title">React Native</strong></a><div class="navbar__item dropdown dropdown--hoverable dropdown--left"><a class="navbar__item navbar__link" href="/docs/0.63/getting-started">0.63</a><ul class="dropdown__menu"><li><a class="dropdown__link" href="/docs/next/animatedvalue">Next</a></li><li><a class="dropdown__link" href="/docs/animatedvalue">0.64</a></li><li><a aria-current="page" class="dropdown__link dropdown__link--active" href="/docs/0.63/animatedvalue">0.63</a></li><li><a class="dropdown__link" href="/docs/0.62/animatedvalue">0.62</a></li><li><a class="dropdown__link" href="/docs/0.61/animatedvalue">0.61</a></li><li><a class="dropdown__link" href="/docs/0.60/animatedvalue">0.60</a></li><li><a class="dropdown__link" href="/versions">All versions</a></li></ul></div></div><div class="navbar__items navbar__items--right"><a class="navbar__item navbar__link" href="/docs/0.63/getting-started">Docs</a><a class="navbar__item navbar__link" href="/docs/0.63/components-and-apis">Components</a><a class="navbar__item navbar__link navbar__link--active" href="/docs/0.63/accessibilityinfo">API</a><a class="navbar__item navbar__link" href="/help">Community</a><a class="navbar__item navbar__link" href="/blog">Blog</a><a href="https://github.com/facebook/react-native" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link navbar-github-link" aria-label="GitHub repository"></a><div class="react-toggle react-toggle--disabled displayOnlyInLargeViewport_Bh6k"><div class="react-toggle-track"><div class="react-toggle-track-check"><span class="toggle_1UDy">🌜</span></div><div class="react-toggle-track-x"><span class="toggle_1UDy">🌞</span></div></div><div class="react-toggle-thumb"></div><input type="checkbox" disabled="" aria-label="Dark mode toggle" class="react-toggle-screenreader-only"></div><button type="button" class="DocSearch DocSearch-Button" aria-label="Search"><span class="DocSearch-Button-Container"><svg width="20" height="20" class="DocSearch-Search-Icon" viewBox="0 0 20 20"><path d="M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z" stroke="currentColor" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"></path></svg><span class="DocSearch-Button-Placeholder">Search</span></span></button></div></div><div role="presentation" class="navbar-sidebar__backdrop"></div><div class="navbar-sidebar"><div class="navbar-sidebar__brand"><a class="navbar__brand" href="/"><img src="/img/header_logo.svg" alt="React Native" class="themedImage_phiS themedImage--light_VJaY navbar__logo"><img src="/img/header_logo.svg" alt="React Native" class="themedImage_phiS themedImage--dark_1NF3 navbar__logo"><strong class="navbar__title">React Native</strong></a></div><div class="navbar-sidebar__items"><div class="menu"><ul class="menu__list"><li class="menu__list-item"><a class="menu__link" href="/docs/0.63/getting-started">Docs</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/0.63/components-and-apis">Components</a></li><li class="menu__list-item"><a class="menu__link navbar__link--active" href="/docs/0.63/accessibilityinfo">API</a></li><li class="menu__list-item"><a class="menu__link" href="/help">Community</a></li><li class="menu__list-item"><a class="menu__link" href="/blog">Blog</a></li><li class="menu__list-item"><a role="button" class="menu__link menu__link--sublist">Versions</a><ul class="menu__list"><li class="menu__list-item"><a class="menu__link" href="/docs/next/animatedvalue">Next</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/animatedvalue">0.64</a></li><li class="menu__list-item"><a aria-current="page" class="menu__link menu__link--active" href="/docs/0.63/animatedvalue">0.63</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/0.62/animatedvalue">0.62</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/0.61/animatedvalue">0.61</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/0.60/animatedvalue">0.60</a></li><li class="menu__list-item"><a class="menu__link" href="/versions">All versions</a></li></ul></li><li class="menu__list-item"><a href="https://github.com/facebook/react-native" target="_blank" rel="noopener noreferrer" class="menu__link navbar-github-link" aria-label="GitHub repository"></a></li></ul></div></div></div></nav><div class="main-wrapper"><div class="docPage_1mVJ"><div class="docSidebarContainer_uPTz" role="complementary"><div class="sidebar_M-Lc"><div class="menu menu--responsive thin-scrollbar menu_tgpy"><button aria-label="Open Menu" aria-haspopup="true" class="button button--secondary button--sm menu__button" type="button"><svg aria-label="Menu" class="sidebarMenuIcon_1e05" width="24" height="24" viewBox="0 0 30 30" role="img" focusable="false"><title>Menu</title><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></button><ul class="menu__list"><li class="menu__list-item"><a class="menu__link menu__link--sublist menu__link--active" href="#!">APIs</a><ul class="menu__list"><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/0.63/accessibilityinfo">AccessibilityInfo</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/0.63/alert">Alert</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/0.63/animated">Animated</a></li><li class="menu__list-item"><a aria-current="page" class="menu__link menu__link--active active" tabindex="0" href="/docs/0.63/animatedvalue">Animated.Value</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/0.63/animatedvaluexy">Animated.ValueXY</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/0.63/appearance">Appearance</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/0.63/appregistry">AppRegistry</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/0.63/appstate">AppState</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/0.63/devsettings">DevSettings</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/0.63/dimensions">Dimensions</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/0.63/easing">Easing</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/0.63/interactionmanager">InteractionManager</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/0.63/keyboard">Keyboard</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/0.63/layoutanimation">LayoutAnimation</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/0.63/linking">Linking</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/0.63/panresponder">PanResponder</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/0.63/pixelratio">PixelRatio</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/0.63/platform">Platform</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/0.63/platformcolor">PlatformColor</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/0.63/share">Share</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/0.63/stylesheet">StyleSheet</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/0.63/systrace">Systrace</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/0.63/transforms">Transforms</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/0.63/vibration">Vibration</a></li><li class="menu__list-item"><a class="menu__link menu__link--sublist" href="#!" tabindex="0">Hooks</a><ul class="menu__list"><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/0.63/usecolorscheme">useColorScheme</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/0.63/usewindowdimensions">useWindowDimensions</a></li></ul></li><li class="menu__list-item"><a class="menu__link menu__link--sublist" href="#!" tabindex="0">Android APIs</a><ul class="menu__list"><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/0.63/backhandler">BackHandler</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/0.63/permissionsandroid">PermissionsAndroid</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/0.63/toastandroid">ToastAndroid</a></li></ul></li><li class="menu__list-item"><a class="menu__link menu__link--sublist" href="#!" tabindex="0">iOS APIs</a><ul class="menu__list"><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/0.63/actionsheetios">ActionSheetIOS</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/0.63/dynamiccolorios">DynamicColorIOS</a></li><li class="menu__list-item"><a class="menu__link" tabindex="0" href="/docs/0.63/settings">Settings</a></li></ul></li></ul></li></ul></div></div></div><main class="docMainContainer_1zi2"><div class="container padding-vert--lg docItemWrapper_1hMI"><div class="row"><div class="col docItemCol_2AGf"><div class="alert alert--warning margin-bottom--md" role="alert"><div>This is documentation for React Native <strong>0.63</strong>, which is no longer actively maintained.</div><div class="margin-top--md">For up-to-date documentation, see the <strong><a href="/docs/animatedvalue">latest version</a></strong> (0.64).</div></div><div class="docItemContainer_1tAC"><article><div><span class="badge badge--secondary">Version: 0.63</span></div><header><h1 class="docTitle_cWlf">Animated.Value</h1></header><div class="markdown"><p>Standard value for driving animations. One <code>Animated.Value</code> can drive multiple properties in a synchronized fashion, but can only be driven by one mechanism at a time. Using a new mechanism (e.g. starting a new animation, or calling <code>setValue</code>) will stop any previous ones.</p><p>Typically initialized with <code>new Animated.Value(0);</code></p><hr><h1><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_E4oP" id="reference"></a>Reference<a class="hash-link" href="#reference" title="Direct link to heading">#</a></h1><h2><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_E4oP" id="methods"></a>Methods<a class="hash-link" href="#methods" title="Direct link to heading">#</a></h2><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_E4oP" id="setvalue"></a><code>setValue()</code><a class="hash-link" href="#setvalue" title="Direct link to heading">#</a></h3><div class="mdxCodeBlock_1daz"><div class="codeBlockContent_2es_"><div tabindex="0" class="prism-code language-jsx codeBlock_27aQ thin-scrollbar"><div class="codeBlockLines_2rCb" style="color:#FFFFFF;background:#282C34"><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token function" style="color:#79b6f2">setValue</span><span class="token punctuation" style="color:#657b83">(</span><span class="token plain">value</span><span class="token punctuation" style="color:#657b83">)</span><span class="token punctuation" style="color:#657b83">;</span></div></div></div><button type="button" aria-label="Copy code to clipboard" class="copyButton_2bml">Copy</button></div></div><p>Directly set the value. This will stop any animations running on the value and update all the bound properties.</p><p><strong>Parameters:</strong></p><table><thead><tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>value</td><td>number</td><td>Yes</td><td>Value</td></tr></tbody></table><hr><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_E4oP" id="setoffset"></a><code>setOffset()</code><a class="hash-link" href="#setoffset" title="Direct link to heading">#</a></h3><div class="mdxCodeBlock_1daz"><div class="codeBlockContent_2es_"><div tabindex="0" class="prism-code language-jsx codeBlock_27aQ thin-scrollbar"><div class="codeBlockLines_2rCb" style="color:#FFFFFF;background:#282C34"><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token function" style="color:#79b6f2">setOffset</span><span class="token punctuation" style="color:#657b83">(</span><span class="token plain">offset</span><span class="token punctuation" style="color:#657b83">)</span><span class="token punctuation" style="color:#657b83">;</span></div></div></div><button type="button" aria-label="Copy code to clipboard" class="copyButton_2bml">Copy</button></div></div><p>Sets an offset that is applied on top of whatever value is set, whether via <code>setValue</code>, an animation, or <code>Animated.event</code>. Useful for compensating things like the start of a pan gesture.</p><p><strong>Parameters:</strong></p><table><thead><tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>offset</td><td>number</td><td>Yes</td><td>Offset value</td></tr></tbody></table><hr><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_E4oP" id="flattenoffset"></a><code>flattenOffset()</code><a class="hash-link" href="#flattenoffset" title="Direct link to heading">#</a></h3><div class="mdxCodeBlock_1daz"><div class="codeBlockContent_2es_"><div tabindex="0" class="prism-code language-jsx codeBlock_27aQ thin-scrollbar"><div class="codeBlockLines_2rCb" style="color:#FFFFFF;background:#282C34"><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token function" style="color:#79b6f2">flattenOffset</span><span class="token punctuation" style="color:#657b83">(</span><span class="token punctuation" style="color:#657b83">)</span><span class="token punctuation" style="color:#657b83">;</span></div></div></div><button type="button" aria-label="Copy code to clipboard" class="copyButton_2bml">Copy</button></div></div><p>Merges the offset value into the base value and resets the offset to zero. The final output of the value is unchanged.</p><hr><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_E4oP" id="extractoffset"></a><code>extractOffset()</code><a class="hash-link" href="#extractoffset" title="Direct link to heading">#</a></h3><div class="mdxCodeBlock_1daz"><div class="codeBlockContent_2es_"><div tabindex="0" class="prism-code language-jsx codeBlock_27aQ thin-scrollbar"><div class="codeBlockLines_2rCb" style="color:#FFFFFF;background:#282C34"><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token function" style="color:#79b6f2">extractOffset</span><span class="token punctuation" style="color:#657b83">(</span><span class="token punctuation" style="color:#657b83">)</span><span class="token punctuation" style="color:#657b83">;</span></div></div></div><button type="button" aria-label="Copy code to clipboard" class="copyButton_2bml">Copy</button></div></div><p>Sets the offset value to the base value, and resets the base value to zero. The final output of the value is unchanged.</p><hr><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_E4oP" id="addlistener"></a><code>addListener()</code><a class="hash-link" href="#addlistener" title="Direct link to heading">#</a></h3><div class="mdxCodeBlock_1daz"><div class="codeBlockContent_2es_"><div tabindex="0" class="prism-code language-jsx codeBlock_27aQ thin-scrollbar"><div class="codeBlockLines_2rCb" style="color:#FFFFFF;background:#282C34"><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token function" style="color:#79b6f2">addListener</span><span class="token punctuation" style="color:#657b83">(</span><span class="token plain">callback</span><span class="token punctuation" style="color:#657b83">)</span><span class="token punctuation" style="color:#657b83">;</span></div></div></div><button type="button" aria-label="Copy code to clipboard" class="copyButton_2bml">Copy</button></div></div><p>Adds an asynchronous listener to the value so you can observe updates from animations. This is useful because there is no way to synchronously read the value because it might be driven natively.</p><p>Returns a string that serves as an identifier for the listener.</p><p><strong>Parameters:</strong></p><table><thead><tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>callback</td><td>function</td><td>Yes</td><td>The callback function which will receive an object with a <code>value</code> key set to the new value.</td></tr></tbody></table><hr><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_E4oP" id="removelistener"></a><code>removeListener()</code><a class="hash-link" href="#removelistener" title="Direct link to heading">#</a></h3><div class="mdxCodeBlock_1daz"><div class="codeBlockContent_2es_"><div tabindex="0" class="prism-code language-jsx codeBlock_27aQ thin-scrollbar"><div class="codeBlockLines_2rCb" style="color:#FFFFFF;background:#282C34"><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token function" style="color:#79b6f2">removeListener</span><span class="token punctuation" style="color:#657b83">(</span><span class="token plain">id</span><span class="token punctuation" style="color:#657b83">)</span><span class="token punctuation" style="color:#657b83">;</span></div></div></div><button type="button" aria-label="Copy code to clipboard" class="copyButton_2bml">Copy</button></div></div><p>Unregister a listener. The <code>id</code> param shall match the identifier previously returned by <code>addListener()</code>.</p><p><strong>Parameters:</strong></p><table><thead><tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>id</td><td>string</td><td>Yes</td><td>Id for the listener being removed.</td></tr></tbody></table><hr><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_E4oP" id="removealllisteners"></a><code>removeAllListeners()</code><a class="hash-link" href="#removealllisteners" title="Direct link to heading">#</a></h3><div class="mdxCodeBlock_1daz"><div class="codeBlockContent_2es_"><div tabindex="0" class="prism-code language-jsx codeBlock_27aQ thin-scrollbar"><div class="codeBlockLines_2rCb" style="color:#FFFFFF;background:#282C34"><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token function" style="color:#79b6f2">removeAllListeners</span><span class="token punctuation" style="color:#657b83">(</span><span class="token punctuation" style="color:#657b83">)</span><span class="token punctuation" style="color:#657b83">;</span></div></div></div><button type="button" aria-label="Copy code to clipboard" class="copyButton_2bml">Copy</button></div></div><p>Remove all registered listeners.</p><hr><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_E4oP" id="stopanimation"></a><code>stopAnimation()</code><a class="hash-link" href="#stopanimation" title="Direct link to heading">#</a></h3><div class="mdxCodeBlock_1daz"><div class="codeBlockContent_2es_"><div tabindex="0" class="prism-code language-jsx codeBlock_27aQ thin-scrollbar"><div class="codeBlockLines_2rCb" style="color:#FFFFFF;background:#282C34"><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token function" style="color:#79b6f2">stopAnimation</span><span class="token punctuation" style="color:#657b83">(</span><span class="token punctuation" style="color:#657b83">[</span><span class="token plain">callback</span><span class="token punctuation" style="color:#657b83">]</span><span class="token punctuation" style="color:#657b83">)</span><span class="token punctuation" style="color:#657b83">;</span></div></div></div><button type="button" aria-label="Copy code to clipboard" class="copyButton_2bml">Copy</button></div></div><p>Stops any running animation or tracking. <code>callback</code> is invoked with the final value after stopping the animation, which is useful for updating state to match the animation position with layout.</p><p><strong>Parameters:</strong></p><table><thead><tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>callback</td><td>function</td><td>No</td><td>A function that will receive the final value.</td></tr></tbody></table><hr><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_E4oP" id="resetanimation"></a><code>resetAnimation()</code><a class="hash-link" href="#resetanimation" title="Direct link to heading">#</a></h3><div class="mdxCodeBlock_1daz"><div class="codeBlockContent_2es_"><div tabindex="0" class="prism-code language-jsx codeBlock_27aQ thin-scrollbar"><div class="codeBlockLines_2rCb" style="color:#FFFFFF;background:#282C34"><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token function" style="color:#79b6f2">resetAnimation</span><span class="token punctuation" style="color:#657b83">(</span><span class="token punctuation" style="color:#657b83">[</span><span class="token plain">callback</span><span class="token punctuation" style="color:#657b83">]</span><span class="token punctuation" style="color:#657b83">)</span><span class="token punctuation" style="color:#657b83">;</span></div></div></div><button type="button" aria-label="Copy code to clipboard" class="copyButton_2bml">Copy</button></div></div><p>Stops any animation and resets the value to its original.</p><p><strong>Parameters:</strong></p><table><thead><tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>callback</td><td>function</td><td>No</td><td>A function that will receive the original value.</td></tr></tbody></table><hr><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_E4oP" id="interpolate"></a><code>interpolate()</code><a class="hash-link" href="#interpolate" title="Direct link to heading">#</a></h3><div class="mdxCodeBlock_1daz"><div class="codeBlockContent_2es_"><div tabindex="0" class="prism-code language-jsx codeBlock_27aQ thin-scrollbar"><div class="codeBlockLines_2rCb" style="color:#FFFFFF;background:#282C34"><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token function" style="color:#79b6f2">interpolate</span><span class="token punctuation" style="color:#657b83">(</span><span class="token plain">config</span><span class="token punctuation" style="color:#657b83">)</span><span class="token punctuation" style="color:#657b83">;</span></div></div></div><button type="button" aria-label="Copy code to clipboard" class="copyButton_2bml">Copy</button></div></div><p>Interpolates the value before updating the property, e.g. mapping 0-1 to 0-10.</p><p>See <code>AnimatedInterpolation.js</code></p><p><strong>Parameters:</strong></p><table><thead><tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>config</td><td>object</td><td>Yes</td><td>See below.</td></tr></tbody></table><p>The <code>config</code> object is composed of the following keys:</p><ul><li><code>inputRange</code>: an array of numbers</li><li><code>outputRange</code>: an array of numbers or strings</li><li><code>easing</code> (optional): a function that returns a number, given an input number</li><li><code>extrapolate</code> (optional): a string such as &#x27;extend&#x27;, &#x27;identity&#x27;, or &#x27;clamp&#x27;</li><li><code>extrapolateLeft</code> (optional): a string such as &#x27;extend&#x27;, &#x27;identity&#x27;, or &#x27;clamp&#x27;</li><li><code>extrapolateRight</code> (optional): a string such as &#x27;extend&#x27;, &#x27;identity&#x27;, or &#x27;clamp&#x27;</li></ul><hr><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_E4oP" id="animate"></a><code>animate()</code><a class="hash-link" href="#animate" title="Direct link to heading">#</a></h3><div class="mdxCodeBlock_1daz"><div class="codeBlockContent_2es_"><div tabindex="0" class="prism-code language-jsx codeBlock_27aQ thin-scrollbar"><div class="codeBlockLines_2rCb" style="color:#FFFFFF;background:#282C34"><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token function" style="color:#79b6f2">animate</span><span class="token punctuation" style="color:#657b83">(</span><span class="token plain">animation</span><span class="token punctuation" style="color:#657b83">,</span><span class="token plain"> callback</span><span class="token punctuation" style="color:#657b83">)</span><span class="token punctuation" style="color:#657b83">;</span></div></div></div><button type="button" aria-label="Copy code to clipboard" class="copyButton_2bml">Copy</button></div></div><p>Typically only used internally, but could be used by a custom Animation class.</p><p><strong>Parameters:</strong></p><table><thead><tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>animation</td><td>Animation</td><td>Yes</td><td>See <code>Animation.js</code>.</td></tr><tr><td>callback</td><td>function</td><td>Yes</td><td>Callback function.</td></tr></tbody></table><hr><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_E4oP" id="stoptracking"></a><code>stopTracking()</code><a class="hash-link" href="#stoptracking" title="Direct link to heading">#</a></h3><div class="mdxCodeBlock_1daz"><div class="codeBlockContent_2es_"><div tabindex="0" class="prism-code language-jsx codeBlock_27aQ thin-scrollbar"><div class="codeBlockLines_2rCb" style="color:#FFFFFF;background:#282C34"><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token function" style="color:#79b6f2">stopTracking</span><span class="token punctuation" style="color:#657b83">(</span><span class="token punctuation" style="color:#657b83">)</span><span class="token punctuation" style="color:#657b83">;</span></div></div></div><button type="button" aria-label="Copy code to clipboard" class="copyButton_2bml">Copy</button></div></div><p>Typically only used internally.</p><hr><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_E4oP" id="track"></a><code>track()</code><a class="hash-link" href="#track" title="Direct link to heading">#</a></h3><div class="mdxCodeBlock_1daz"><div class="codeBlockContent_2es_"><div tabindex="0" class="prism-code language-jsx codeBlock_27aQ thin-scrollbar"><div class="codeBlockLines_2rCb" style="color:#FFFFFF;background:#282C34"><div class="token-line" style="color:#FFFFFF;background:#282C34"><span class="token function" style="color:#79b6f2">track</span><span class="token punctuation" style="color:#657b83">(</span><span class="token plain">tracking</span><span class="token punctuation" style="color:#657b83">)</span><span class="token punctuation" style="color:#657b83">;</span></div></div></div><button type="button" aria-label="Copy code to clipboard" class="copyButton_2bml">Copy</button></div></div><p>Typically only used internally.</p><p><strong>Parameters:</strong></p><table><thead><tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td>tracking</td><td>AnimatedNode</td><td>Yes</td><td>See <code>AnimatedNode.js</code></td></tr></tbody></table></div></article><div class="docMetadata margin-vert--xl"><div class="row"><div class="col"><a href="https://github.com/facebook/react-native-website/blob/master/website/versioned_docs/version-0.63/animatedvalue.md" target="_blank" rel="noreferrer noopener"><svg fill="currentColor" height="1.2em" width="1.2em" preserveAspectRatio="xMidYMid meet" role="img" viewBox="0 0 40 40" class="iconEdit_2Hwv"><g><path d="m34.5 11.7l-3 3.1-6.3-6.3 3.1-3q0.5-0.5 1.2-0.5t1.1 0.5l3.9 3.9q0.5 0.4 0.5 1.1t-0.5 1.2z m-29.5 17.1l18.4-18.5 6.3 6.3-18.4 18.4h-6.3v-6.2z"></path></g></svg>Edit this page</a></div><div class="col text--right"><em><small class="docMetadata-updated">Last updated on <time datetime="2020-10-29T04:19:29.000Z" class="docLastUpdatedAt_1gIo">10/29/2020</time></small></em></div></div></div><div class="margin-vert--lg"><nav class="pagination-nav" aria-label="Blog list page navigation"><div class="pagination-nav__item"><a class="pagination-nav__link" href="/docs/0.63/animated"><div class="pagination-nav__sublabel">Previous</div><div class="pagination-nav__label">« Animated</div></a></div><div class="pagination-nav__item pagination-nav__item--next"><a class="pagination-nav__link" href="/docs/0.63/animatedvaluexy"><div class="pagination-nav__sublabel">Next</div><div class="pagination-nav__label">Animated.ValueXY »</div></a></div></nav></div></div></div><div class="col col--3"><div class="tableOfContents_1zTD thin-scrollbar"><ul class="table-of-contents table-of-contents__left-border"><li><a href="#methods" class="table-of-contents__link">Methods</a><ul><li><a href="#setvalue" class="table-of-contents__link"><code>setValue()</code></a></li><li><a href="#setoffset" class="table-of-contents__link"><code>setOffset()</code></a></li><li><a href="#flattenoffset" class="table-of-contents__link"><code>flattenOffset()</code></a></li><li><a href="#extractoffset" class="table-of-contents__link"><code>extractOffset()</code></a></li><li><a href="#addlistener" class="table-of-contents__link"><code>addListener()</code></a></li><li><a href="#removelistener" class="table-of-contents__link"><code>removeListener()</code></a></li><li><a href="#removealllisteners" class="table-of-contents__link"><code>removeAllListeners()</code></a></li><li><a href="#stopanimation" class="table-of-contents__link"><code>stopAnimation()</code></a></li><li><a href="#resetanimation" class="table-of-contents__link"><code>resetAnimation()</code></a></li><li><a href="#interpolate" class="table-of-contents__link"><code>interpolate()</code></a></li><li><a href="#animate" class="table-of-contents__link"><code>animate()</code></a></li><li><a href="#stoptracking" class="table-of-contents__link"><code>stopTracking()</code></a></li><li><a href="#track" class="table-of-contents__link"><code>track()</code></a></li></ul></li></ul></div></div></div></div></main></div></div><footer class="footer footer--dark"><div class="container"><div class="row footer__links"><div class="col footer__col"><h4 class="footer__title">Docs</h4><ul class="footer__items"><li class="footer__item"><a class="footer__link-item" href="/docs/getting-started">Getting Started</a></li><li class="footer__item"><a class="footer__link-item" href="/docs/tutorial">Tutorial</a></li><li class="footer__item"><a class="footer__link-item" href="/docs/components-and-apis">Components and APIs</a></li><li class="footer__item"><a class="footer__link-item" href="/docs/more-resources">More Resources</a></li></ul></div><div class="col footer__col"><h4 class="footer__title">Community</h4><ul class="footer__items"><li class="footer__item"><a class="footer__link-item" href="/help">The React Native Community</a></li><li class="footer__item"><a class="footer__link-item" href="/showcase">Who&#x27;s using React Native?</a></li><li class="footer__item"><a href="https://stackoverflow.com/questions/tagged/react-native" target="_blank" rel="noopener noreferrer" class="footer__link-item">Ask Questions on Stack Overflow</a></li><li class="footer__item"><a href="https://github.com/facebook/react-native/blob/master/CONTRIBUTING.md" target="_blank" rel="noopener noreferrer" class="footer__link-item">Contributor Guide</a></li><li class="footer__item"><a href="https://dev.to/t/reactnative" target="_blank" rel="noopener noreferrer" class="footer__link-item">DEV Community</a></li></ul></div><div class="col footer__col"><h4 class="footer__title">Find us</h4><ul class="footer__items"><li class="footer__item"><a class="footer__link-item" href="/blog">Blog</a></li><li class="footer__item"><a href="https://twitter.com/reactnative" target="_blank" rel="noopener noreferrer" class="footer__link-item">Twitter</a></li><li class="footer__item"><a href="https://github.com/facebook/react-native" target="_blank" rel="noopener noreferrer" class="footer__link-item">GitHub</a></li></ul></div><div class="col footer__col"><h4 class="footer__title">More</h4><ul class="footer__items"><li class="footer__item"><a href="https://reactjs.org/" target="_blank" rel="noopener noreferrer" class="footer__link-item">React</a></li><li class="footer__item"><a href="https://opensource.facebook.com/legal/privacy" target="_blank" rel="noopener noreferrer" class="footer__link-item">Privacy Policy</a></li><li class="footer__item"><a href="https://opensource.facebook.com/legal/terms" target="_blank" rel="noopener noreferrer" class="footer__link-item">Terms of Service</a></li></ul></div></div><div class="footer__bottom text--center"><div class="margin-bottom--sm"><a href="https://opensource.facebook.com" target="_blank" rel="noopener noreferrer" class="footerLogoLink_3cAK"><img class="footer__logo" alt="Facebook Open Source Logo" src="/img/oss_logo.png"></a></div><div class="footer__copyright">Copyright © 2021 Facebook, Inc.</div></div></div></footer></div>
<script src="/styles.9d29dd5a.js"></script>
<script src="/runtime~main.b00a5634.js"></script>
<script src="/main.4103a08e.js"></script>
<script src="/1.7a6193e2.js"></script>
<script src="/2.9b40dc51.js"></script>
<script src="/1089.caa7a648.js"></script>
<script src="/ee5b3385.34621f56.js"></script>
<script src="/17896441.b54b3e3c.js"></script>
<script src="/21e9f77a.93e8c895.js"></script>
</body>
</html>