Sha256: 7cd30396676e54afe8e6d2db59ae96933550f798bb8117ca726d15c6dede3510

Contents?: true

Size: 1.09 KB

Versions: 363

Compression:

Stored size: 1.09 KB

Contents

export const showElement = (elem: HTMLElement) => {
  elem.style.display = 'block';
  const height = elem.scrollHeight + 'px'; // Get its height
  elem.style.height = height; // Update the max-height
  elem.classList.add('is-visible');
  elem.style.overflow = "hidden"
  // Once the transition is complete, remove the inline max-height so the content can scale responsively
  window.setTimeout(() => {
    // If a user toggles multiple times quickly in a row, 'is-visible' can be removed by hideElement's timeout
    if (!elem.classList.contains('is-visible')) {
      elem.classList.add('is-visible')
    }
    elem.style.height = '';
    elem.style.overflow = "visible"
  }, 300);
};

export const hideElement = (elem: HTMLElement) => {
  elem.style.height = elem.scrollHeight + 'px';

  window.setTimeout(() => {
    elem.style.height = '0';
    elem.style.paddingTop = '0';
    elem.style.paddingBottom = '0';
    elem.style.overflow = "hidden"
  }, 1);

  // When the transition is complete, hide it
  window.setTimeout(() => {
    elem.classList.remove('is-visible');
    elem.style.overflow = ""
  }, 300);
};

Version data entries

363 entries across 363 versions & 1 rubygems

Version Path
playbook_ui-14.11.1.pre.alpha.PLAY1720phonenumberinputformatAsYouType5377 app/pb_kits/playbook/pb_collapsible/_helper_functions.ts
playbook_ui-14.11.1.pre.alpha.play17725374 app/pb_kits/playbook/pb_collapsible/_helper_functions.ts
playbook_ui-14.11.1.pre.alpha.play17725372 app/pb_kits/playbook/pb_collapsible/_helper_functions.ts
playbook_ui-14.12.0.pre.rc.4 app/pb_kits/playbook/pb_collapsible/_helper_functions.ts
playbook_ui-14.11.1.pre.alpha.hfhbrakemanplaybook5370 app/pb_kits/playbook/pb_collapsible/_helper_functions.ts
playbook_ui-14.11.1.pre.alpha.responsivetablerails5364 app/pb_kits/playbook/pb_collapsible/_helper_functions.ts
playbook_ui-14.11.1.pre.alpha.responsivetablerails5362 app/pb_kits/playbook/pb_collapsible/_helper_functions.ts
playbook_ui-14.11.1.pre.alpha.PBNTR769sticky5359 app/pb_kits/playbook/pb_collapsible/_helper_functions.ts
playbook_ui-14.11.1.pre.alpha.PBNTR573datepickerinvestigation5355 app/pb_kits/playbook/pb_collapsible/_helper_functions.ts
playbook_ui-14.11.1.pre.alpha.PLAY1750pbcontenttagkitbutton5341 app/pb_kits/playbook/pb_collapsible/_helper_functions.ts
playbook_ui-14.11.1.pre.alpha.PLAY1750pbcontenttagkitbutton5340 app/pb_kits/playbook/pb_collapsible/_helper_functions.ts
playbook_ui-14.11.1.pre.alpha.PLAY1750pbcontenttagkitbutton5339 app/pb_kits/playbook/pb_collapsible/_helper_functions.ts
playbook_ui-14.12.0.pre.rc.3 app/pb_kits/playbook/pb_collapsible/_helper_functions.ts
playbook_ui-14.12.0.pre.rc.2 app/pb_kits/playbook/pb_collapsible/_helper_functions.ts
playbook_ui-14.12.0.pre.rc.1 app/pb_kits/playbook/pb_collapsible/_helper_functions.ts
playbook_ui-14.12.0.pre.rc.0 app/pb_kits/playbook/pb_collapsible/_helper_functions.ts
playbook_ui-14.10.0.pre.alpha.PLAY1774timelinelabelstepspacing5315 app/pb_kits/playbook/pb_collapsible/_helper_functions.ts
playbook_ui-14.10.0.pre.alpha.PLAY1774timelinelabelstepspacing5314 app/pb_kits/playbook/pb_collapsible/_helper_functions.ts
playbook_ui-14.10.0.pre.alpha.PLAY1750pbcontenttagkitbutton5308 app/pb_kits/playbook/pb_collapsible/_helper_functions.ts
playbook_ui-14.11.1 app/pb_kits/playbook/pb_collapsible/_helper_functions.ts