Obtener el valor actual de Animado.Valor, React-native
Estoy tratando de animar la vista con interpolar. Me gustaría obtener un valor actual de mi Animación.Valor, pero no sé cómo. No entendía cómo hacerlo con React-native docs .
this.state = {
translateAnim: new Animated.Value(0)
}
DeviceEventEmitter.addListener('Accelerometer', function (data) {
console.log(this.state.translateAnim);
// returns an object, but I need a value in current moment
}
27
3 answers
Me entero, cómo obtener un valor:
this.state.translateAnim.addListener(({value}) => this._value = value);
EDITAR
Para registrar un valor hago lo siguiente:
console.log(this.state.translateAnim._value)
43
Author: Evgeny Kuznetsov,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-05-02 12:16:15
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-05-02 12:16:15
No tengo reputación para agregar un comentario, pero para las personas con typscript.
console.log((this.state.translateAnim as any)._value);
Funcionó para mí para completar tsc como cualquiera.
5
Author: A Bordonado,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-05-02 11:49:03
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-05-02 11:49:03
Esto también funciona para mí...
const headerHeight = new Animated.Value(0);
Después de alguna manipulación....
console.log(headerHeight.__getValue())
Se siente hackish pero hace el trabajo...
5
Author: moQuez,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-05-02 12:35:59
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-05-02 12:35:59