Skip to content

Commit

Permalink
scrollbugfix for vertical submenus
Browse files Browse the repository at this point in the history
  • Loading branch information
Fred Heusschen committed May 12, 2020
1 parent 5871e38 commit afb8b13
Show file tree
Hide file tree
Showing 10 changed files with 223 additions and 76 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "frdh/mmenu.js",
"version": "8.5.7",
"version": "8.5.8",
"authors": [
{
"name": "Fred Heusschen",
Expand Down
8 changes: 6 additions & 2 deletions dist/_modules/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ export function find(element, filter) {
*/
export function children(element, filter) {
var children = Array.prototype.slice.call(element.children);
return filter ? children.filter(function (child) { return child.matches(filter); }) : children;
return filter
? children.filter(function (child) { return child.matches(filter); })
: children;
}
/**
* Find text excluding text from within child elements.
Expand Down Expand Up @@ -65,7 +67,9 @@ export function parents(element, filter) {
parents.push(parent);
parent = parent.parentElement;
}
return filter ? parents.filter(function (parent) { return parent.matches(filter); }) : parents;
return filter
? parents.filter(function (parent) { return parent.matches(filter); })
: parents;
}
/**
* Find all previous siblings matching the selecotr.
Expand Down
11 changes: 9 additions & 2 deletions dist/addons/searchfield/mmenu.searchfield.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
var __spreadArrays = (this && this.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
import Mmenu from '../../core/oncanvas/mmenu.oncanvas';
import options from './_options';
import configs from './_configs';
Expand Down Expand Up @@ -280,8 +287,8 @@ var initNoResultsMsg = function (wrapper) {
wrapper.append(message);
};
Mmenu.prototype.search = function (input, query) {
var _this = this;
var _a;
var _this = this;
var options = this.opts.searchfield, configs = this.conf.searchfield;
query = query || '' + input.value;
query = query.toLowerCase().trim();
Expand Down Expand Up @@ -406,7 +413,7 @@ Mmenu.prototype.search = function (input, query) {
}
// Update parent for sub-panel
// .reverse() mutates the original array, therefor we "clone" it first using [...panels].
panels.slice().reverse().forEach(function (panel, p) {
__spreadArrays(panels).reverse().forEach(function (panel, p) {
var parent = panel['mmParent'];
if (parent) {
// The current panel has mached listitems
Expand Down
3 changes: 3 additions & 0 deletions dist/core/scrollbugfix/mmenu.scrollbugfix.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ export default function () {
// Prevent the page from scrolling when dragging in the menu.
this.node.menu.addEventListener('touchmove', function (evnt) {
var wrapper = evnt.target.closest('.mm-panel, .mm-iconbar__top, .mm-iconbar__bottom');
if (wrapper.closest('.mm-listitem_vertical')) {
wrapper = DOM.parents(wrapper, '.mm-panel').pop();
}
if (wrapper) {
// When dragging a non-scrollable panel,
// we can simple preventDefault and stopPropagation.
Expand Down
4 changes: 2 additions & 2 deletions dist/mmenu.js

Large diffs are not rendered by default.

Loading

0 comments on commit afb8b13

Please sign in to comment.