Skip to content

Commit

Permalink
fix: pinch to zoom out close points (#171)
Browse files Browse the repository at this point in the history
  • Loading branch information
yotamberk committed Jan 31, 2020
1 parent 36dbd3b commit 1a56fce
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/timeline/Range.js
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,7 @@ export default class Range extends Component {
this.props.touch.end = this.end;
this.props.touch.allowDragging = true;
this.props.touch.center = null;
this.props.touch.centerDate = null;
this.scaleOffset = 0;
this.deltaDifference = 0;
// Disable the browser default handling of this event.
Expand All @@ -694,12 +695,12 @@ export default class Range extends Component {

if (!this.props.touch.center) {
this.props.touch.center = this.getPointer(event.center, this.body.dom.center);
this.props.touch.centerDate = this._pointerToDate(this.props.touch.center);
}

this.stopRolling();

const scale = 1 / (event.scale + this.scaleOffset);
const centerDate = this._pointerToDate(this.props.touch.center);
const centerDate = this.props.touch.centerDate;

const hiddenDuration = DateUtil.getHiddenDurationBetween(this.body.hiddenDates, this.start, this.end);
const hiddenDurationBefore = DateUtil.getHiddenDurationBefore(this.options.moment, this.body.hiddenDates, this, centerDate);
Expand All @@ -712,7 +713,7 @@ export default class Range extends Component {
// snapping times away from hidden zones
this.startToFront = 1 - scale <= 0; // used to do the right auto correction with periodic hidden times
this.endToFront = scale - 1 <= 0; // used to do the right auto correction with periodic hidden times

const safeStart = DateUtil.snapAwayFromHidden(this.body.hiddenDates, newStart, 1 - scale, true);
const safeEnd = DateUtil.snapAwayFromHidden(this.body.hiddenDates, newEnd, scale - 1, true);
if (safeStart != newStart || safeEnd != newEnd) {
Expand All @@ -722,7 +723,7 @@ export default class Range extends Component {
newStart = safeStart;
newEnd = safeEnd;
}

const options = {
animation: false,
byUser: true,
Expand Down

0 comments on commit 1a56fce

Please sign in to comment.