Close menus by sliding objects on mobile

This commit is contained in:
2022-09-26 16:47:36 +02:00
parent af8d19591c
commit 3d67ff3103
5 changed files with 43 additions and 17 deletions

View File

@@ -206,12 +206,9 @@ function initPage(asHash) {
//Add "Loading" Post //Add "Loading" Post
getPost({type: 'loading', headerless: true, formatted_time: '', relative_time: ''}).appendTo($('#loading')); getPost({type: 'loading', headerless: true, formatted_time: '', relative_time: ''}).appendTo($('#loading'));
/*
//Mobile events //Mobile events
$("#feed").onSwipe(function(aiDelta){ self.tmp('$Feed').onSwipe((oPos) => {if(oPos.xEnd - oPos.xStart > 100 && Math.abs(oPos.yEnd - oPos.yStart) < 100) toggleFeedPanel(false);});
if(aiDelta.x > self.tmp('$Feed').outerWidth(true)/3 && aiDelta.x > Math.abs(aiDelta.y)) toggleFeedPanel(false); self.tmp('$Settings').onSwipe((oPos) => {if(oPos.xEnd - oPos.xStart < -100 && Math.abs(oPos.yEnd - oPos.yStart) < 100) toggleSettingsPanel(false);});
});
*/
//Feed Panel //Feed Panel
initPosts(); initPosts();
@@ -932,7 +929,7 @@ function getPost(asPost) {
.hover( .hover(
function(){ function(){
var oMarker = oSpot.tmp(['markers', $(this).data('id')]); var oMarker = oSpot.tmp(['markers', $(this).data('id')]);
if(oSpot.tmp('map').getBounds().contains(oMarker.getLatLng()) && !oMarker.isPopupOpen()) oMarker.openPopup(); if(oSpot.tmp('map') && oSpot.tmp('map').getBounds().contains(oMarker.getLatLng()) && !oMarker.isPopupOpen()) oMarker.openPopup();
}, },
function(){ function(){
var oMarker = oSpot.tmp(['markers', $(this).data('id')]); var oMarker = oSpot.tmp(['markers', $(this).data('id')]);

View File

@@ -381,21 +381,46 @@ $.prototype.hoverSwap = function(sDefault, sHover)
.text(sDefault); .text(sDefault);
}; };
$.prototype.onSwipe = function(fCallBack){ $.prototype.onSwipe = function(fOnEnd){
return $(this) return $(this)
.on('mousedown touchstart', function(e) { .on('dragstart', (e) => {
var $This = $(this); e.preventDefault();
$This.data('x-down', e.pageX);
$This.data('y-down', e.pageY);
}) })
.on('mouseup touchend',function (e) { .on('mousedown touchstart', (e) => {
var $This = $(this); var $This = $(this);
var iDeltaX = e.pageX - $This.data('x-down'); var oPos = getDragPosition(e);
var iDeltaY = e.pageY - $This.data('y-down'); $This.data('x-start', oPos.x);
fCallBack({x:iDeltaX, y:iDeltaY}); $This.data('y-start', oPos.y);
$This.data('moving', true).addClass('moving');
})
.on('touchmove mousemove', (e) => {
var $This = $(this);
if($This.data('moving')) {
var oPos = getDragPosition(e);
$This.data('x-move', oPos.x);
$This.data('y-move', oPos.y);
}
})
.on('mouseup mouseleave touchend', (e) => {
var $This = $(this);
$This.data('moving', false).removeClass('moving');
fOnEnd({
xStart: $This.data('x-start'),
yStart: $This.data('y-start'),
xEnd: $This.data('x-move'),
yEnd: $This.data('y-move')
});
}); });
}; };
function getDragPosition(oEvent) {
let bMouse = oEvent.type.includes('mouse');
return {
x: bMouse?oEvent.pageX:oEvent.touches[0].clientX,
y: bMouse?oEvent.pageY:oEvent.touches[0].clientY
};
}
function copyTextToClipboard(text) { function copyTextToClipboard(text) {
if(!navigator.clipboard) { if(!navigator.clipboard) {
var textArea = document.createElement('textarea'); var textArea = document.createElement('textarea');

View File

@@ -73,7 +73,7 @@
} }
[title]:not(a):not(.clickable) { [title]:not(a):not(.clickable) {
cursor: default; cursor: inherit;
} }
.clickable { .clickable {

View File

@@ -93,7 +93,6 @@ $fa-css-prefix: fa;
.#{$fa-css-prefix}-drill-video:before { content: fa-content($fa-var-play-circle); } .#{$fa-css-prefix}-drill-video:before { content: fa-content($fa-var-play-circle); }
.#{$fa-css-prefix}-drill-image:before { content: fa-content($fa-var-search); } .#{$fa-css-prefix}-drill-image:before { content: fa-content($fa-var-search); }
.#{$fa-css-prefix}-drill-message:before { content: fa-content($fa-var-search-location); } .#{$fa-css-prefix}-drill-message:before { content: fa-content($fa-var-search-location); }
.#{$fa-css-prefix}-upload:before { content: fa-content($fa-var-cloud-upload); }
.#{$fa-css-prefix}-video-shot:before { content: fa-content($fa-var-camcorder); } .#{$fa-css-prefix}-video-shot:before { content: fa-content($fa-var-camcorder); }
.#{$fa-css-prefix}-image-shot:before { content: fa-content($fa-var-camera-alt); } .#{$fa-css-prefix}-image-shot:before { content: fa-content($fa-var-camera-alt); }
.#{$fa-css-prefix}-link:before { content: fa-content($fa-var-link); } .#{$fa-css-prefix}-link:before { content: fa-content($fa-var-link); }

View File

@@ -371,6 +371,11 @@ $legend-color: $post-color;
bottom: 0; bottom: 0;
overflow: hidden; overflow: hidden;
z-index: 999; z-index: 999;
cursor: grab;
&.moving {
cursor: grabbing;
}
input, textarea { input, textarea {
background-color: $post-input-bg; background-color: $post-input-bg;