blob: a1d3044566427f857c990d6388e82a20b18dc82d [file] [log] [blame]
Javier López-Contreras052503f2018-12-26 12:34:42 +01001function cameraGoto(nodeX, nodeY) {
2 sigma.misc.animation.camera( s.camera,
3 { x: nodeX, y: nodeY, ratio: 1 },
4 { duration: s.settings('animationsTime') || 300 }
5 );
6}
7
Javier López-Contreras6d1d72d2018-12-27 23:17:18 +01008function is_touch_device() {
avm99963027b5b02018-12-28 02:31:46 +01009 var prefixes = ' -webkit- -moz- -o- -ms- '.split(' ');
10 var mq = function(query) {
11 return window.matchMedia(query).matches;
12 }
Javier López-Contreras052503f2018-12-26 12:34:42 +010013
avm99963027b5b02018-12-28 02:31:46 +010014 if (('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch) {
15 return true;
16 }
Javier López-Contreras6d1d72d2018-12-27 23:17:18 +010017
avm99963027b5b02018-12-28 02:31:46 +010018 // include the 'heartz' as a way to have a non matching MQ to help terminate the join
19 // https://git.io/vznFH
20 var query = ['(', prefixes.join('touch-enabled),('), 'heartz', ')'].join('');
21 return mq(query);
Javier López-Contreras6d1d72d2018-12-27 23:17:18 +010022}
23
24function initCamera() {
Javier López-Contreras6d1d72d2018-12-27 23:17:18 +010025 if(!is_touch_device()) {
Javier López-Contreras6d1d72d2018-12-27 23:17:18 +010026 document.querySelector("#zoomin").addEventListener("click", function() {
27 s.camera.goTo({
28 ratio: Math.max(s.camera.settings("zoomMin"), s.camera.ratio / Math.sqrt(2))
29 });
Javier López-Contreras052503f2018-12-26 12:34:42 +010030 });
avm99963027b5b02018-12-28 02:31:46 +010031
Javier López-Contreras6d1d72d2018-12-27 23:17:18 +010032 document.querySelector("#zoomout").addEventListener("click", function() {
33 s.camera.goTo({
34 ratio: Math.min(s.camera.settings("zoomMax"), s.camera.ratio * Math.sqrt(2))
35 });
36 });
avm99963027b5b02018-12-28 02:31:46 +010037 } else {
Javier López-Contreras6d1d72d2018-12-27 23:17:18 +010038 document.querySelector("#zoomin").style.display = "none";
39 document.querySelector("#zoomout").style.display = "none";
avm99963027b5b02018-12-28 02:31:46 +010040
Javier López-Contreras6d1d72d2018-12-27 23:17:18 +010041 document.querySelector("#circle-mode").style.bottom = "110px";
42 document.querySelector("#settings").style.bottom = "60px";
43 document.querySelector("#search").style.bottom = "10px";
44 }
Javier López-Contreras052503f2018-12-26 12:34:42 +010045}