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

198
Views
Cómo obtener la posición de un elemento en movimiento en React Native

Actualmente estoy tratando de desarrollar una aplicación con elementos arrastrables usando React Native y la biblioteca react Native arrastrable ( https://www.npmjs.com/package/react-native-draggable ).

Mi objetivo es obtener la posición de mi elemento arrastrable. (Para que pueda cambiar su color dependiendo de dónde se encuentre en la pantalla).

Probé un método diferente pero nada funcionó para mí. Aquí está lo último que probé:

 return ( <View> <Draggable onDragRelease={event => {const layout = event.nativeEvent.layout; console.log('x:', layout.x); console.log('y:', layout.y); } } x={positionX} y={positionY} renderSize={56} renderColor='#BDFF00' renderText={'Drag me'} // onDrag={getPosition} /> </View> )

El código anterior devuelve este error ( TypeError: undefined is not an object (evaluating 'layout.x' ))

También traté de hacer esto:

 const getPosition = (event) => { console.log(event.locationX) setPositionX(event.locationX) setPositionY(event.locationY) }; const changerColorFunction = () => { } return ( <View> <Draggable x={positionX} y={positionY} renderSize={56} renderColor='#BDFF00' renderText={'Drag me'} onDrag={getPosition} /> </View> )

Basado en la documentación Draggable nativa de reacción, pero tampoco funciona. Creo que no entendí completamente cómo debería funcionar. Cualquier ayuda sería genial.

about 4 years ago · Santiago Trujillo
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!