Skip to content

Commit

Permalink
version 1.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
tedw committed Mar 13, 2019
1 parent 4ccbfe6 commit 15b4de4
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 24 deletions.
2 changes: 1 addition & 1 deletion dist/compressed/expand-toggle.amd.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/compressed/expand-toggle.m.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/compressed/expand-toggle.umd.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/expand-toggle.amd.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/expand-toggle.m.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/expand-toggle.umd.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ <h2>About Threespot</h2><p>Threespot is an independent digital agency hell-bent
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Mar 12 2019 13:53:27 GMT-0400 (EDT) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Mar 12 2019 22:11:29 GMT-0400 (EDT) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
33 changes: 18 additions & 15 deletions docs/index.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ <h1 class="page-title">index.js</h1>
expandedClasses: "", // string, accepts multiple space-separated classes
shouldToggleHeight: false, // should target element’s height be animated using max-height
activeToggleText: "", // expanded state toggle button text
shouldStartExpanded: false,// component starts expanded on init
shouldStartExpanded: false, // component starts expanded on init
onReady: null // ready callback function
},
opts
Expand Down Expand Up @@ -110,8 +110,7 @@ <h1 class="page-title">index.js</h1>

// Check if component should start expanded
this.shouldStartExpanded =
this.el.hasAttribute("data-expanded") ||
this.options.shouldStartExpanded;
this.el.hasAttribute("data-expanded") || this.options.shouldStartExpanded;

// Check for custom toggle button text to use when expanded
this.hasActiveText = false;
Expand Down Expand Up @@ -148,7 +147,7 @@ <h1 class="page-title">index.js</h1>
}

// Click event listener on toggle button
// Note: Callback needs to be assigned to a var so we can remove it since we’re using bind()
// Note: Callback needs to be assigned to a let so we can remove it since we’re using bind()
// https://stackoverflow.com/a/22870717/673457
this.clickHandler = this.toggle.bind(this);
this.el.addEventListener("click", this.clickHandler);
Expand Down Expand Up @@ -206,7 +205,6 @@ <h1 class="page-title">index.js</h1>
}

heightToggleSetup() {
var self = this;
this.targetParentEl = this.targetEl.parentNode;

// Set max-height to the expanded height so we can animate it.
Expand Down Expand Up @@ -234,28 +232,33 @@ <h1 class="page-title">index.js</h1>
// or another 3rd-party lib like Velocity.js, to avoid loading a large lib.
updateExpandedHeight() {
// Get width of original element so we can apply it to the clone
var nodeWidth = Math.round(parseFloat(this.targetEl.offsetWidth));
let nodeWidth = Math.round(parseFloat(this.targetEl.offsetWidth));

// Create clone of node
var cloneEl = this.targetEl.cloneNode(true); // 'true' includes child nodes
let cloneEl = this.targetEl.cloneNode(true); // 'true' includes child nodes

// Inline styles added to prevent reflow, ensure clone is same size as expanded element
cloneEl.style.cssText =
"max-height: none !important; position: absolute !important; right: 100% !important; visibility: hidden !important; width: " +
nodeWidth +
"px !important; -webkit-transition: none !important; -moz-transition: none !important; transition: none !important";
cloneEl.style.cssText = `max-height: none !important; position: absolute !important; right: 100% !important; visibility: hidden !important; width: ${nodeWidth}px !important; -webkit-transition: none !important; -moz-transition: none !important; transition: none !important`;

// Update “aria-hidden” attribute
cloneEl.setAttribute("aria-hidden", false);

// Remove id just to be safe
cloneEl.removeAttribute("id");

// Append clone to document, save as new var so we can remove it later
var newEl = this.targetParentEl.insertBefore(cloneEl, this.targetEl);
// Remove “name” attributes to prevent resetting checkbox or radio elements
let childElsWithId = cloneEl.querySelectorAll("[name]");

// IE-friendly way of iterating over a NodeList
Array.prototype.forEach.call(childElsWithId, el => {
el.removeAttribute("name");
});

// Append clone to document, save as new let so we can remove it later
let newEl = this.targetParentEl.insertBefore(cloneEl, this.targetEl);

// Calculate height
var expandedHeight = Math.round(parseFloat(newEl.offsetHeight));
let expandedHeight = Math.round(parseFloat(newEl.offsetHeight));

// Remove cloned node to clean up after ourselves
this.targetParentEl.removeChild(newEl);
Expand Down Expand Up @@ -328,7 +331,7 @@ <h1 class="page-title">index.js</h1>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Mar 12 2019 13:53:27 GMT-0400 (EDT) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Mar 12 2019 22:11:29 GMT-0400 (EDT) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/module.exports.html
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ <h5>Parameters:</h5>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Mar 12 2019 13:53:27 GMT-0400 (EDT) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Mar 12 2019 22:11:29 GMT-0400 (EDT) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@threespot/expand-toggle",
"version": "1.6.0",
"version": "1.6.1",
"description": "Simple and accessible expandable functionality, similar to jQuery’s `slideToggle()` method.",
"main": "dist/expand-toggle.m.js",
"homepage": "https://threespot.github.io/expand-toggle/",
Expand Down

0 comments on commit 15b4de4

Please sign in to comment.