From eff2fc27cab02069dd909569201d3c7879815dd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 16 Nov 2019 14:57:08 +0100 Subject: [PATCH] Add infinite scroll on list/tree issue8729 review282261002 --- CHANGELOG | 2 ++ src/sao.less | 7 +++++++ src/view/tree.js | 15 +++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 8a27a9a535..7a5da2a620 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* Add infinite scroll + Version 5.4.0 - 2019-11-04 * Bug fixes (see mercurial logs for details) * Support visual context on tree view diff --git a/src/sao.less b/src/sao.less index 57a3faa53f..fa033f79d9 100644 --- a/src/sao.less +++ b/src/sao.less @@ -120,6 +120,13 @@ .modal-body { overflow-x: auto; + max-height: calc(100vh - 200px); +} + +@media screen and (max-height: 500px) { + .modal-body { + max-height: 300px; + } } .modal-lg { diff --git a/src/view/tree.js b/src/view/tree.js index 21d87d9c00..7244609cce 100644 --- a/src/view/tree.js +++ b/src/view/tree.js @@ -3,6 +3,18 @@ (function() { 'use strict'; + if ('IntersectionObserver' in window) { + var moreObserver = new IntersectionObserver(function(entries, observer) { + entries.forEach(function(entry) { + if (entry.isIntersecting) { + jQuery(entry.target).trigger('click'); + } + }); + }, { + rootMargin: '0px 0px 50px 0px', + }); + } + Sao.View.TreeXMLViewParser = Sao.class_(Sao.View.XMLViewParser, { _parse_tree: function(node, attributes) { [].forEach.call(node.childNodes, function(child) { @@ -692,6 +704,9 @@ more_cell.append(more_button); more_row.append(more_cell); this.tbody.append(more_row); + if (moreObserver) { + moreObserver.observe(more_button[0]); + } } }, redraw: function(selected, expanded) {