@acanto/components-header
Advanced tools
Comparing version 0.0.14 to 0.0.15
57
index.js
@@ -1,2 +0,2 @@ | ||
import { $, setVendorCSS } from "@acanto/core-dom"; | ||
import { $, on, setVendorCSS } from "@acanto/core-dom"; | ||
import { parseSize } from "@acanto/core-helpers/jss"; | ||
@@ -22,29 +22,27 @@ | ||
mounted(); | ||
// default status as collapsed | ||
_setStatus("collapsed"); | ||
// immediately clamp the collpsable header part, it won't never be open | ||
// at this point. | ||
$collapsable.style.maxHeight = "0"; | ||
$bg.style.bottom = "100%"; | ||
setVendorCSS($collapsable, "transitionDuration", expandTime); | ||
on($toggle, "click", handleToggle); | ||
on(document, "click", handleClickOutside); | ||
/** | ||
* Mounted | ||
* Handle click outside | ||
* | ||
* @param {MouseEvent} event | ||
*/ | ||
function mounted() { | ||
// default status as collapsed | ||
_setStatus("collapsed"); | ||
// immediately clamp the collpsable header part, it won't never be open | ||
// at this point. | ||
$collapsable.style.maxHeight = "0"; | ||
$bg.style.bottom = "100%"; | ||
setVendorCSS($collapsable, "transitionDuration", expandTime); | ||
$toggle.addEventListener("click", handleToggle); | ||
document.addEventListener("click", (event) => { | ||
if (status === "expanded") { | ||
// @ts-ignore | ||
if (!$root.contains(event.target)) { | ||
collapse(); | ||
} | ||
function handleClickOutside(event) { | ||
if (status === "expanded") { | ||
// @ts-ignore | ||
if (!$root.contains(event.target)) { | ||
collapse(); | ||
} | ||
}); | ||
} | ||
} | ||
@@ -54,3 +52,2 @@ | ||
* Handle toggle | ||
* | ||
*/ | ||
@@ -122,5 +119,17 @@ function handleToggle() { | ||
/** | ||
* Destroy | ||
* | ||
*/ | ||
function destroy() { | ||
off($toggle, "click", handleToggle); | ||
off(document, "click", handleClickOutside); | ||
} | ||
return { | ||
$root, | ||
expand, | ||
collapse, | ||
destroy | ||
}; | ||
} |
{ | ||
"name": "@acanto/components-header", | ||
"version": "0.0.14", | ||
"version": "0.0.15", | ||
"author": "Acanto <info@acanto.net> (https://acanto.agency/)", | ||
@@ -19,3 +19,3 @@ "license": "ISC", | ||
}, | ||
"gitHead": "71880eff0af1629ee9ce2009b02e02c4edd607dd" | ||
"gitHead": "05ba1c727134f34f5a7b1a3a9462faa1422acf3e" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
15978
112