顺利拖动div

时间:2017-12-06 11:18:09

标签: javascript reactjs

我想创建一个可拖动的div。我想知道如何改进浏览器渲染和平滑结果。

jsfiddle

reactJS

$current n = 0;
if (!$solvemedia_response->is_valid) {
    print "<div class='alert alert-danger'> Captcha wrong try again!: ".$solvemedia_response->error."</div>";
    $currentn +=0;
    echo $currentn;
}else {
    print "<div class='alert alert-success'> 100 satoshis have been earned successfuly </div>";
    $currentn +=100;
    echo $currentn;
}

HTML

 mouseDown() {
this.setState({
  thumbActive: true,
});
},

mouseUp() {
this.setState({
  thumbActive: false,
});
},

mouseMove(e) {
  if(!this.state.thumbActive) {
  return;
  }

  const y = e.nativeEvent.offsetY;
  this.setState({
  topPosition: y,
  });
},

1 个答案:

答案 0 :(得分:0)

尝试使用拖放插件,这样可以节省大量时间。

插件 - react-dnd