-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcourses.js
More file actions
46 lines (40 loc) · 1.03 KB
/
courses.js
File metadata and controls
46 lines (40 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//documents used
document.onmousemove = mouseMove;
document.onmouseup = mouseUp;
//my variables
var dragObject = null;
//functions
/* onmousemove ... mouseMove(ev):
* takes an event and changes the current coordinates
* of the mouse as it moves.
*/
function mouseMove(ev){
ev = ev || window.event;
var mousePos = mouseCoords(ev);
}
/* onmousemove ... mouseCoords(ev):
* takes an event, and actively chanes the coordinates.
*/
function mouseCoords(ev){
if(ev.pageX || ev.pageY){
return{x:ev.pageX, y:ev.pageY};
}
return{
x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
y:ev.clientY + document.body.scrollTop - document.body.clientTop
};
}
/* onmouseup ... makeClickable(object):
* makes the given object clickable.
*/
function makeClickable(object){
object.onmousedown = function(){
dragObject = this;
}
}
/* onmouseup ... mouseUp(ev):
* if the mouse is not clicked, its drag properties do not exist/happen.
*/
function mouseUp(ev){
dragObject = null;
}