Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

144
Views
React Native: ubicaciones de eventos táctiles en vistas anidadas

Estoy tratando de diseñar un componente deslizante en React Native con el siguiente código (ejemplo mínimo):

 import React from 'react' import {GestureResponderEvent, View} from 'react-native' const Slider = (): JSX.Element => { const [value, setValue] = React.useState() const onTouch = React.useCallback( (e: GestureResponderEvent) => setValue(e.nativeEvent.locationX), [setValue], ) return ( <View key="base" style={{flex: 1, flexDirection: 'row'}} onTouchStart={onTouch} onTouchMove={onTouch}> <View key="track" style={{width: value, backgroundColor: 'white'}}/> <View key="toggle" style={{width: 16, height: 16, borderRadius: 16 / 2, backgroundColor: 'red'}}/> </View> ) }

Tengo problemas porque el siguiente código funciona bien si toco la vista de track , pero no si toco la vista toggle .

Esto parece deberse al hecho de que e.nativeEvent.locationX es un número relativo dentro de la vista de toggle , no la vista base .

¿Alguna sugerencia?

EDITAR: puedo obtener la posición absoluta de los eventos táctiles usando las propiedades e.nativeEvent.pageX y e.nativeEvent.pageY , pero ¿cómo puedo obtener la posición absoluta de la vista base ? La devolución de llamada onLayout solo me da la relativa ...

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!