React化raphael

#1

地址:


使用方式:

window.React = require('react');
window.ReactDOM = require('react-dom');
window.Raphael = require('raphael');

const {Raphael,Paper,Set,Circle,Ellipse,Image,Rect,Text,Path} = require('react-raphael');

class App extends React.Component{
    render(){
        var data = [
            {x:50,y:50,r:40,attr:{"stroke":"#0b8ac9","stroke-width":5},animate:Raphael.animation({cx:60},500,"<>")},
            {x:100,y:100,r:40,attr:{"stroke":"#f0c620","stroke-width":5},animate:Raphael.animation({cx:105},500,"<>")},
            {x:150,y:50,r:40,attr:{"stroke":"#1a1a1a","stroke-width":5}},
            {x:200,y:100,r:40,attr:{"stroke":"#10a54a","stroke-width":5},animate:Raphael.animation({cx:195},500,"<>")},
            {x:250,y:50,r:40,attr:{"stroke":"#e11032","stroke-width":5},animate:Raphael.animation({cx:240},500,"<>")}
        ]
        return (<Paper width={300} height={300}>
                       <Set>    
                        {
                            data.map(function(ele,pos){
                                return (<Circle key={pos} x={ele.x} y={ele.y} r={ele.r} attr={ele.attr} animate={ele.animate}/>)
                            })
                        }
                        </Set>
                        <Set>
                            <Rect x={30} y={148} width={240} height={150} attr={{"fill":"#10a54a","stroke":"#f0c620","stroke-width":5}}/>
                            <Ellipse x={150} y={200} ry={40} rx={100} attr={{"fill":"#fff","stroke":"#e11032"}} glow={{width:100,fill:true,color:"#e11032",opacity:1}}/>
                            <Image src="/static/images/5circle.png" x={100} y={170} width={90} height={60} />
                            <Text x={150} y={250} text="同一个世界 同一个梦想" attr={{"fill":"#fff"}}/>
                            <Text x={150} y={270} text="One World One Dream" attr={{"fill":"#fff"}}/>
                            <Path d={["M80 290L220 290"]} attr={{"stroke":"#fff"}}/>
                        </Set>
                </Paper>)
    }
}

使用效果:

#2

0.4.0 版本发布

  1. 众多功能趋于稳定
  2. 新增中国地图示例
#3

0.6.0 版本发布

  1. 众多功能趋于稳定
  2. 新增图表插件react-raphael-chart
  3. 新增Line组件
  4. 新增部分props
#4

0.7.1 版本发布

  1. 新增Paper的props: container
  2. 新增Element的props: update
  3. 修复Path animiate构建动画的错误
  4. 持续跟踪 raphael #491 bug造成的tspan的dy和text的y相同的问题
#5

准备长期维护版本0.8.x

  1. 全面覆盖所有element props测试
  2. 支持ie8浏览器
  3. 修复transform和matrix bug
  4. 修复移除element bug
  5. 新增更多react-raphael示例
  6. 新增更多依赖react-raphael的组件
  1. 尝试取消element(Set除外)仍然需要渲染空div的情况,使用null替代。
#6

欢迎大家更多的使用react-raphael。
发现问题过后及时告知(提issue)。
版本稳定过后,会准备发布1.0.x版本。

#7

元宵节快乐

#8

@liuhong1happy I wanted to use this lib dynamiacally. is there any way to use it all events and dragging and all with this olib dynamically ?