Skip to content

Commit

Permalink
Debounced zoom tracking.
Browse files Browse the repository at this point in the history
  • Loading branch information
fbarl committed Jul 31, 2017
1 parent e0beb1e commit 83e433e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
13 changes: 10 additions & 3 deletions client/app/scripts/components/time-travel-timeline.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import moment from 'moment';
import classNames from 'classnames';
import { map, clamp, find, last } from 'lodash';
import { map, clamp, find, last, debounce } from 'lodash';
import { connect } from 'react-redux';
import { drag } from 'd3-drag';
import { scaleUtc } from 'd3-scale';
Expand All @@ -17,7 +17,7 @@ import {
} from '../utils/time-utils';

import { NODES_SPRING_FAST_ANIMATION_CONFIG } from '../constants/animation';
import { TIMELINE_TICK_INTERVAL } from '../constants/timer';
import { TIMELINE_TICK_INTERVAL, ZOOM_TRACK_DEBOUNCE_INTERVAL } from '../constants/timer';


const TICK_SETTINGS_PER_PERIOD = {
Expand Down Expand Up @@ -107,6 +107,7 @@ class TimeTravelTimeline extends React.Component {
this.handlePan = this.handlePan.bind(this);

this.saveSvgRef = this.saveSvgRef.bind(this);
this.debouncedTrackZoom = debounce(this.trackZoom.bind(this), ZOOM_TRACK_DEBOUNCE_INTERVAL);
}

componentDidMount() {
Expand Down Expand Up @@ -140,6 +141,12 @@ class TimeTravelTimeline extends React.Component {
this.svgRef = ref;
}

trackZoom() {
trackMixpanelEvent('scope.time.timeline.zoom', {
durationPerPixelInMilliseconds: this.state.durationPerPixel.asMilliseconds()
});
}

handlePanStart() {
this.setState({ isPanning: true });
}
Expand All @@ -163,8 +170,8 @@ class TimeTravelTimeline extends React.Component {
if (durationPerPixel > MAX_DURATION_PER_PX) durationPerPixel = MAX_DURATION_PER_PX;
if (durationPerPixel < MIN_DURATION_PER_PX) durationPerPixel = MIN_DURATION_PER_PX;

trackMixpanelEvent('scope.time.timeline.zoom', { scale });
this.setState({ durationPerPixel });
this.debouncedTrackZoom();
ev.preventDefault();
}

Expand Down
4 changes: 3 additions & 1 deletion client/app/scripts/constants/timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ export const TOPOLOGY_LOADER_DELAY = 100;

export const TABLE_ROW_FOCUS_DEBOUNCE_INTERVAL = 10;
export const VIEWPORT_RESIZE_DEBOUNCE_INTERVAL = 200;

export const ZOOM_CACHE_DEBOUNCE_INTERVAL = 500;
export const TIMELINE_DEBOUNCE_INTERVAL = 500;
export const ZOOM_TRACK_DEBOUNCE_INTERVAL = 1000;

export const TIMELINE_DEBOUNCE_INTERVAL = 500;
export const TIMELINE_TICK_INTERVAL = 1000;

0 comments on commit 83e433e

Please sign in to comment.