|
46 | 46 | FULL featured drag and drop. 0.7 kb minified, 0.3 gzipped. done. |
47 | 47 | Who told d'n'd is rocket science? Usage: |
48 | 48 | |
49 | | - $(".myelement").drag({y: false}).bind("drag", function(event, x, y) { |
| 49 | + $(".myelement").drag({y: false}).on("drag", function(event, x, y) { |
50 | 50 | // do your custom thing |
51 | 51 | }); |
52 | 52 | |
|
66 | 66 |
|
67 | 67 | conf = $.extend({x: true, y: true, drag: true}, conf); |
68 | 68 |
|
69 | | - doc = doc || $(document).bind("mousedown mouseup", function(e) { |
| 69 | + doc = doc || $(document).on("mousedown mouseup", function(e) { |
70 | 70 |
|
71 | 71 | var el = $(e.target); |
72 | 72 |
|
|
78 | 78 | y0 = e.pageY - offset.top, |
79 | 79 | start = true; |
80 | 80 |
|
81 | | - doc.bind("mousemove.drag", function(e) { |
| 81 | + doc.on("mousemove.drag", function(e) { |
82 | 82 | var x = e.pageX -x0, |
83 | 83 | y = e.pageY -y0, |
84 | 84 | props = {}; |
|
104 | 104 | draggable.trigger("dragEnd"); |
105 | 105 | } |
106 | 106 | } finally { |
107 | | - doc.unbind("mousemove.drag"); |
| 107 | + doc.off("mousemove.drag"); |
108 | 108 | draggable = null; |
109 | 109 | } |
110 | 110 | } |
|
167 | 167 | precision = conf.precision; |
168 | 168 |
|
169 | 169 | if (precision === undefined) { |
170 | | - try { |
171 | | - precision = step.toString().split(".")[1].length; |
172 | | - } catch (err) { |
173 | | - precision = 0; |
174 | | - } |
| 170 | + precision = step.toString().split("."); |
| 171 | + precision = precision.length === 2 ? precision[1].length : 0; |
175 | 172 | } |
176 | 173 |
|
177 | 174 | // Replace built-in range input (type attribute cannot be changed) |
|
330 | 327 |
|
331 | 328 | // from configuration |
332 | 329 | if ($.isFunction(conf[name])) { |
333 | | - $(self).bind(name, conf[name]); |
| 330 | + $(self).on(name, conf[name]); |
334 | 331 | } |
335 | 332 |
|
336 | 333 | // API methods |
337 | 334 | self[name] = function(fn) { |
338 | | - if (fn) { $(self).bind(name, fn); } |
| 335 | + if (fn) { $(self).on(name, fn); } |
339 | 336 | return self; |
340 | 337 | }; |
341 | 338 | }); |
342 | 339 |
|
343 | 340 |
|
344 | 341 | // dragging |
345 | | - handle.drag({drag: false}).bind("dragStart", function() { |
| 342 | + handle.drag({drag: false}).on("dragStart", function() { |
346 | 343 |
|
347 | 344 | /* do some pre- calculations for seek() function. improves performance */ |
348 | 345 | init(); |
|
351 | 348 | fireOnSlide = hasEvent($(self)) || hasEvent(input); |
352 | 349 |
|
353 | 350 |
|
354 | | - }).bind("drag", function(e, y, x) { |
| 351 | + }).on("drag", function(e, y, x) { |
355 | 352 |
|
356 | 353 | if (input.is(":disabled")) { return false; } |
357 | 354 | slide(e, vertical ? y : x); |
358 | 355 |
|
359 | | - }).bind("dragEnd", function(e) { |
| 356 | + }).on("dragEnd", function(e) { |
360 | 357 | if (!e.isDefaultPrevented()) { |
361 | 358 | e.type = "change"; |
362 | 359 | fire.trigger(e, [value]); |
|
0 commit comments