aboutsummaryrefslogtreecommitdiff
path: root/panel.js
blob: 1f02c5fc304aa1dba4e111608a25c8da05089e94 (plain) (blame)
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
var fold=true;
function setupevents()
{
	window.ontouchstart=function(e)
	{
		x1=e.touches[0].screenX;
		y1=e.touches[0].screenY;
	}
	window.ontouchmove=function(e)
	{
		x2=e.touches[0].screenX;
		y2=e.touches[0].screenY;
	}
	window.ontouchend=function(e)
	{
		x2=e.changedTouches[0].screenX;
		y2=e.changedTouches[0].screenY;
		if(Math.abs(x1-x2)<20&&Math.abs(y1-y2)<20)
		{
			if(x2<document.getElementById("panel").getClientRects()[0].right&&fold)
			{document.getElementById("panel").style.left="0";fold=false;}
			if(x2>document.getElementById("panel").getClientRects()[0].right&&!fold)
			{document.getElementById("panel").style.left="-15em";fold=true;}
		}
		if(x2-x1>window.innerWidth*0.2)
		{document.getElementById("panel").style.left="0";fold=false;}
		if(x1-x2>window.innerWidth*0.2)
		{document.getElementById("panel").style.left="-15em";fold=true;}
	}
	document.getElementById("panel").onmouseenter=function()
	{
		if(fold)
		{document.getElementById("panel").style.left="0";fold=false;}
	}
	document.getElementById("panel").onmouseleave=function()
	{
		if(!fold)
		{document.getElementById("panel").style.left="-15em";fold=true;}
	} 
}
function unsetevents()
{
	window.ontouchstart=undefined;
	window.ontouchmove=undefined;
	window.ontouchend=undefined;
	document.getElementById("panel").onmouseenter=undefined;
	document.getElementById("panel").onmouseleave=undefined;
}