Skip to content

Commit

Permalink
Improve minification
Browse files Browse the repository at this point in the history
  • Loading branch information
etimberg committed Jun 12, 2016
1 parent 2f3f2fd commit 8efb9f8
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions src/chart.zoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ Chart = typeof(Chart) === 'function' ? Chart : window.Chart;
var helpers = Chart.helpers;

// Take the zoom namespace of Chart
Chart.Zoom = Chart.Zoom || {};
var zoomNS = Chart.Zoom = Chart.Zoom || {};

// Where we store functions to handle different scale types
var zoomFunctions = Chart.Zoom.zoomFunctions = Chart.Zoom.zoomFunctions || {};
var panFunctions = Chart.Zoom.panFunctions = Chart.Zoom.panFunctions || {};
var zoomFunctions = zoomNS.zoomFunctions = zoomNSzoomFunctions || {};
var panFunctions = zoomNS.panFunctions = zoomNS.panFunctions || {};

// Default options if none are provided
var defaultOptions = Chart.Zoom.defaults = {
var defaultOptions = zoomNS.defaults = {
pan: {
enabled: true,
mode: 'xy',
Expand Down Expand Up @@ -121,16 +121,16 @@ function panTimeScale(scale, delta) {
}

function panNumericalScale(scale, delta) {
var options = scale.options;
var tickOpts = scale.options.ticks;
var start = scale.start,
end = scale.end;

if (options.ticks.reverse) {
options.ticks.max = scale.getValueForPixel(scale.getPixelForValue(start) - delta);
options.ticks.min = scale.getValueForPixel(scale.getPixelForValue(end) - delta);
if (tickOpts.reverse) {
tickOpts.max = scale.getValueForPixel(scale.getPixelForValue(start) - delta);
tickOpts.min = scale.getValueForPixel(scale.getPixelForValue(end) - delta);
} else {
options.ticks.min = scale.getValueForPixel(scale.getPixelForValue(start) - delta);
options.ticks.max = scale.getValueForPixel(scale.getPixelForValue(end) - delta);
tickOpts.min = scale.getValueForPixel(scale.getPixelForValue(start) - delta);
tickOpts.max = scale.getValueForPixel(scale.getPixelForValue(end) - delta);
}
}

Expand Down Expand Up @@ -164,21 +164,21 @@ function positionInChartArea(chartInstance, position) {
}

// Store these for later
Chart.Zoom.zoomFunctions['category'] = zoomIndexScale;
Chart.Zoom.zoomFunctions['time'] = zoomTimeScale;
Chart.Zoom.zoomFunctions['linear'] = zoomNumericalScale;
Chart.Zoom.zoomFunctions['logarithmic'] = zoomNumericalScale;
Chart.Zoom.panFunctions['category'] = panIndexScale;
Chart.Zoom.panFunctions['time'] = panTimeScale;
Chart.Zoom.panFunctions['linear'] = panNumericalScale;
Chart.Zoom.panFunctions['logarithmic'] = panNumericalScale;
zoomNS.zoomFunctions['category'] = zoomIndexScale;
zoomNS.zoomFunctions['time'] = zoomTimeScale;
zoomNS.zoomFunctions['linear'] = zoomNumericalScale;
zoomNS.zoomFunctions['logarithmic'] = zoomNumericalScale;
zoomNS.panFunctions['category'] = panIndexScale;
zoomNS.panFunctions['time'] = panTimeScale;
zoomNS.panFunctions['linear'] = panNumericalScale;
zoomNS.panFunctions['logarithmic'] = panNumericalScale;

// Chartjs Zoom Plugin
var ZoomPlugin = Chart.PluginBase.extend({
var zoomPlugin = {
beforeInit: function(chartInstance) {
var node = chartInstance.chart.ctx.canvas;
var options = chartInstance.options;
var panThreshold = helpers.getValueOrDefault(options.pan ? options.pan.threshold : undefined, Chart.Zoom.defaults.pan.threshold);
var panThreshold = helpers.getValueOrDefault(options.pan ? options.pan.threshold : undefined, zoomNS.defaults.pan.threshold);

var wheelHandler = function(e) {
if (e.deltaY > 0) {
Expand Down Expand Up @@ -269,6 +269,6 @@ var ZoomPlugin = Chart.PluginBase.extend({
mc.remove('panend');
}
}
});
};

Chart.pluginService.register(new ZoomPlugin());
Chart.pluginService.register(zoomPlugin);

0 comments on commit 8efb9f8

Please sign in to comment.