Browse Source

Added swipe support in Photo embedded viewer

TC pushbot 5 4 years ago
parent
commit
06e13d2051

+ 66 - 5
web/Photo/embedded.html

@@ -5,11 +5,16 @@
 <head>
     <meta charset="UTF-8">
     <meta name="theme-color" content="#4b75ff">
-    <title>Photo Preview</title>
+    <title>Photo Viewer</title>
     <script src="../script/jquery.min.js"></script>
     <script src="../script/ao_module.js"></script>
     <link rel="manifest" href="manifest.json">
     <style>
+        body{
+            margin: 0px !important;
+            background:rgba(34,34,34,1);
+            overflow: hidden;
+        }
         .arrow{
             width: 2em;
             opacity: 0.5;
@@ -27,8 +32,8 @@
         }
     </style>
 </head>
-<body style="background:rgba(34,34,34,1);overflow:hidden;">
-    <img id="img" style="max-height: 100vh;max-width: 100vw;">
+<body>
+    <img id="img" style="max-height: 100vh;max-width: 100%;">
     <img class="left arrow" onclick="previousImage();" src="embedded/arrow-left.svg">
     <img class="right arrow" onclick="nextImage();" src="embedded/arrow-right.svg">
     <script>
@@ -125,9 +130,65 @@
         }
 
         function updateImgSize() {
-            $('#img').css("margin-top", (window.innerHeight - $("#img").height()) / 2 - 6);
-            $('#img').css("margin-left", (window.innerWidth - $("#img").width()) / 2 - 6);
+            $('#img').css("margin-top", (window.innerHeight - $("#img").height()) / 2);
+            $('#img').css("margin-left", (window.innerWidth - $("#img").width()) / 2);
         }
+
+        //Touch gesture detections
+        document.addEventListener('touchstart', handleTouchStart, false);        
+        document.addEventListener('touchmove', handleTouchMove, false);
+
+        var xDown = null;                                                        
+        var yDown = null;
+
+        function getTouches(evt) {
+        return evt.touches ||             // browser API
+                evt.originalEvent.touches; // jQuery
+        }                                                     
+                                                                                
+        function handleTouchStart(evt) {
+            const firstTouch = getTouches(evt)[0];                                      
+            xDown = firstTouch.clientX;
+            yDown = firstTouch.clientY;
+        };
+
+
+        function handleTouchMove(evt) {
+            if ( ! xDown || ! yDown ) {
+                return;
+            }
+
+            var xUp = evt.touches[0].clientX;                                    
+            var yUp = evt.touches[0].clientY;
+
+            var xDiff = xDown - xUp;
+            var yDiff = yDown - yUp;
+                                                                                
+            if ( Math.abs( xDiff ) > Math.abs( yDiff ) ) {/*most significant*/
+                if ( xDiff > 0 ) {
+                    /* right swipe */ 
+                    nextImage();
+                } else {
+                    /* left swipe */
+                    previousImage();
+                }                       
+            } else {
+                if ( yDiff > 0 ) {
+                    /* down swipe */ 
+                } else { 
+                    /* up swipe */
+                }                                                                 
+            }
+
+            /* reset values */
+            xDown = null;
+            yDown = null;                        
+        };
+
+        function isZoomed(){
+            return window.matchMedia('(max--moz-device-pixel-ratio:0.99), (min--moz-device-pixel-ratio:1.01)').matches;
+        }
+
     </script>
 </body>
 

+ 21 - 0
web/Photo/embedded/pinchzoom-2.3.4/LICENSE

@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2013-now Manuel Stofer
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.

File diff suppressed because it is too large
+ 0 - 0
web/Photo/embedded/pinchzoom-2.3.4/pinch-zoom.min.js


Some files were not shown because too many files changed in this diff