blob: 44e9f5dced89cc3ca7bcd7f8071b8df6cf9b78db [file] [log] [blame]
Javier López-Contreras6d1d72d2018-12-27 23:17:18 +01001// *********** HERE STARTS camera.js *************
2
3
Javier López-Contreras052503f2018-12-26 12:34:42 +01004window.addEventListener('load', initCamera);
5
6function cameraGoto(nodeX, nodeY) {
7 sigma.misc.animation.camera( s.camera,
8 { x: nodeX, y: nodeY, ratio: 1 },
9 { duration: s.settings('animationsTime') || 300 }
10 );
11}
12
Javier López-Contreras6d1d72d2018-12-27 23:17:18 +010013function is_touch_device() {
14 var prefixes = ' -webkit- -moz- -o- -ms- '.split(' ');
15 var mq = function(query) {
16 return window.matchMedia(query).matches;
17 }
Javier López-Contreras052503f2018-12-26 12:34:42 +010018
Javier López-Contreras6d1d72d2018-12-27 23:17:18 +010019 if (('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch) {
20 return true;
21 }
22
23 // include the 'heartz' as a way to have a non matching MQ to help terminate the join
24 // https://git.io/vznFH
25 var query = ['(', prefixes.join('touch-enabled),('), 'heartz', ')'].join('');
26 return mq(query);
27}
28
29function initCamera() {
30
31 if(!is_touch_device()) {
32
33 document.querySelector("#zoomin").addEventListener("click", function() {
34 s.camera.goTo({
35 ratio: Math.max(s.camera.settings("zoomMin"), s.camera.ratio / Math.sqrt(2))
36 });
Javier López-Contreras052503f2018-12-26 12:34:42 +010037 });
Javier López-Contreras6d1d72d2018-12-27 23:17:18 +010038
39 document.querySelector("#zoomout").addEventListener("click", function() {
40 s.camera.goTo({
41 ratio: Math.min(s.camera.settings("zoomMax"), s.camera.ratio * Math.sqrt(2))
42 });
43 });
44 }
45 else{
46 document.querySelector("#zoomin").style.display = "none";
47 document.querySelector("#zoomout").style.display = "none";
48
49 document.querySelector("#circle-mode").style.bottom = "110px";
50 document.querySelector("#settings").style.bottom = "60px";
51 document.querySelector("#search").style.bottom = "10px";
52 }
Javier López-Contreras052503f2018-12-26 12:34:42 +010053}