Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

commit of various fixes

  • Loading branch information...
commit e4c6d1cacae2f0ccd01ce7650f414b872228bc24 1 parent 38af939
@csuwildcat authored
View
64 Source/Drag/Slider.js
@@ -36,6 +36,12 @@ var Slider = new Class({
onTick: function(position){
this.setKnobPosition(position);
},
+ onStart: function(){
+ this.draggedKnob();
+ },
+ onDrag: function(){
+ this.draggedKnob();
+ },
initialStep: 0,
snap: false,
offset: 0,
@@ -75,23 +81,29 @@ var Slider = new Class({
modifiers[this.axis] = this.property;
limit[this.axis] = [-options.offset, this.full - options.offset];
- var dragOptions = {
- snap: 0,
- limit: limit,
- modifiers: modifiers,
- onDrag: this.draggedKnob,
- onStart: this.draggedKnob,
- onBeforeStart: (function(){
- this.isDragging = true;
- }).bind(this),
- onCancel: function(){
- this.isDragging = false;
- }.bind(this),
- onComplete: function(){
- this.isDragging = false;
- this.draggedKnob();
- this.end();
- }.bind(this)
+ var self = this,
+ dragOptions = {
+ snap: 0,
+ limit: limit,
+ modifiers: modifiers,
+ onBeforeStart: function(knob, event){
+ self.fireEvent('beforeStart', [knob, event]);
+ self.isDragging = true;
+ },
+ onStart: function(knob, event){
+ self.fireEvent('start', [knob, event]);
+ },
+ onDrag: function(knob, event){
+ self.fireEvent('drag', [knob, event]);
+ },
+ onCancel: function(){
+ self.isDragging = false;
+ },
+ onComplete: function(){
+ self.isDragging = false;
+ self.draggedKnob();
+ self.end();
+ }
};
if (options.snap) this.setSnap(dragOptions);
@@ -109,7 +121,7 @@ var Slider = new Class({
detach: function(){
this.element.removeEvent('mousedown', this.clickedElement)
- .removeEvent('mousewheel', this.scrolledElement);
+ .removeEvent('mousewheel', this.scrolledElement);
this.drag.detach();
return this;
},
@@ -125,7 +137,7 @@ var Slider = new Class({
setSnap: function(options){
if (!options) options = this.drag.options;
options.grid = Math.ceil(this.stepWidth);
- options.limit[this.axis][1] = this.full;
+ options.limit[this.axis][1] = this.element[this.offset];
return this;
},
@@ -169,11 +181,9 @@ var Slider = new Class({
var dir = this.range < 0 ? -1 : 1,
position = event.page[this.axis] - this.element.getPosition()[this.axis] - this.half;
-
- position = position.limit(-this.options.offset, this.full - this.options.offset);
+ position = position.limit(-this.options.offset, this.full - this.options.offset);
this.step = Math.round(this.min + dir * this.toStep(position));
-
this.checkStep()
.fireEvent('tick', position)
.end();
@@ -188,15 +198,15 @@ var Slider = new Class({
draggedKnob: function(){
var dir = this.range < 0 ? -1 : 1,
position = this.drag.value.now[this.axis];
-
- position = position.limit(-this.options.offset, this.full -this.options.offset);
+ position = position.limit(-this.options.offset, this.full -this.options.offset);
this.step = Math.round(this.min + dir * this.toStep(position));
this.checkStep();
},
-
+
checkStep: function(){
var step = this.step;
+ this.knob.setStyle(this.property, this.toPosition(this.step));
if (this.previousChange != step){
this.previousChange = step;
this.fireEvent('change', step);
@@ -220,6 +230,10 @@ var Slider = new Class({
toPosition: function(step){
return (this.full * Math.abs(this.min - step)) / (this.steps * this.stepSize) - this.options.offset;
+ },
+
+ toElement: function(){
+ return this.knob;
}
});
View
8 Source/Fx/Fx.Scroll.js
@@ -125,16 +125,16 @@ Fx.Scroll = new Class({
x: position.x + size.x,
y: position.y + size.y
};
-
+
['x', 'y'].each(function(axis){
if (axes.contains(axis)){
- if (edge[axis] > scroll[axis] + containerSize[axis]) to[axis] = edge[axis] - containerSize[axis];
- if (position[axis] < scroll[axis]) to[axis] = position[axis];
+ if (edge[axis] > containerSize[axis]) to[axis] = (edge[axis] - containerSize[axis]) + scroll[axis];
+ else if (position[axis] < scroll[axis]) to[axis] = position[axis] + scroll[axis];
}
if (to[axis] == null) to[axis] = scroll[axis];
if (offset && offset[axis]) to[axis] = to[axis] + offset[axis];
}, this);
-
+
if (to.x != scroll.x || to.y != scroll.y) this.start(to.x, to.y);
return this;
},
View
2  Source/Request/Request.JSONP.js
@@ -83,7 +83,7 @@ Request.JSONP = new Class({
if (src.length > 2083) this.fireEvent('error', src);
Request.JSONP.request_map['request_' + index] = function(){
- this.success(arguments, index);
+ this.success(Array.from(arguments).append(options), index);
}.bind(this);
var script = this.getScript(src).inject(options.injectScript);

1 comment on commit e4c6d1c

@csuwildcat
Owner

Slider.js - code fixes the issue that was raised again today for the 1000th time (in office hours none the less) where the knob doesn't snap to the end of the slider element if the division leaves a remainder - devs shouldn't have to worry about making their layout certain sizes to fit our bugs. It also allows for Slider.Extras, which is just pimp.

Fx.Scroll - fixes the fact that Fx.Scroll doesn't account for the current amount the element is already scrolled, this causes the code to transition to the wrong place.

Request.JSONP - an enhancement to allow the options of the particular send() instance to be passed to the success function. This is important because the options change per call so not tying it to the instance success means you can be sure they are the right ones as the return is async.

Please sign in to comment.
Something went wrong with that request. Please try again.