1
0
mirror of https://github.com/Pomax/BezierInfo-2.git synced 2025-08-29 02:59:58 +02:00

curve moulding

This commit is contained in:
Pomax
2016-01-06 23:02:36 -08:00
parent f79fb75769
commit c8c6a3504c
12 changed files with 1301 additions and 97 deletions

View File

@@ -89,6 +89,11 @@ var Graphic = React.createClass({
fix(evt);
this.mx = evt.offsetX;
this.my = evt.offsetY;
this.moving = false;
this.dragging = false;
this.down = true;
this.lpts.forEach(p => {
if(Math.abs(this.mx - p.x)<10 && Math.abs(this.my - p.y)<10) {
this.moving = true;
@@ -98,8 +103,8 @@ var Graphic = React.createClass({
}
});
if (this.props.mouseDown) {
this.props.mouseDown(evt, this);
if (this.props.onMouseDown) {
this.props.onMouseDown(evt, this);
}
},
@@ -107,6 +112,10 @@ var Graphic = React.createClass({
fix(evt);
if(!this.props.static) {
if (this.down) {
this.dragging = true;
}
var found = false;
this.lpts.forEach(p => {
var mx = evt.offsetX;
@@ -140,8 +149,12 @@ var Graphic = React.createClass({
}
}
if (this.props.mouseMove) {
this.props.mouseMove(evt, this);
if (this.props.onMouseMove) {
this.props.onMouseMove(evt, this);
}
if (this.dragging && this.props.onMouseDrag) {
this.props.onMouseDrag(evt, this);
}
if (!this.playing && this.props.draw) {
@@ -150,7 +163,14 @@ var Graphic = React.createClass({
},
mouseUp: function(evt) {
if(!this.moving) return;
this.down = false;
this.dragging = false;
if(!this.moving) {
if (this.props.onMouseUp) {
this.props.onMouseUp(evt, this);
}
return;
}
this.moving = false;
this.mp = false;
if (this.props.onMouseUp) {
@@ -162,7 +182,7 @@ var Graphic = React.createClass({
fix(evt);
this.mx = evt.offsetX;
this.my = evt.offsetY;
if (this.props.onClick) {
if (!this.dragging && this.props.onClick) {
this.props.onClick(evt, this);
}
},