question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Touchable event bug [Android]

See original GitHub issue

Expect

Touchable events to be consistent between android & iOS.

Actual

Android doesn’t render path correctly, when using Android

Reproduce

"react": "16.0.0",
"react-native": "0.50.3",
"react-native-svg": "5.5.1"
import React, { Component } from 'react'
import { View } from 'react-native'
import Svg, { Rect, Path } from 'react-native-svg'

export default class App extends Component<{}> {
  state = {
    isDown: false,
    path: ''
  }

  getCoords(e) {
    const { locationX, locationY } = e.nativeEvent
    const X = parseInt(locationX)
    const Y = parseInt(locationY)

    return `${X},${Y}`
  }

  down(e) {
    this.setState({
      path: `${this.state.path}M${this.getCoords(e)} `,
      isDown: true
    })
  }

  move(e) {
    if (this.state.isDown) {
      this.setState({
        path: `${this.state.path}L${this.getCoords(e)} `
      })
    }
  }

  up() {
    this.setState({
      isDown: false
    })
  }

  render() {
    return (
      <View style={{ flex: 1, width: '100%', height: '100%' }}>
        <View
          onStartShouldSetResponder={() => true}
          onMoveShouldSetResponder={() => true}
          onResponderGrant={this.down.bind(this)}
          onResponderMove={this.move.bind(this)}
          onResponderRelease={this.up.bind(this)}
          style={{ width: '100%', height: '50%', backgroundColor: '#eee' }}
        />
        <Svg style={{ width: '100%', height: '50%' }}>
          <Rect
            fill="#fff"
            width="100%"
            height="100%"
            onPressIn={this.down.bind(this)}
            onResponderMove={this.move.bind(this)}
            onPressOut={this.up.bind(this)}
          />
          <Path
            fill="none"
            stroke="#111"
            strokeWidth="2"
            d={this.state.path}
            strokeMiterLimit="5"
            strokeLinecap="round"
            strokeLinejoin="round"
            pointerEvents={() => 'none'}
          />
        </Svg>
      </View>
    )
  }
}

snack.expo.io

Run the example in IOS, drawing in the top grey area with cursor and note the svg path output in the white area, now try the same in the bottom white area. note (path rendered is consistent).

Now run the example in Android, note the white area path doesn’t render properly, but works in the grey area indicating a bug in react-native-svg touchables.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
msandcommented, Sep 25, 2018

Can you try again with the latest commit from the master branch? I’ve fixed some issues with the gesture responder logic and think this might be fixed as well.

0reactions
msandcommented, Dec 9, 2018

Closing because of inactivity.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Touchable event bug [Android] · Issue #503 - GitHub
Touchable events to be consistent between android & iOS. Actual. Android doesn't render path correctly, when using Android. Reproduce. "react": ...
Read more >
Android Multi-touch event problems...No new ... - Stack Overflow
The problem arises once I started to try and add the ability to touch the top portion of the screen to fire a...
Read more >
Respond to touch events - Android Developers
This lesson shows you how to listen for touch events to let users rotate an OpenGL ES object. Setup a touch listener. In...
Read more >
Touch events not being properly released on Lenovo Horizon ...
Chrome desktop behavior changed in M32 to match Chrome Android (issue 240735). ... This is a bug in the Lenovo touch input driver...
Read more >
Odd Android touch event problem (Nexus 10)
I am not sure if I am understanding this correct, but it seems to me like you answered your own question. I touch...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found