Changeset 3305
- Timestamp:
- 12/14/05 10:03:04 (3 years ago)
- Files:
-
- plugins/scriptaculous_slider/CHANGELOG (modified) (1 diff)
- plugins/scriptaculous_slider/javascripts/slider.js (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/scriptaculous_slider/CHANGELOG
r2937 r3305 1 * Updated to slider.js as of script.aculo.us 1.5 final 2 1 3 * Updated copyright notice 2 4 plugins/scriptaculous_slider/javascripts/slider.js
r2937 r3305 65 65 66 66 this.trackLength = this.maximumOffset() - this.minimumOffset(); 67 this.handleLength = this.isVertical() ? this.handles[0].offsetHeight : this.handles[0].offsetWidth; 67 68 68 69 this.active = false; … … 152 153 this.value = this.values[0]; // assure backwards compat 153 154 154 this.handles[handleIdx].style[ this.isVertical() ? 'top' : 'left'] =155 this.handles[handleIdx].style[this.isVertical() ? 'top' : 'left'] = 155 156 this.translateToPx(sliderValue); 156 157 157 158 this.drawSpans(); 158 if(!this. event) this.updateFinished();159 if(!this.dragging || !this.event) this.updateFinished(); 159 160 }, 160 161 setValueBy: function(delta, handleIdx) { … … 163 164 }, 164 165 translateToPx: function(value) { 165 return Math.round((this.trackLength / (this.range.end - this.range.start)) * (value - this.range.start)) + "px"; 166 return Math.round( 167 ((this.trackLength-this.handleLength)/(this.range.end-this.range.start)) * 168 (value - this.range.start)) + "px"; 166 169 }, 167 170 translateToValue: function(offset) { 168 return ((offset/this.trackLength) * (this.range.end - this.range.start)) + this.range.start; 171 return ((offset/(this.trackLength-this.handleLength) * 172 (this.range.end-this.range.start)) + this.range.start); 169 173 }, 170 174 getRange: function(range) { … … 216 220 if(handle==this.track) { 217 221 var offsets = Position.cumulativeOffset(this.track); 218 this.event = event; 222 this.event = event; 219 223 this.setValue(this.translateToValue( 220 this.isVertical() ? pointer[1]-offsets[1] : pointer[0]-offsets[0]224 (this.isVertical() ? pointer[1]-offsets[1] : pointer[0]-offsets[0])-(this.handleLength/2) 221 225 )); 222 offsets = Position.cumulativeOffset(this.activeHandle);226 var offsets = Position.cumulativeOffset(this.activeHandle); 223 227 this.offsetX = (pointer[0] - offsets[0]); 224 228 this.offsetY = (pointer[1] - offsets[1]); … … 242 246 update: function(event) { 243 247 if(this.active) { 244 if(!this.dragging) { 245 this.dragging = true; 246 if(this.activeHandle.style.position=="") style.position = "relative"; 247 } 248 if(!this.dragging) this.dragging = true; 248 249 this.draw(event); 249 250 // fix AppleWebKit rendering … … 259 260 this.event = event; 260 261 this.setValue(this.translateToValue( this.isVertical() ? pointer[1] : pointer[0] )); 261 if(this.initialized && this.options.onSlide) this.options.onSlide(this.values.length>1 ? this.values : this.value, this); 262 if(this.initialized && this.options.onSlide) 263 this.options.onSlide(this.values.length>1 ? this.values : this.value, this); 262 264 }, 263 265 endDrag: function(event) {