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); 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