8000 Drag function with state · Issue #14 · liuhong1happy/react-raphael · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Drag function with state #14
Open
Open
@l1zard

Description

@l1zard

How to use drag function with state? But when i use on move function i am guessing object will rerender and onmove is fired only once (checked with console.log). How to used it properly?

state = {
    x: 10,
    y: 10
}


 y) => {
    this.setState({x: x, y: y})
}

 dy) => {
    let x = this.state.x;
    let y = this.state.y
    this.setState({x: x + dx, y: y + dy})
}


end = (x, y) => {
    this.setState({x: x, y: y})
}

render() {
    return (
        <div className="design_wrapper">
            <div className="svg_container">
                <Paper width={300} height={300}>
                    <Set>
                        <Circle key={"asdd"} x={this.state.x} y={this.state.y} r={15}
                                attr={{stroke: "#000", fill: "#000"}}
                                drag={{
                                    move: this.onMove,
                                    start: this.onstart,
                                    end: this.end
                                }}/>
                    </Set>
                </Paper>
            </div>
        </div>
    );
}

}`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0