From 1122de907f38b3e74937e51b5f7953f26814bfcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrno=20Ader?= Date: Mon, 1 Apr 2019 14:31:56 +0300 Subject: [PATCH] Create interaction handle during animation This makes the path animation compatible with InteractionManager.runAfterInteractions --- src/animated-path.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/animated-path.js b/src/animated-path.js index bf22d89a..b519a0f7 100644 --- a/src/animated-path.js +++ b/src/animated-path.js @@ -1,4 +1,5 @@ import React, { Component } from 'react' +import { InteractionManager } from 'react-native' import PropTypes from 'prop-types' import { Path } from 'react-native-svg' import * as interpolate from 'd3-interpolate-path' @@ -33,12 +34,16 @@ class AnimatedPath extends Component { componentWillUnmount() { cancelAnimationFrame(this.animation) + this._clearInteraction() } _animate(start) { cancelAnimationFrame(this.animation) this.animation = requestAnimationFrame((timestamp) => { if (!start) { + this._clearInteraction() + this.handle = InteractionManager.createInteractionHandle() + start = timestamp } @@ -50,6 +55,7 @@ class AnimatedPath extends Component { // Just to be safe set our final value to the new graph path. this.component.setNativeProps({ d: this.newD }) // Stop our animation loop. + this._clearInteraction() return } @@ -67,6 +73,13 @@ class AnimatedPath extends Component { }) } + _clearInteraction() { + if (this.handle) { + InteractionManager.clearInteractionHandle(this.handle) + this.handle = null + } + } + render() { return (