Skip to content

Commit

Permalink
Fixes #88
Browse files Browse the repository at this point in the history
  • Loading branch information
earlyriser committed Sep 11, 2019
1 parent 2613c65 commit 5b59e42
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/components/draggable.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class Draggable extends PureComponent {
drag = createDragHandler({
handleDrag: this.handleDrag,
handleDragStop: this.handleDragStop
})
}, this.props.isTracking)

clear() {
if (this.delay) clearTimeout(this.delay)
Expand All @@ -88,6 +88,7 @@ class Draggable extends PureComponent {
className: string,
delay: number.isRequired,
isDisabled: bool,
isTracking: bool,
style: object,
tabIndex: number,
onClick: func.isRequired,
Expand All @@ -98,6 +99,7 @@ class Draggable extends PureComponent {

static defaultProps = {
delay: 250,
isTracking: false,
onClick: noop,
onDrag: noop,
onDragStop: noop
Expand Down
1 change: 1 addition & 0 deletions src/components/esper/toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ class EsperToolbar extends React.PureComponent {
precision={this.props.zoomPrecision}
resolution={this.props.resolution * 100}
showCurrentValue
isTracking
steps={this.props.zoomSteps}
minIcon={<IconMinusCircle/>}
maxIcon={<IconPlusCircle/>}
Expand Down
1 change: 1 addition & 0 deletions src/components/project/toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const ProjectToolbar = (props) => (
value={props.zoom}
max={props.maxZoom}
isDisabled={props.isDisabled || props.count === 0}
isTracking
onChange={props.onZoomChange}
minIcon={<IconList/>}
maxIcon={<IconGrid/>}
Expand Down
3 changes: 3 additions & 0 deletions src/components/slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ class Slider extends React.PureComponent {
<Draggable
delay={15}
isDisabled={isDisabled}
isTracking={this.props.isTracking}
onDrag={this.handleDrag}
onDragStart={this.handleDragStart}>
<div ref={this.track} className="slider-track">
Expand All @@ -240,6 +241,7 @@ class Slider extends React.PureComponent {

static propTypes = {
isDisabled: bool,
isTracking: bool,
keymap: instanceOf(KeyMap).isRequired,
max: number.isRequired,
maxIcon: element,
Expand All @@ -259,6 +261,7 @@ class Slider extends React.PureComponent {
}

static defaultProps = {
isTracking: false,
min: 0,
max: 1,
precision: 1,
Expand Down
12 changes: 10 additions & 2 deletions src/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ const dom = {
return node.tagName === 'A' && !blank(node.href)
},

createDragHandler({ handleDrag, handleDragStop }) {
createDragHandler({ handleDrag, handleDragStop }, isTracking = false) {
function onKeyDown(event) {
switch (event.key) {
case 'Escape':
Expand All @@ -189,9 +189,17 @@ const dom = {
function onDragStart() {
dom.on(document, 'mousemove', handleDrag)
dom.on(document, 'mouseup', onDragStop, { capture: true })
dom.on(document, 'mouseleave', onDragStop)
dom.on(window, 'blur', onDragStop)

if (isTracking) {
dom.on(document.body, 'mouseleave', onDragStop)
dom.on(document, 'mousemove', (e) => {
if (e.buttons === 0) {
onDragStop()
}
})
}

// Register on body because global bindings are bound
// on document and we need to stop the propagation in
// case we handle it here!
Expand Down

0 comments on commit 5b59e42

Please sign in to comment.