From d5035a0aa04dac836bcf737dc29f2ebfc1f2d537 Mon Sep 17 00:00:00 2001 From: Jesin A Date: Thu, 27 Feb 2014 17:51:09 +0530 Subject: [PATCH 1/2] Add an event - background_drag --- draggable_background.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/draggable_background.js b/draggable_background.js index 323369a..555c895 100644 --- a/draggable_background.js +++ b/draggable_background.js @@ -79,6 +79,12 @@ x0 = x y0 = y + $this.trigger({ + type: 'background_drag', + posX: xPos, + posY: yPos + }) + $this.css('background-position', xPos + 'px ' + yPos + 'px') }) }) @@ -91,4 +97,10 @@ bound: true , axis: undefined } + + $.fn.background_drag = function(data, callback) { + return arguments.length > 0 ? + this.on('background_drag', null, data, callback) : + this.trigger('background_drag'); + } }(jQuery); From ab435b93b691d21281efbd353a7160c92d883984 Mon Sep 17 00:00:00 2001 From: Jesin A Date: Thu, 27 Feb 2014 18:04:18 +0530 Subject: [PATCH 2/2] Update demo to make use of background_drag event --- index.html | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index 5634cd4..9c21585 100644 --- a/index.html +++ b/index.html @@ -19,14 +19,18 @@ , html = $this.html() $this.empty().append($('

').html(html)) }) + + $('div').background_drag(function(e){ + $(this).find("span").text(e.posX + 'px x ' + e.posY + 'px') + }) }) -

default
-
bound: false
+
default | 0px x 0px
+
bound: false | 0px x 0px


-
axis: 'x'
-
axis: 'y'
+
axis: 'x' | 0px x 0px
+
axis: 'y' | 0px x 0px