The URI of TUHH Docker Registry changed from "docker.rz.tu-harburg.de:5000" to "docker.rz.tu-harburg.de". Please update your gitlab-ci.yml files if you use images from this registry.

Commit ca706ea3 authored by Tobias Zeumer's avatar Tobias Zeumer

Detect mouse to determine if "which" option (panzoom) and loading...

Detect mouse to determine if "which" option (panzoom) and loading JQuery.mousewheel is necessary; #31 (and #4)
parent 19f1c13d
......@@ -27,7 +27,6 @@
<script type="text/javascript" src="node_modules/jquery/dist/jquery.min.js?v3.3.1" defer></script>
<script type="text/javascript" src="node_modules/jquery-lang-js/js/jquery-lang.js?v3.0.3" defer></script>
<script type="text/javascript" src="node_modules/jquery.panzoom/dist/jquery.panzoom.min.js?v3.2.2" defer></script>
<script type="text/javascript" src="node_modules/jquery.mousewheel/jquery.mousewheel.js?v3.1.9" defer></script> <!-- only needed for Firefox -->
<script type="text/javascript" src="js/tubmap.js?<?php echo $filetimes['js/tubmap.js'] ?>" defer></script>
<!-- link rel="stylesheet" href="css/main.css" -->
......
......@@ -3,8 +3,9 @@
/* #############################################################################
# Some globals
############################################################################# */
// Config vars
var pathJsSavePng = 'node_modules/save-svg-as-png/lib/saveSvgAsPng.js';
// Config vars
var pathJsSavePng = 'node_modules/save-svg-as-png/lib/saveSvgAsPng.js';
var pathJqMousewheel = 'node_modules/jquery.mousewheel/jquery.mousewheel.js?v3.1.9';
var screenSaverTime = 5 * 60 * 1000; // Reset page after 5 minutes
var allow_logging = true; // Requires php. Logs field:value with /logger.php
......@@ -69,20 +70,26 @@ $( document ).ready(function() {
$zoomOut: $('.zoom-out'),
$zoomRange: $('.zoom-range'),
$reset: $('.zoom-reset'),
});
$panzoom.parent().on('mousewheel.focal', function( e ) {
e.preventDefault();
var delta = e.delta || e.originalEvent.wheelDelta;
var zoomOut = delta ? delta < 0 : e.originalEvent.deltaY > 0;
$panzoom.panzoom('zoom', zoomOut, {
increment: 0.1,
animate: false,
focal: e
});
});
// Add onetime event listener, that just changes "which" if a mouse is detected
});
// Add onetime event listener, that changes "which" if a mouse is detected
// Also only set mousewheel stuff if a it exists
window.addEventListener('mousemove', function() {
$("#tubhh").panzoom("option", "which", 1);
// JQuery.mousewheel only needed for Firefox to make wheel work
postload_js(pathJqMousewheel, false, function() {
// Set zoom center at mouse pointer (needed for all browsers)
$panzoom.parent().on('mousewheel.focal', function( e ) {
e.preventDefault();
var delta = e.delta || e.originalEvent.wheelDelta;
var zoomOut = delta ? delta < 0 : e.originalEvent.deltaY > 0;
$panzoom.panzoom('zoom', zoomOut, {
increment: 0.1,
animate: false,
focal: e
});
});
});
}, {once: true});
/*
// Other way around; but this requires on simple touch before doing any pinching
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment