jasonslyvia / jasonslyvia/react-anything-sortable

Get container position on mouse down

Open
#87 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
457
Forks
82
PR merge metrics
No merged PRs in 30d

Description

There is problem when get contianer position at componentDidUpdate:

When container scroll out of visual range then update position, scroll back, we can't call handleMouseMove correctly

Why not let it work onMouseDown.

`handleMouseDown: function handleMouseDown(e, index) {
this._draggingIndex = index;
this._prevX = e.pageX || e.clientX;
this._prevY = e.pageY || e.clientY;
this._initOffset = e.offset;
this._isReadyForDragging = true;
this._hasInitDragging = false;

var container = _reactDom2['default'].findDOMNode(this);
var rect = container.getBoundingClientRect();

var scrollTop = doc.docElement && doc.docElement.scrollTop || doc.body.scrollTop;
var scrollLeft = doc.docElement && doc.docElement.scrollLeft || doc.body.scrollLeft;

this._top = rect.top + scrollTop;
this._left = rect.left + scrollLeft;
this._bottom = this._top + rect.height;
this._right = this._left + rect.width;

// start listening mousemove and mouseup
this.bindEvent();
}`

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the handleMouseDown entry point and compare it with the componentDidUpdate behavior described in the issue. Check that the container bounds are captured on mouse down and that dragging still handles mouse movement after the container has been scrolled out of view and back.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.