]> source.dussan.org Git - nextcloud-server.git/commitdiff
Page size calculation based on real page height
authorNazar Mokrynskyi <nazar@mokrynskyi.com>
Sat, 11 Oct 2014 13:10:54 +0000 (15:10 +0200)
committerNazar Mokrynskyi <nazar@mokrynskyi.com>
Sat, 11 Oct 2014 13:10:54 +0000 (15:10 +0200)
This is fix for https://github.com/owncloud/core/issues/10060
Instead of hard coding page size as 20 items, we check real page height, and divide by 50 (height of one row).
This will allow to load fewer items on small screens and enough items on large screens (4k, portrait orientation, etc.).
Also checking page height on every load to respond on browser window resizing,

apps/files/js/filelist.js

index 86cba29e76c96d1a5bf02e6d9a36f7f1cae9fcb9..eafef6c2a5e23353abb62a26fda7702ebbd0a694 100644 (file)
                fileSummary: null,
                initialized: false,
 
-               // number of files per page
-               pageSize: 20,
+               // number of files per page, calculated dynamically
+               pageSize: function() {
+                       return Math.ceil($('#app-content').height() / 50);
+               },
 
                /**
                 * Array of files in the current folder.
                 */
                _nextPage: function(animate) {
                        var index = this.$fileList.children().length,
-                               count = this.pageSize,
+                               count = this.pageSize(),
                                tr,
                                fileData,
                                newTrs = [],
                        // if there are less elements visible than one page
                        // but there are still pending elements in the array,
                        // then directly append the next page
-                       if (lastIndex < this.files.length && lastIndex < this.pageSize) {
+                       if (lastIndex < this.files.length && lastIndex < this.pageSize()) {
                                this._nextPage(true);
                        }