Skip to content

Commit

Permalink
Pointer event fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
cwilso committed Sep 10, 2014
1 parent d6cfbd6 commit b03d799
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 29 deletions.
1 change: 0 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

<script src="http://cwilso.github.io/AudioContext-MonkeyPatch/AudioContextMonkeyPatch.js"></script>

<script src="js/pointerevents.js"></script>
<script src="js/main.js"></script>
<script src="js/dragging.js"></script>
<script src="js/analyser.js"></script>
Expand Down
40 changes: 20 additions & 20 deletions js/dragging.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ function startDraggingNode(event) {
dragObj.elNode.style.zIndex = ++dragObj.zIndex;

// Capture mousemove and mouseup events on the page.
// document.addEventListener("mousemove", skipDefault, true);
// document.addEventListener("mouseup", stopDraggingNode, true);
document.addEventListener( 'pointermove', whileDraggingNode, true );
document.addEventListener( 'pointerup', stopDraggingNode, true );
document.addEventListener( 'pointerleave', stopDraggingNode, true );
document.addEventListener("mousemove", whileDraggingNode, true);
document.addEventListener("mouseup", stopDraggingNode, true);
// document.addEventListener( 'pointermove', whileDraggingNode, true );
// document.addEventListener( 'pointerup', stopDraggingNode, true );
// document.addEventListener( 'pointerleave', stopDraggingNode, true );
event.preventDefault();
}

Expand Down Expand Up @@ -115,11 +115,11 @@ function whileDraggingNode(event) {

function stopDraggingNode(event) {
// Stop capturing mousemove and mouseup events.
// document.removeEventListener("mousemove", whileDraggingNode, true);
// document.removeEventListener("mouseup", stopDraggingNode, true);
document.removeEventListener( 'pointermove', whileDraggingNode, true );
document.removeEventListener( 'pointerup', stopDraggingNode, true );
document.removeEventListener( 'pointerleave', stopDraggingNode, true );
document.removeEventListener("mousemove", whileDraggingNode, true);
document.removeEventListener("mouseup", stopDraggingNode, true);
// document.removeEventListener( 'pointermove', whileDraggingNode, true );
// document.removeEventListener( 'pointerup', stopDraggingNode, true );
// document.removeEventListener( 'pointerleave', stopDraggingNode, true );
}

// Connector Dragging functions - these are used for dragging the connectors
Expand Down Expand Up @@ -175,11 +175,11 @@ function startDraggingConnector(event) {
document.getElementById("svgCanvas").appendChild(shape);

// Capture mousemove and mouseup events on the page.
// document.addEventListener("mousemove", whileDraggingConnector, true);
// document.addEventListener("mouseup", stopDraggingConnector, true);
document.addEventListener( 'pointermove', whileDraggingConnector, true );
document.addEventListener( 'pointerup', stopDraggingConnector, true );
document.addEventListener( 'pointerleave', stopDraggingConnector, true );
document.addEventListener("mousemove", whileDraggingConnector, true);
document.addEventListener("mouseup", stopDraggingConnector, true);
// document.addEventListener( 'pointermove', whileDraggingConnector, true );
// document.addEventListener( 'pointerup', stopDraggingConnector, true );
// document.addEventListener( 'pointerleave', stopDraggingConnector, true );
event.preventDefault();
event.stopPropagation();
}
Expand Down Expand Up @@ -371,11 +371,11 @@ function disconnectNode( nodeElement ) {

function stopDraggingConnector(event) {
// Stop capturing mousemove and mouseup events.
// document.removeEventListener("mousemove", whileDraggingConnector, true);
// document.removeEventListener("mouseup", stopDraggingConnector, true);
document.removeEventListener( 'pointermove', whileDraggingConnector, true );
document.removeEventListener( 'pointerup', stopDraggingConnector, true );
document.removeEventListener( 'pointerleave', stopDraggingConnector, true );
document.removeEventListener("mousemove", whileDraggingConnector, true);
document.removeEventListener("mouseup", stopDraggingConnector, true);
// document.removeEventListener( 'pointermove', whileDraggingConnector, true );
// document.removeEventListener( 'pointerup', stopDraggingConnector, true );
// document.removeEventListener( 'pointerleave', stopDraggingConnector, true );

if (dragObj.lastLit) {
dragObj.lastLit.className = dragObj.lastLit.unlitClassname;
Expand Down
16 changes: 8 additions & 8 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ function createNewModule( nodeType, input, output ) {
tempy = 100;

e.setAttribute("audioNodeType", nodeType );
e.addEventListener("mousedown", skipDefault, false);
e.addEventListener( 'pointerdown', startDraggingNode, false );
e.addEventListener("mousedown", startDraggingNode, false);
// e.addEventListener( 'pointerdown', startDraggingNode, false );
var content = document.createElement("div");
content.className="content";
e.appendChild(content);
Expand All @@ -46,8 +46,8 @@ function createNewModule( nodeType, input, output ) {
if (input) {
var i=document.createElement("div");
i.className="node node-input ";
i.addEventListener( "mousedown", skipDefault, true );
i.addEventListener( 'pointerdown', startDraggingConnector, false );
i.addEventListener( "mousedown", startDraggingConnector, true );
// i.addEventListener( 'pointerdown', startDraggingConnector, false );
i.innerHTML = "<span class='node-button'>&nbsp;</span>";
e.appendChild(i);
e.inputs = i;
Expand All @@ -56,8 +56,8 @@ function createNewModule( nodeType, input, output ) {
if (output) {
var i=document.createElement("div");
i.className="node node-output";
i.addEventListener( "mousedown", skipDefault, true );
i.addEventListener( 'pointerdown', startDraggingConnector, false );
i.addEventListener( "mousedown", startDraggingConnector, true );
// i.addEventListener( 'pointerdown', startDraggingConnector, false );
i.innerHTML = "<span class='node-button'>&nbsp;</span>";
e.appendChild(i);
e.outputs = i;
Expand Down Expand Up @@ -886,8 +886,8 @@ function startLoadingSounds() {
function setClickHandler( id, handler ) {
var el = document.getElementById( id );
if (el) {
el.addEventListener( "mousedown", skipDefault, true );
el.addEventListener( "pointerdown", handler, false );
el.addEventListener( "mousedown", handler, true );
// el.addEventListener( "pointerdown", handler, false );
}
}

Expand Down

0 comments on commit b03d799

Please sign in to comment.