Sha256: 50e1309dd13222ee88787bd6662a391ac894e23f8044fe151fd20eb13dc695fd

Contents?: true

Size: 529 Bytes

Versions: 13

Compression:

Stored size: 529 Bytes

Contents

/**
 * Scroll smoothly to the last message automatically when the page is fully loaded.
 * To apply this to a page, at least one element must have the class "scroll-to-last-message".
 *
 * @param {HTMLElement} node target node
 * @returns {void}
 */
export default function(node = document) {
  const element = node.querySelector("[data-scroll-last-child]")
  if (element && element.children.length) {
    const lastChild = [...element.children].pop()
    window.scrollTo({ top: lastChild.offsetTop, behavior: "smooth" });
  }
}

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
decidim-core-0.29.1 app/packs/src/decidim/scroll_to_last_child.js
decidim-core-0.28.4 app/packs/src/decidim/scroll_to_last_child.js
decidim-core-0.29.0 app/packs/src/decidim/scroll_to_last_child.js
decidim-core-0.28.3 app/packs/src/decidim/scroll_to_last_child.js
decidim-core-0.29.0.rc4 app/packs/src/decidim/scroll_to_last_child.js
decidim-core-0.29.0.rc3 app/packs/src/decidim/scroll_to_last_child.js
decidim-core-0.29.0.rc2 app/packs/src/decidim/scroll_to_last_child.js
decidim-core-0.29.0.rc1 app/packs/src/decidim/scroll_to_last_child.js
decidim-core-0.28.2 app/packs/src/decidim/scroll_to_last_child.js
decidim-core-0.28.1 app/packs/src/decidim/scroll_to_last_child.js
decidim-core-0.28.0 app/packs/src/decidim/scroll_to_last_child.js
decidim-core-0.28.0.rc5 app/packs/src/decidim/scroll_to_last_child.js
decidim-core-0.28.0.rc4 app/packs/src/decidim/scroll_to_last_child.js