From 4fd72fc51d050e264f59b082a470d4e215d52fca Mon Sep 17 00:00:00 2001 From: Markus Stange Date: Sat, 26 Nov 2016 11:59:11 -0500 Subject: [PATCH] Use setCapture to capture the mouse while dragging points. --- components/Graphic.jsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/components/Graphic.jsx b/components/Graphic.jsx index e9a244c5..06af4b53 100644 --- a/components/Graphic.jsx +++ b/components/Graphic.jsx @@ -114,6 +114,10 @@ var Graphic = React.createClass({ if (this.props.onMouseDown) { this.props.onMouseDown(evt, this); } + + if ('setCapture' in evt.target) { + evt.target.setCapture(); + } }, mouseMove: function(evt) { @@ -143,8 +147,8 @@ var Graphic = React.createClass({ if(this.movingPoint) { this.ox = evt.offsetX - this.mx; this.oy = evt.offsetY - this.my; - this.mp.x = this.cx + this.ox; - this.mp.y = this.cy + this.oy; + this.mp.x = Math.max(0, Math.min(this.defaultWidth, this.cx + this.ox)); + this.mp.y = Math.max(0, Math.min(this.defaultHeight, this.cy + this.oy)); if (this.curve.forEach) { for (var i=0, c, _pts; i