-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathImageViewer.js
85 lines (76 loc) · 1.52 KB
/
ImageViewer.js
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//Album
function ImageWrap() {
this.image = new Image();
this.imageWidth = 0;
this.imageHeight = 0;
}
function Album() {
this.images = new Array();
this.imageLoaders = new Array();
}
Album.prototype.addImage = function (image) {
image.add(image);
}
Album.prototype.getImage = function (index) {
return this.images[index];
}
Album.prototype.addImages = function (imageArr) {
for (int i=0; i<imageArr.size(); i++)
{
image.add(imageArr[i]);
}
}
//ImageViewer
function ImageViewer(canvasObj) {
//init
this.canvas = canvasObj;
this.curimg = -1;
this.startX = 0;
this.startY = 0;
this.degrees = 0;
this.cWidth = 630;
this.cHeight = 460;
this.resizeTimeoutId = null; //it's here...
this.timeoutId = null;
this.maxWidth = 0;
this.maxHeight = 0;
this.cscale = 1.0;
this.fullsize = false;
this.loadct = 0;
//=============================
//Create canvas to draw image to:
//canvas = document.getElementById('canvas');
if (canvas.addEventListener)
{
canvas.addEventListener("click", canvasonclick, false);
}
else //IE
{
canvas.attachEvent("onclick", canvasonclick );
}
setsize();
if (document.addEventListener)
{
document.addEventListener("keydown", canvasonkey, false);
}
else
{
document.attachEvent("onkeydown", canvasonkey);
}
cview = canvas.getContext("2d");
preloadImagesTimer();
//Draw initial image:
if (curimg==galleryarray.length-1)
{
lastimage();
}
else if (curimg==0)
{
firstimage();
}
else
{
loadimage(curimg);
}
}
};