From 9449ec5ca2b09fedc9f81262e21b8362b44a78eb Mon Sep 17 00:00:00 2001 From: Mo Bitar Date: Mon, 1 Apr 2019 11:15:12 -0500 Subject: [PATCH] Reset pagination on window resize --- app/assets/javascripts/app/controllers/notes.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/app/controllers/notes.js b/app/assets/javascripts/app/controllers/notes.js index 9489117b8..041a37b8d 100644 --- a/app/assets/javascripts/app/controllers/notes.js +++ b/app/assets/javascripts/app/controllers/notes.js @@ -173,8 +173,9 @@ angular.module('app') } } - let MinNoteHeight = 51.0; // This is the height of a note cell with nothing but the title, which *is* a display option - this.DefaultNotesToDisplayValue = (document.documentElement.clientHeight / MinNoteHeight) || 20; + window.onresize = (event) => { + this.resetPagination({keepCurrentIfLarger: true}); + }; this.paginate = function() { this.notesToDisplay += this.DefaultNotesToDisplayValue @@ -184,7 +185,12 @@ angular.module('app') } } - this.resetPagination = function() { + this.resetPagination = function({keepCurrentIfLarger} = {}) { + let MinNoteHeight = 51.0; // This is the height of a note cell with nothing but the title, which *is* a display option + this.DefaultNotesToDisplayValue = (document.documentElement.clientHeight / MinNoteHeight) || 20; + if(keepCurrentIfLarger && this.notesToDisplay > this.DefaultNotesToDisplayValue) { + return; + } this.notesToDisplay = this.DefaultNotesToDisplayValue; }