Skip to content

Commit

Permalink
Remove duplicate init code #7
Browse files Browse the repository at this point in the history
  • Loading branch information
ovidiuch committed Jan 2, 2014
1 parent 8b64fcf commit e8b9f64
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions src/dragdealer.js
Expand Up @@ -177,7 +177,7 @@ var Dragdealer = function(wrapper, options) {
return;
}
this.init(wrapper, handle, options || {});
this.setup();
this.bindEventListeners();
};
Dragdealer.prototype = {
defaults: {
Expand Down Expand Up @@ -210,11 +210,13 @@ Dragdealer.prototype = {
target: [0, 0]
};
this.change = [0, 0];
this.stepRatios = this.calculateStepRatios();

this.activity = false;
this.dragging = false;
this.tapping = false;

this.reflow();
if (this.options.disabled) {
this.disable();
}
Expand All @@ -227,13 +229,14 @@ Dragdealer.prototype = {
}
return options;
},
setup: function() {
this.setWrapperOffset();
this.bounds = this.calculateBounds();
this.valuePrecision = this.calculateValuePrecision();
this.setSteps();

this.bindEventListeners();
calculateStepRatios: function() {
var stepRatios = [];
if (this.options.steps > 1) {
for (var i = 0; i <= this.options.steps - 1; i++) {
stepRatios[i] = i / (this.options.steps - 1);
}
}
return stepRatios;
},
setWrapperOffset: function() {
this.offset.wrapper = Position.get(this.wrapper);
Expand Down Expand Up @@ -266,14 +269,6 @@ Dragdealer.prototype = {
1 / (this.options.yPrecision || this.bounds.availHeight)
];
},
setSteps: function() {
if (this.options.steps > 1) {
this.stepRatios = [];
for (var i = 0; i <= this.options.steps - 1; i++) {
this.stepRatios[i] = i / (this.options.steps - 1);
}
}
},
bindEventListeners: function() {
// Start dragging
this.bindEventHandler('mousedown', this.handle, 'onHandleMouseDown');
Expand Down

0 comments on commit e8b9f64

Please sign in to comment.