Skip to content

Commit

Permalink
Fixed a bug that prevented dragstart(), drag() and dragstop() events …
Browse files Browse the repository at this point in the history
…from firing on layers apart of a draggable group

- Also updated links in the README
  • Loading branch information
Caleb Evans committed Jul 3, 2013
1 parent 79331c8 commit 07db9f9
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 15 deletions.
21 changes: 13 additions & 8 deletions README.md
@@ -1,20 +1,25 @@
# [jCanvas](http://calebevans.me/projects/jcanvas/)
*Copyright 2013, Caleb Evans*

jCanvas is a jQuery plugin that makes the HTML5 canvas easy to work with.
jCanvas is a jQuery plugin, written in JavaScript, that makes the HTML5 canvas easy to work with.

## [Download](http://calebevans.me/projects/jcanvas/downloads.php)
## [Download](http://calebevans.me/projects/jcanvas/downloads/)

jCanvas requires jQuery 1.4 or newer, and supports both desktop and mobile browsers.

## [Documentation](http://calebevans.me/projects/jcanvas/downloads.php)
## [Documentation](http://calebevans.me/projects/jcanvas/docs/)

Please read the documentation before emailing me any questions you may have. If something in the documentation doesn't make sense, feel free to [email me](mailto:calebevans.me@gmail.com) for clarification.
Please read the documentation before emailing me any questions you may have. If something in the documentation isn't clear, feel free to [email me](mailto:calebevans.me@gmail.com) for clarification.

## [Support](http://calebevans.me/projects/jcanvas/support.php)
## [Support](http://calebevans.me/projects/jcanvas/support/)

Where to find help regarding jCanvas.
If you are reporting a jCanvas bug, please include the following information in your report:

## [License](https://github.com/caleb531/jcanvas/blob/master/license.txt)
* The version of jCanvas you used
* A complete code sample that reproduces the issue
* What you expected to happen
* What happened instead

jCanvas is licensed under the MIT license.
## [License](https://github.com/caleb531/jcanvas/blob/master/LICENSE.txt)

jCanvas is available as a free and open-source library under the MIT license.
2 changes: 1 addition & 1 deletion jcanvas.jquery.json
@@ -1,7 +1,7 @@
{
"name": "jcanvas",
"title": "jCanvas",
"version": "13.06.26",
"version": "13.07.03",
"author": {
"name": "Caleb Evans",
"email": "calebevans.me@gmail.com",
Expand Down
28 changes: 24 additions & 4 deletions jcanvas.js
@@ -1,5 +1,5 @@
/**
* jCanvas v13.06.26
* jCanvas v13.07.03
* Copyright 2013 Caleb Evans
* Released under the MIT license
*/
Expand Down Expand Up @@ -1145,6 +1145,11 @@ $.fn.drawLayers = function drawLayers(args) {
// Ensure layer index is accurate
group[l].index = layers.length - 2;
}
// Trigger dragstart event if defined
if (group[l].dragstart) {
group[l].dragstart.call($canvases[e], group[l]);
}

}
}

Expand All @@ -1158,7 +1163,7 @@ $.fn.drawLayers = function drawLayers(args) {

// Trigger dragstart event if defined
if (drag.layer.dragstart) {
drag.layer.dragstart.call($canvas, drag.layer);
drag.layer.dragstart.call($canvas[0], drag.layer);
}

}
Expand All @@ -1175,25 +1180,40 @@ $.fn.drawLayers = function drawLayers(args) {
if (group[l] !== drag.layer) {
group[l].x = drag.layer._eventX - (group[l]._endX - group[l]._startX);
group[l].y = drag.layer._eventY - (group[l]._endY - group[l]._startY);
// Trigger drag event if defined
if (group[l].drag) {
group[l].drag.call($canvases[e], group[l]);
}
}
}

}

// Trigger drag event if defined
if (drag.layer.drag) {
drag.layer.drag.call($canvas, drag.layer);
drag.layer.drag.call($canvases[e], drag.layer);
}

} else if ((eventType === 'mouseup' || eventType === 'touchend')) {
// Detect when user stops dragging layer

// Trigger dragstop event if defined
if (drag.layer.dragstop && drag.dragging) {
drag.layer.dragstop.call($canvas, drag.layer);
drag.layer.dragstop.call($canvases[e], drag.layer);
drag.dragging = FALSE;
}

group = data.layer.groups[drag.layer.group];
if (drag.layer.group && drag.layer.dragGroupWithLayer && group) {
for (l = 0; l < group.length; l += 1) {
if (group[l] !== drag.layer) {
// Trigger dragstart event if defined
if (group[l].dragstop) {
group[l].dragstop.call($canvases[e], group[l]);
}
}
}
}
// Cancel dragging
data.drag = {};

Expand Down

0 comments on commit 07db9f9

Please sign in to comment.