Skip to content

Commit

Permalink
Merge pull request #2 from takipi-dev/master
Browse files Browse the repository at this point in the history
move from takipi-dev to takipi
  • Loading branch information
shimonmagal authored Apr 24, 2018
2 parents b69b9ff + dd23ce8 commit c1d2bce
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
14 changes: 11 additions & 3 deletions dist/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ var UITreeNode = function (_Component) {
dragging: dragging,
paddingLeft: _this.props.paddingLeft,
onCollapse: _this.props.onCollapse,
onDragStart: _this.props.onDragStart
onDragStart: _this.props.onDragStart,
dragDelay: _this.props.dragDelay
});
})
);
Expand All @@ -92,10 +93,17 @@ var UITreeNode = function (_Component) {
}, _this.handleMouseDown = function (e) {
var nodeId = _this.props.index.id;
var dom = _this.refs.inner;
var eventXY = { clientY: e.clientY, clientX: e.clientX };

var self = _this;

if (_this.props.onDragStart) {
_this.props.onDragStart(nodeId, dom, e);
_this.pressTimer = window.setTimeout(function () {
self.props.onDragStart(nodeId, dom, eventXY);
}, _this.props.dragDelay);
}
}, _this.handleMouseUp = function (e) {
clearTimeout(_this.pressTimer);
}, _temp), _possibleConstructorReturn(_this, _ret);
}

Expand All @@ -120,7 +128,7 @@ var UITreeNode = function (_Component) {
},
_react2.default.createElement(
'div',
{ className: 'inner', ref: 'inner', onMouseDown: this.handleMouseDown },
{ className: 'inner', ref: 'inner', onMouseDown: this.handleMouseDown, onMouseUp: this.handleMouseUp },
this.renderCollapse(),
tree.renderNode(node)
),
Expand Down
3 changes: 2 additions & 1 deletion dist/react-ui-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ var UITree = function (_Component) {
paddingLeft: this.props.paddingLeft,
onDragStart: this.dragStart,
onCollapse: this.toggleCollapse,
dragging: dragging && dragging.id
dragging: dragging && dragging.id,
dragDelay: this.props.dragDelay || 0
})
);
}
Expand Down
14 changes: 12 additions & 2 deletions lib/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class UITreeNode extends Component {
paddingLeft={this.props.paddingLeft}
onCollapse={this.props.onCollapse}
onDragStart={this.props.onDragStart}
dragDelay={this.props.dragDelay}
/>
);
})}
Expand All @@ -64,7 +65,7 @@ class UITreeNode extends Component {
})}
style={styles}
>
<div className="inner" ref="inner" onMouseDown={this.handleMouseDown}>
<div className="inner" ref="inner" onMouseDown={this.handleMouseDown} onMouseUp={this.handleMouseUp}>
{this.renderCollapse()}
{tree.renderNode(node)}
</div>
Expand All @@ -85,11 +86,20 @@ class UITreeNode extends Component {
handleMouseDown = e => {
const nodeId = this.props.index.id;
const dom = this.refs.inner;
const eventXY = {clientY: e.clientY, clientX: e.clientX};

let self = this;

if (this.props.onDragStart) {
this.props.onDragStart(nodeId, dom, e);
this.pressTimer = window.setTimeout(function() {
self.props.onDragStart(nodeId, dom, eventXY);
}, this.props.dragDelay);
}
};

handleMouseUp = e => {
clearTimeout(this.pressTimer);
};
}

module.exports = UITreeNode;
1 change: 1 addition & 0 deletions lib/react-ui-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class UITree extends Component {
onDragStart={this.dragStart}
onCollapse={this.toggleCollapse}
dragging={dragging && dragging.id}
dragDelay={this.props.dragDelay || 0}
/>
</div>
);
Expand Down

0 comments on commit c1d2bce

Please sign in to comment.