Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No bounds arg on onDragRelease #61

Open
alexandertsema opened this issue Jun 14, 2020 · 5 comments
Open

No bounds arg on onDragRelease #61

alexandertsema opened this issue Jun 14, 2020 · 5 comments
Labels

Comments

@alexandertsema
Copy link

v3.3.0

@baconcheese113
Copy link
Collaborator

You're not getting a 3rd parameter?

Can you share the relevant code

@tylerablake
Copy link

tylerablake commented Jul 2, 2020

The following code receives the bounds argument in a standard react-native project, but not in an expo project. Same exact code in both projects, and same version in both projects "react-native-draggable": "^3.3.0".

import React, {Component} from 'react';
import {
  Button,
  StyleSheet,
  Image,
  TouchableOpacity,
  Text,
  TextInput,
  View,
} from 'react-native';
import Draggable from 'react-native-draggable';

class App extends Component {
  updatedAnnotations = [];

  state = {
    annotations: [
      {
        id: 1,
        color: 'gray',
        note: 'Bent',
        hidden: false,
        left: 10,
        top: 10,
      },
    ],
  };

  handleDragRelease(annotation, event, gestureState, bounds) {
    console.log(`bounds`, bounds);
  }

  renderCircles() {
    return this.state.annotations.map(annotation => {
      return (
        <Draggable
          key={annotation.id}
          x={Number(annotation.left)}
          y={Number(annotation.top)}
          onDragRelease={(event, gestureState, bounds) =>
            this.handleDragRelease(annotation, event, gestureState, bounds)
          }>
          <View style={styles.circle} />
        </Draggable>
      );
    });
  }

  render() {
    return (
      <View style={styles.container}>
        <Image
          source={{
            uri:
              'https://images-na.ssl-images-amazon.com/images/I/41g8yeF0NWL._AC_SY355_.jpg',
          }}
          style={styles.image}
        />

        <View style={styles.circleSandbox}>{this.renderCircles()}</View>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },
  button: {
    alignItems: 'center',
    backgroundColor: '#DDDDDD',
    padding: 10,
    marginBottom: 10,
  },
  circle: {
    width: 80,
    height: 80,
    borderRadius: 100 / 2,
    borderWidth: 3,
    borderColor: 'red',
  },
  circleNumber: {
    fontSize: 18,
    textAlign: 'center',
  },
  image: {
    width: 405,
    height: 300,
    marginLeft: 5,
  },
  circleSandbox: {
    width: 405,
    height: 300,
    marginLeft: 5,
    marginTop: -300,
  },
});

export default App;

@contention
Copy link

Same issue here with an expo project and 3.3.0

Any fixes for this one yet? Thanks. :o)

@kevinvayro
Copy link

kevinvayro commented Jul 24, 2020

Also experiencing the same running an expo project but if I copy the Draggable code into a fresh file in my project it works as expected.

@kaltoft
Copy link

kaltoft commented Oct 9, 2020

Solution #77

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants