-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1465d37
commit c52d58e
Showing
11 changed files
with
235 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
|
||
const elemMedcalf = 'medcalf' | ||
const objMedcalf = document.getElementById(elemMedcalf); | ||
|
||
objMedcalf.onmousedown = function(event) { | ||
|
||
console.log("an attempt to move") | ||
|
||
if (window.location.pathname !== '/dm') { | ||
return; | ||
} | ||
|
||
let shiftX = event.clientX - objMedcalf.getBoundingClientRect().left; | ||
let shiftY = event.clientY - objMedcalf.getBoundingClientRect().top; | ||
|
||
objMedcalf.style.position = 'absolute'; | ||
objMedcalf.style.zIndex = 1000; | ||
document.body.append(objMedcalf); | ||
|
||
moveAt(event.pageX, event.pageY); | ||
|
||
function moveAt(pageX, pageY) { | ||
objMedcalf.style.left = pageX - shiftX + 'px'; | ||
objMedcalf.style.top = pageY - shiftY + 'px'; | ||
} | ||
|
||
function onMouseMove(event) { | ||
moveAt(event.pageX, event.pageY); | ||
} | ||
|
||
function getLocation() { | ||
const X = window.scrollX + objMedcalf.getBoundingClientRect().left; | ||
const Y = window.scrollY + objMedcalf.getBoundingClientRect().top; | ||
return {X, Y}; | ||
} | ||
|
||
document.addEventListener('mousemove', onMouseMove); | ||
|
||
objMedcalf.onmouseup = function() { | ||
document.removeEventListener('mousemove', onMouseMove); | ||
//trigger a web socket event | ||
socket.emit('change', {location: getLocation(), element: elemMedcalf}) | ||
objMedcalf.onmouseup = null; | ||
}; | ||
|
||
}; | ||
|
||
objMedcalf.ondragstart = function() { | ||
return false; | ||
}; | ||
|
||
socket.on('change', function(input){ | ||
console.log("Change has been detected") | ||
console.log(input.location.X, input.location.Y) | ||
console.log(input.element) | ||
|
||
if (input.element === elemMedcalf) { | ||
objMedcalf.style.position = 'absolute'; | ||
objMedcalf.style.zIndex = 1000; | ||
document.body.append(objMedcalf); | ||
|
||
moveAt(input.location.X, input.location.Y); | ||
|
||
function moveAt(shiftX, shiftY) { | ||
objMedcalf.style.left = shiftX + 'px'; | ||
objMedcalf.style.top = shiftY + 'px'; | ||
} | ||
} | ||
|
||
}); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
|
||
const elemFiona = 'fiona' | ||
const objFiona = document.getElementById(elemFiona); | ||
|
||
objFiona.onmousedown = function(event) { | ||
|
||
console.log("an attempt to move") | ||
|
||
if (window.location.pathname !== '/dm') { | ||
return; | ||
} | ||
|
||
let shiftX = event.clientX - objFiona.getBoundingClientRect().left; | ||
let shiftY = event.clientY - objFiona.getBoundingClientRect().top; | ||
|
||
objFiona.style.position = 'absolute'; | ||
objFiona.style.zIndex = 1000; | ||
document.body.append(objFiona); | ||
|
||
moveAt(event.pageX, event.pageY); | ||
|
||
function moveAt(pageX, pageY) { | ||
objFiona.style.left = pageX - shiftX + 'px'; | ||
objFiona.style.top = pageY - shiftY + 'px'; | ||
} | ||
|
||
function onMouseMove(event) { | ||
moveAt(event.pageX, event.pageY); | ||
} | ||
|
||
function getLocation() { | ||
const X = window.scrollX + objFiona.getBoundingClientRect().left; | ||
const Y = window.scrollY + objFiona.getBoundingClientRect().top; | ||
return {X, Y}; | ||
} | ||
|
||
document.addEventListener('mousemove', onMouseMove); | ||
|
||
objFiona.onmouseup = function() { | ||
document.removeEventListener('mousemove', onMouseMove); | ||
//trigger a web socket event | ||
socket.emit('change', {location: getLocation(), element: elemFiona}) | ||
objFiona.onmouseup = null; | ||
}; | ||
|
||
}; | ||
|
||
objFiona.ondragstart = function() { | ||
return false; | ||
}; | ||
|
||
socket.on('change', function(input){ | ||
console.log("Change has been detected") | ||
console.log(input.location.X, input.location.Y) | ||
console.log(input.element) | ||
|
||
if (input.element === elemFiona) { | ||
objFiona.style.position = 'absolute'; | ||
objFiona.style.zIndex = 1000; | ||
document.body.append(objFiona); | ||
|
||
moveAt(input.location.X, input.location.Y); | ||
|
||
function moveAt(shiftX, shiftY) { | ||
objFiona.style.left = shiftX + 'px'; | ||
objFiona.style.top = shiftY + 'px'; | ||
} | ||
} | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
|
||
const elemHannah = 'hannah' | ||
const objHannah = document.getElementById(elemHannah); | ||
|
||
objHannah.onmousedown = function(event) { | ||
|
||
console.log("an attempt to move") | ||
|
||
if (window.location.pathname !== '/dm') { | ||
return; | ||
} | ||
|
||
let shiftX = event.clientX - objHannah.getBoundingClientRect().left; | ||
let shiftY = event.clientY - objHannah.getBoundingClientRect().top; | ||
|
||
objHannah.style.position = 'absolute'; | ||
objHannah.style.zIndex = 1000; | ||
document.body.append(objHannah); | ||
|
||
moveAt(event.pageX, event.pageY); | ||
|
||
function moveAt(pageX, pageY) { | ||
objHannah.style.left = pageX - shiftX + 'px'; | ||
objHannah.style.top = pageY - shiftY + 'px'; | ||
} | ||
|
||
function onMouseMove(event) { | ||
moveAt(event.pageX, event.pageY); | ||
} | ||
|
||
function getLocation() { | ||
const X = window.scrollX + objHannah.getBoundingClientRect().left; | ||
const Y = window.scrollY + objHannah.getBoundingClientRect().top; | ||
return {X, Y}; | ||
} | ||
|
||
document.addEventListener('mousemove', onMouseMove); | ||
|
||
objHannah.onmouseup = function() { | ||
document.removeEventListener('mousemove', onMouseMove); | ||
//trigger a web socket event | ||
socket.emit('change', {location: getLocation(), element: elemHannah}) | ||
objHannah.onmouseup = null; | ||
}; | ||
|
||
}; | ||
|
||
objHannah.ondragstart = function() { | ||
return false; | ||
}; | ||
|
||
socket.on('change', function(input){ | ||
console.log("Change has been detected") | ||
console.log(input.location.X, input.location.Y) | ||
console.log(input.element) | ||
|
||
if (input.element === elemHannah) { | ||
objHannah.style.position = 'absolute'; | ||
objHannah.style.zIndex = 1000; | ||
document.body.append(objHannah); | ||
|
||
moveAt(input.location.X, input.location.Y); | ||
|
||
function moveAt(shiftX, shiftY) { | ||
objHannah.style.left = shiftX + 'px'; | ||
objHannah.style.top = shiftY + 'px'; | ||
} | ||
} | ||
|
||
}); |