AliasIO / Raphael.FreeTransform

Free transform tool for Raphaël elements.
http://elbertf.com
362 stars 107 forks source link

How to use this in reactJs project in componentDidMount(){} methode? #157

Open AnurajRicky opened 6 years ago

beasteers commented 6 years ago

Something like this should work:

import React from "react";
import { Paper, Set, Rect } from 'react-raphael';
import 'Raphael.FreeTransform';

class Rectangle extends React.Component {
    onLoad = (element) => {
        this.transformer = element.paper.freeTransform(element);
    }
    componentWillUnmount() {
        this.transformer.unplug();
    }
    render() {
        return <Rect load={this.onLoad} />;
    }
}
...

You need to use the react-raphael load callback to access the element because it may not be loaded at the time of componentDidMount.

kaleem-elahi commented 4 years ago

@AnurajRicky @beasteers Did this worked ? like importing like that "import 'Raphael.FreeTransform';".

Thanks, do let me know.