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