Skip to content

Commit

Permalink
[ui:navbar] more finer control of swipe to close
Browse files Browse the repository at this point in the history
  • Loading branch information
nao-pon committed Aug 31, 2017
1 parent c57a41b commit f05c65d
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 12 deletions.
16 changes: 14 additions & 2 deletions js/commands/quicklook.plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,12 @@ elFinder.prototype.commands.quicklook.plugins = [
node.append('<div class="elfinder-quicklook-preview-charsleft"><hr/><span>' + fm.i18n('charsLeft', fm.toLocaleString(more)) + '</span></div>');
}

node.appendTo(preview);
node.on('touchstart', function(e) {
var scrL, scrR;
if ((scrL = node.scrollLeft()) || (scrR = node.scrollRight())) {
((fm.direction === 'ltr'? scrR : scrL) > 5) && (e.originalEvent._preventSwipe = true);
}
}).appendTo(preview);

PRcheck(node, 100);
})
Expand Down Expand Up @@ -592,7 +597,14 @@ elFinder.prototype.commands.quicklook.plugins = [
filenames.sort();
loading.remove();
header = '<strong>'+fm.escape(file.mime)+'</strong> ('+fm.formatSize(file.size)+')'+'<hr/>'
doc = $('<div class="elfinder-quicklook-preview-archive-wrapper">'+header+'<pre class="elfinder-quicklook-preview-text">'+fm.escape(filenames.join("\n"))+'</pre></div>').appendTo(preview);
doc = $('<div class="elfinder-quicklook-preview-archive-wrapper">'+header+'<pre class="elfinder-quicklook-preview-text">'+fm.escape(filenames.join("\n"))+'</pre></div>')
.on('touchstart', function(e) {
var scrL, scrR;
if ((scrL = doc.scrollLeft()) || (scrR = doc.scrollRight())) {
((fm.direction === 'ltr'? scrR : scrL) > 5) && (e.originalEvent._preventSwipe = true);
}
})
.appendTo(preview);
ql.hideinfo();
}
}, 70);
Expand Down
7 changes: 3 additions & 4 deletions js/elFinder.js
Original file line number Diff line number Diff line change
Expand Up @@ -4208,7 +4208,7 @@ var elFinder = function(node, opts, bootCallback) {
handleW, handleH = 50;

node.on('touchstart touchmove touchend', function(e) {
if (e.type === 'touchend') {
if (e.type === 'touchend' || e.originalEvent._preventSwipe) {
lastX = false;
lastY = false;
moveOff();
Expand Down Expand Up @@ -4239,11 +4239,10 @@ var elFinder = function(node, opts, bootCallback) {
}
} else {
navbarW = navbar.width();
treeWidth = Math.max.apply(Math, $.map(navbar.children('.elfinder-tree'), function(c){return $(c).width();}));
if (ltr) {
swipeX = (x < nodeOffset.left + navbarW && treeWidth - navbar.scrollLeft() - 5 <= navbarW);
swipeX = (x < nodeOffset.left + navbarW);
} else {
swipeX = (x > nodeOffset.left + nodeWidth - navbarW && treeWidth - navbar.scrollRight() - 5 <= navbarW);
swipeX = (x > nodeOffset.left + nodeWidth - navbarW);
}
if (swipeX) {
handleW = Math.max(50, nodeWidth / 10);
Expand Down
2 changes: 1 addition & 1 deletion js/jquery.elfinder.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ if (! $.fn.scrollRight) {
$.fn.extend({
scrollRight: function (val) {
if (val === undefined) {
return this[0].scrollWidth - (this[0].scrollLeft + this[0].clientWidth) + 1;
return Math.max(0, this[0].scrollWidth - (this[0].scrollLeft + this[0].clientWidth));
}
return this.scrollLeft(this[0].scrollWidth - this[0].clientWidth - val);
}
Expand Down
5 changes: 5 additions & 0 deletions js/ui/navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ $.fn.elfindernavbar = function(fm, opts) {
});
autoHide.navbar = (mode !== 'show');
fm.storage('autoHide', Object.assign(fm.storage('autoHide'), {navbar: autoHide.navbar}));
}).on('touchstart', function(e) {
var scrL, scrR;
if ((scrL = nav.scrollLeft()) || (scrR = nav.scrollRight())) {
((fm.direction === 'ltr'? scrR : scrL) > 5) && (e.originalEvent._preventSwipe = true);
}
});
}

Expand Down
5 changes: 0 additions & 5 deletions js/ui/navdock.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,6 @@ $.fn.elfindernavdock = function(fm, opts) {
self.height(0).hide();
}
fm.trigger('wzresize');
}).on('touchmove', function(e) {
if (! $(e.target).hasClass('elfinder-quicklook-preview')) {
// prevent swipe action on contents preview
e.stopPropagation();
}
});

if (! opts.disabled) {
Expand Down

0 comments on commit f05c65d

Please sign in to comment.