diff --git a/dist/basicContext.min.js b/dist/basicContext.min.js
index fedf67a..e6b21f2 100644
--- a/dist/basicContext.min.js
+++ b/dist/basicContext.min.js
@@ -1 +1 @@
-"use strict";!function(n,t){"undefined"!=typeof module&&module.exports?module.exports=t():"function"==typeof define&&define.amd?define(t):window[n]=t()}("basicContext",function(){var n=null,t="item",e="separator",i=function(){var n=arguments.length<=0||void 0===arguments[0]?"":arguments[0];return document.querySelector(".basicContext "+n)},l=function(){var n=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],i=0===Object.keys(n).length?!0:!1;return i===!0&&(n.type=e),null==n.type&&(n.type=t),null==n["class"]&&(n["class"]=""),n.visible!==!1&&(n.visible=!0),null==n.icon&&(n.icon=null),null==n.title&&(n.title="Undefined"),n.disabled!==!0&&(n.disabled=!1),n.disabled===!0&&(n["class"]+=" basicContext__item--disabled"),null==n.fn&&n.type!==e&&n.disabled===!1?(console.warn("Missing fn for item '"+n.title+"'"),!1):!0},o=function(n,i){var o="",r="";return l(n)===!1?"":n.visible===!1?"":(n.num=i,null!==n.icon&&(r=""),n.type===t?o="\n
-
-
-
+
+
+
`
items.forEach((item, i) => html += buildItem(item, i))
html += `
-
-
-
-
+
+
+
`
return html
@@ -183,18 +179,15 @@ const bind = function(item = {}) {
const show = function(items, e, fnClose, fnCallback) {
+ // Close any other open context menus
+ close()
+
// Build context
let html = build(items)
// Add context to the body
document.body.insertAdjacentHTML('beforeend', html)
- // Save current overflow and block scrolling of site
- if (overflow==null) {
- overflow = document.body.style.overflow
- document.body.style.overflow = 'hidden'
- }
-
// Cache the context
let context = dom()
@@ -210,7 +203,7 @@ const show = function(items, e, fnClose, fnCallback) {
// Close fn fallback
if (fnClose==null) fnClose = close
- // Bind click on background
+ // Bind click on parent element
context.parentElement.onclick = fnClose
context.parentElement.oncontextmenu = fnClose
@@ -239,17 +232,9 @@ const visible = function() {
const close = function() {
- if (visible()===false) return false
+ let container = document.querySelector('.basicContext')
- let container = document.querySelector('.basicContextContainer')
-
- container.parentElement.removeChild(container)
-
- // Reset overflow to its original value
- if (overflow!=null) {
- document.body.style.overflow = overflow
- overflow = null
- }
+ if (container!==null) container.parentElement.removeChild(container)
return true
@@ -261,4 +246,4 @@ return {
show,
visible,
close
-}
\ No newline at end of file
+}