Javier López-Contreras | 6d1d72d | 2018-12-27 23:17:18 +0100 | [diff] [blame] | 1 | // *********** HERE STARTS camera.js *************
|
| 2 |
|
| 3 |
|
Javier López-Contreras | 052503f | 2018-12-26 12:34:42 +0100 | [diff] [blame] | 4 | window.addEventListener('load', initCamera);
|
| 5 |
|
| 6 | function 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-Contreras | 6d1d72d | 2018-12-27 23:17:18 +0100 | [diff] [blame] | 13 | function 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-Contreras | 052503f | 2018-12-26 12:34:42 +0100 | [diff] [blame] | 18 |
|
Javier López-Contreras | 6d1d72d | 2018-12-27 23:17:18 +0100 | [diff] [blame] | 19 | 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 |
|
| 29 | function 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-Contreras | 052503f | 2018-12-26 12:34:42 +0100 | [diff] [blame] | 37 | });
|
Javier López-Contreras | 6d1d72d | 2018-12-27 23:17:18 +0100 | [diff] [blame] | 38 |
|
| 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-Contreras | 052503f | 2018-12-26 12:34:42 +0100 | [diff] [blame] | 53 | }
|