Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[slider] Move _preventDocumentDrag function into the widget prototype…

… and attach it with ._on() to ensure removal upon destroy()
  • Loading branch information...
commit 8275474afbd7660b2a855b0eac4aafb1134e6174 1 parent c21100a
@gabrielschulhof gabrielschulhof authored
Showing with 22 additions and 23 deletions.
  1. +22 −23 js/widgets/forms/slider.js
View
45 js/widgets/forms/slider.js
@@ -152,28 +152,7 @@ $.widget( "mobile.slider", $.mobile.widget, {
self.refresh( val(), true );
});
- this._preventDocumentDrag = function( event ) {
- // NOTE: we don't do this in refresh because we still want to
- // support programmatic alteration of disabled inputs
- if ( self.dragging && !self.options.disabled ) {
-
- // self.mouseMoved must be updated before refresh() because it will be used in the control "change" event
- self.mouseMoved = true;
-
- if ( cType === "select" ) {
- // make the handle move in sync with the mouse
- handle.removeClass( "ui-slider-handle-snapping" );
- }
-
- self.refresh( event );
-
- // only after refresh() you can calculate self.userModified
- self.userModified = self.beforeStart !== control[0].selectedIndex;
- return false;
- }
- }
-
- $( document ).bind( "vmousemove", this._preventDocumentDrag );
+ this._on( document, { "vmousemove": "_preventDocumentDrag" } );
// it appears the clicking the up and down buttons in chrome on
// range/number inputs doesn't trigger a change until the field is
@@ -312,6 +291,27 @@ $.widget( "mobile.slider", $.mobile.widget, {
this.refresh( undefined, undefined, true );
},
+ _preventDocumentDrag: function( event ) {
+ // NOTE: we don't do this in refresh because we still want to
+ // support programmatic alteration of disabled inputs
+ if ( this.dragging && !this.options.disabled ) {
+
+ // self.mouseMoved must be updated before refresh() because it will be used in the control "change" event
+ this.mouseMoved = true;
+
+ if ( this._type === "select" ) {
+ // make the handle move in sync with the mouse
+ this.handle.removeClass( "ui-slider-handle-snapping" );
+ }
+
+ this.refresh( event );
+
+ // only after refresh() you can calculate self.userModified
+ this.userModified = this.beforeStart !== this.element[0].selectedIndex;
+ return false;
+ }
+ },
+
_checkedRefresh: function() {
if( this.value != this._value() ){
this.refresh( this._value() );
@@ -324,7 +324,6 @@ $.widget( "mobile.slider", $.mobile.widget, {
},
_destroy: function() {
- $( document ).unbind( "vmousemove", this._preventDocumentDrag );
$( document ).unbind( "vmouseup", this._sliderMouseUp );
},
Please sign in to comment.
Something went wrong with that request. Please try again.