Skip to content
This repository

A bunch of fixes and additions #253

Open
wants to merge 1 commit into from

3 participants

Daniel Buchner Jacob Arian Stolwijk
Daniel Buchner

No description provided.

Jacob
fat commented

commit of a bunch of untested changes with incorrect whitespace?

Arian Stolwijk
Owner
arian commented

What does it fix?

Daniel Buchner

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.

Arian Stolwijk
Owner
arian commented

Thanks for the explanation. Unfortunately I don't have time to pull this now. Providing some tests (I assume you tested your changes locally) would help. Preferably as specs and tests in the Tests folder of course.

Arian Stolwijk
Owner
arian commented

Your sliders changes would fix #252 right?

Noritaka Horio holyshared referenced this pull request from a commit
Arian Stolwijk arian * Fixes #253 - Better explanation for the dataFormat property of the …
…date validator in Form.Validator

* Fix some broken links in the Form.Validator and Form.Validator.Extras Docs
* Use the right amount of dashes for the headings
0278d80
Arian Stolwijk arian commented on the diff
Source/Drag/Slider.js
@@ -36,6 +36,12 @@ var Slider = new Class({
36 36 onTick: function(position){
37 37 this.setKnobPosition(position);
38 38 },
  39 + onStart: function(){
  40 + this.draggedKnob();
1
Arian Stolwijk Owner
arian added a note

Wouldn't this break when you set the events with the options object during the initialization.
So isn't it better to use this in the initialize method?

this.addEvent('start', this.draggedKnob.bind(this), true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Arian Stolwijk arian commented on the diff
Source/Drag/Slider.js
((7 lines not shown))
81   - modifiers: modifiers,
82   - onDrag: this.draggedKnob,
83   - onStart: this.draggedKnob,
84   - onBeforeStart: (function(){
85   - this.isDragging = true;
86   - }).bind(this),
87   - onCancel: function(){
88   - this.isDragging = false;
89   - }.bind(this),
90   - onComplete: function(){
91   - this.isDragging = false;
92   - this.draggedKnob();
93   - this.end();
94   - }.bind(this)
  84 + var self = this,
  85 + dragOptions = {
1
Arian Stolwijk Owner
arian added a note

keep the var here, and don't extra indent. Makes it hard to review as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Arian Stolwijk arian commented on the diff
Source/Fx/Fx.Scroll.js
((6 lines not shown))
129 129 ['x', 'y'].each(function(axis){
130 130 if (axes.contains(axis)){
131   - if (edge[axis] > scroll[axis] + containerSize[axis]) to[axis] = edge[axis] - containerSize[axis];
132   - if (position[axis] < scroll[axis]) to[axis] = position[axis];
  131 + if (edge[axis] > containerSize[axis]) to[axis] = (edge[axis] - containerSize[axis]) + scroll[axis];
1
Arian Stolwijk Owner
arian added a note

Doesn't this apply for that other method as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Arian Stolwijk arian commented on the diff
Source/Request/Request.JSONP.js
@@ -83,7 +83,7 @@ Request.JSONP = new Class({
83 83 if (src.length > 2083) this.fireEvent('error', src);
84 84
85 85 Request.JSONP.request_map['request_' + index] = function(){
86   - this.success(arguments, index);
  86 + this.success(Array.from(arguments).append(options), index);
1
Arian Stolwijk Owner
arian added a note

I see that it's not easy to access the options like url and data in the success method, however we don't have this in Request as well, and I don't want to add extra stuff that is inconsistent across the framework (so with core)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Arian Stolwijk
Owner
arian commented

Isn't the Fx.Scroll fix the same as #239

Sergio Crisostomo SergioCrisostomo referenced this pull request from a commit in SergioCrisostomo/mootools-more
Sergio Crisostomo SergioCrisostomo Fix "snap" to final value
Imported a idea from @csuwildcat 's PR #253
fixes #252
349e30b
Sergio Crisostomo SergioCrisostomo referenced this pull request from a commit
Sergio Crisostomo SergioCrisostomo Fix "snap" to final value
Imported a idea from @csuwildcat 's PR #253
fixes #252
62f78bf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Jun 21, 2011
Daniel Buchner csuwildcat commit of various fixes e4c6d1c
This page is out of date. Refresh to see the latest.
64 Source/Drag/Slider.js
@@ -36,6 +36,12 @@ var Slider = new Class({
36 36 onTick: function(position){
37 37 this.setKnobPosition(position);
38 38 },
  39 + onStart: function(){
  40 + this.draggedKnob();
  41 + },
  42 + onDrag: function(){
  43 + this.draggedKnob();
  44 + },
39 45 initialStep: 0,
40 46 snap: false,
41 47 offset: 0,
@@ -75,23 +81,29 @@ var Slider = new Class({
75 81 modifiers[this.axis] = this.property;
76 82 limit[this.axis] = [-options.offset, this.full - options.offset];
77 83
78   - var dragOptions = {
79   - snap: 0,
80   - limit: limit,
81   - modifiers: modifiers,
82   - onDrag: this.draggedKnob,
83   - onStart: this.draggedKnob,
84   - onBeforeStart: (function(){
85   - this.isDragging = true;
86   - }).bind(this),
87   - onCancel: function(){
88   - this.isDragging = false;
89   - }.bind(this),
90   - onComplete: function(){
91   - this.isDragging = false;
92   - this.draggedKnob();
93   - this.end();
94   - }.bind(this)
  84 + var self = this,
  85 + dragOptions = {
  86 + snap: 0,
  87 + limit: limit,
  88 + modifiers: modifiers,
  89 + onBeforeStart: function(knob, event){
  90 + self.fireEvent('beforeStart', [knob, event]);
  91 + self.isDragging = true;
  92 + },
  93 + onStart: function(knob, event){
  94 + self.fireEvent('start', [knob, event]);
  95 + },
  96 + onDrag: function(knob, event){
  97 + self.fireEvent('drag', [knob, event]);
  98 + },
  99 + onCancel: function(){
  100 + self.isDragging = false;
  101 + },
  102 + onComplete: function(){
  103 + self.isDragging = false;
  104 + self.draggedKnob();
  105 + self.end();
  106 + }
95 107 };
96 108 if (options.snap) this.setSnap(dragOptions);
97 109
@@ -109,7 +121,7 @@ var Slider = new Class({
109 121
110 122 detach: function(){
111 123 this.element.removeEvent('mousedown', this.clickedElement)
112   - .removeEvent('mousewheel', this.scrolledElement);
  124 + .removeEvent('mousewheel', this.scrolledElement);
113 125 this.drag.detach();
114 126 return this;
115 127 },
@@ -125,7 +137,7 @@ var Slider = new Class({
125 137 setSnap: function(options){
126 138 if (!options) options = this.drag.options;
127 139 options.grid = Math.ceil(this.stepWidth);
128   - options.limit[this.axis][1] = this.full;
  140 + options.limit[this.axis][1] = this.element[this.offset];
129 141 return this;
130 142 },
131 143
@@ -169,11 +181,9 @@ var Slider = new Class({
169 181
170 182 var dir = this.range < 0 ? -1 : 1,
171 183 position = event.page[this.axis] - this.element.getPosition()[this.axis] - this.half;
172   -
173   - position = position.limit(-this.options.offset, this.full - this.options.offset);
  184 + position = position.limit(-this.options.offset, this.full - this.options.offset);
174 185
175 186 this.step = Math.round(this.min + dir * this.toStep(position));
176   -
177 187 this.checkStep()
178 188 .fireEvent('tick', position)
179 189 .end();
@@ -188,15 +198,15 @@ var Slider = new Class({
188 198 draggedKnob: function(){
189 199 var dir = this.range < 0 ? -1 : 1,
190 200 position = this.drag.value.now[this.axis];
191   -
192   - position = position.limit(-this.options.offset, this.full -this.options.offset);
  201 + position = position.limit(-this.options.offset, this.full -this.options.offset);
193 202
194 203 this.step = Math.round(this.min + dir * this.toStep(position));
195 204 this.checkStep();
196 205 },
197   -
  206 +
198 207 checkStep: function(){
199 208 var step = this.step;
  209 + this.knob.setStyle(this.property, this.toPosition(this.step));
200 210 if (this.previousChange != step){
201 211 this.previousChange = step;
202 212 this.fireEvent('change', step);
@@ -220,6 +230,10 @@ var Slider = new Class({
220 230
221 231 toPosition: function(step){
222 232 return (this.full * Math.abs(this.min - step)) / (this.steps * this.stepSize) - this.options.offset;
  233 + },
  234 +
  235 + toElement: function(){
  236 + return this.knob;
223 237 }
224 238
225 239 });
8 Source/Fx/Fx.Scroll.js
@@ -125,16 +125,16 @@ Fx.Scroll = new Class({
125 125 x: position.x + size.x,
126 126 y: position.y + size.y
127 127 };
128   -
  128 +
129 129 ['x', 'y'].each(function(axis){
130 130 if (axes.contains(axis)){
131   - if (edge[axis] > scroll[axis] + containerSize[axis]) to[axis] = edge[axis] - containerSize[axis];
132   - if (position[axis] < scroll[axis]) to[axis] = position[axis];
  131 + if (edge[axis] > containerSize[axis]) to[axis] = (edge[axis] - containerSize[axis]) + scroll[axis];
  132 + else if (position[axis] < scroll[axis]) to[axis] = position[axis] + scroll[axis];
133 133 }
134 134 if (to[axis] == null) to[axis] = scroll[axis];
135 135 if (offset && offset[axis]) to[axis] = to[axis] + offset[axis];
136 136 }, this);
137   -
  137 +
138 138 if (to.x != scroll.x || to.y != scroll.y) this.start(to.x, to.y);
139 139 return this;
140 140 },
2  Source/Request/Request.JSONP.js
@@ -83,7 +83,7 @@ Request.JSONP = new Class({
83 83 if (src.length > 2083) this.fireEvent('error', src);
84 84
85 85 Request.JSONP.request_map['request_' + index] = function(){
86   - this.success(arguments, index);
  86 + this.success(Array.from(arguments).append(options), index);
87 87 }.bind(this);
88 88
89 89 var script = this.getScript(src).inject(options.injectScript);

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.