Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

advanced-menus

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

advanced-menus - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

dist/menu.js

9

index.js
import Menu from "./module/Menu.js";
var autoload = false;
if (autoload){
require('./sass/menu.scss');
var menu = new Menu();
}
module.exports = require('./module/Menu.js')
module.exports = Menu;

@@ -7,3 +7,3 @@ export default class Menu {

//init Menu
this.menu = document.querySelector(selectors.menu);
this.menu = document.getElementById(selectors.menu_id);
if(!this.menu) {

@@ -21,2 +21,7 @@ console.error("unable to find the menu with selector: " + selectors.menu);

if(this.submenus.length)
for(var i=0; i < this.submenus.length; i++){
this.calculateMaxHeight(this.submenus[i]);
}
// init toggleButtons

@@ -47,3 +52,16 @@ this.toggleButtons = document.querySelectorAll(selectors.toggle_button);

console.log(this);
document.addEventListener('mousedown', function(e){
var hide = this.menu.classList.contains('active');
if(!hide) return;
for(var i = 0; i < e.path.length; i++ ){
if(
e.path[i].id == this.settings.selectors.menu_id ||
e.path[i].classList && e.path[i].classList.contains('menu-toggle-button')
)
hide = false;
}
if(hide) this.close();
}.bind(this))
}

@@ -57,3 +75,3 @@

selectors:{
menu: '#main-menu',
menu_id: 'main-menu',
menuitem: 'li',

@@ -78,3 +96,6 @@ submenu: '.menu-item > ul',

var submenu = e.target.parentNode.querySelector(this.settings.selectors.submenu);
if(!submenu) return;
if(!submenu) {
this.close();
return;
}

@@ -109,3 +130,4 @@ e.preventDefault();

toggleSubmenu(submenu){
this.can_open_multiple();
if(!submenu.classList.contains('active'))
this.can_open_multiple(this.closest(submenu, submenu.className));
submenu.classList.toggle('active');

@@ -130,28 +152,28 @@ }

if ( ! this.xDown || ! this.yDown ) {
return;
}
return;
}
var xUp = evt.touches[0].clientX;
var yUp = evt.touches[0].clientY;
var xUp = evt.touches[0].clientX;
var yUp = evt.touches[0].clientY;
var xDiff = this.xDown - xUp;
var yDiff = this.yDown - yUp;
var xDiff = this.xDown - xUp;
var yDiff = this.yDown - yUp;
if ( Math.abs( xDiff ) > Math.abs( yDiff ) ) {
if ( xDiff > 0 ) {
this.onSwipeLeft();
} else {
this.onSwipeRight();
}
} else {
if ( yDiff > 0 ) {
this.onSwipeUp();
} else {
this.onSwipeDown();
}
}
if ( Math.abs( xDiff ) > Math.abs( yDiff ) ) {
if ( xDiff > 0 ) {
this.onSwipeLeft();
} else {
this.onSwipeRight();
}
} else {
if ( yDiff > 0 ) {
this.onSwipeUp();
} else {
this.onSwipeDown();
}
}
/* reset values */
this.xDown = null;
this.yDown = null;
/* reset values */
this.xDown = null;
this.yDown = null;
}

@@ -171,9 +193,35 @@

can_open_multiple(){
can_open_multiple(parentMenu){
if(!this.settings.submenu.can_open_multiple){
for(var i = 0; i < this.submenus.length; i++){
this.closeSubmenu(this.submenus[i]);
if(parentMenu != this.submenus[i])
this.closeSubmenu(this.submenus[i]);
}
}
}
calculateMaxHeight(submenu) {
submenu.classList.add('active');
var menuitems = submenu.children;
for (var i = 0; i< this.menuitems.length; i++){
if(this.closest(this.menuitems[i], 'sub-menu'))
this.menuitems[i].parentNode.style.maxHeight = this.menuitems[i].clientHeight + "px"
}
submenu.classList.remove('active');
//submenu.style.maxHeight = menuitems.length*menuitems[0].clientHeight + "px";
}
closest(el, classname) {
if(el.parentNode && el.parentNode.className){
if(el.parentNode.className.indexOf(classname) != -1){
return el.parentNode;
}
else{
return this.closest(el.parentNode, classname);
}
}
else{
return false;
}
}
}
{
"name": "advanced-menus",
"version": "1.0.3",
"version": "1.0.4",
"description": "Easy to use and configurable HTML5 Menus",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -8,3 +8,3 @@ var path = require('path');

entry: './index.js',
watch: true,
watch: false,
output: {

@@ -11,0 +11,0 @@ filename: 'menu.js',

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc