adapt-authoring-ui 3.0.1 → 3.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -164,8 +164,9 @@ define(function(require) {
164
164
  }, {
165
165
  success: model => {
166
166
  this.presets.add(model);
167
+ this.updatePresetSelect();
167
168
  this.updateRestorePresetButton(false);
168
- window.setTimeout(() => this.$('.preset select').val(model.get('_id')), 1);
169
+ this.$('.preset select').val(model.get('_id'));
169
170
  },
170
171
  error: this.onError
171
172
  });
@@ -185,33 +185,24 @@ define(function(require){
185
185
  });
186
186
  },
187
187
 
188
+ isNearListBottom: function(buffer) {
189
+ const cp = $('.contentPane')[0];
190
+ if(!cp) return false;
191
+ return cp.scrollHeight - cp.scrollTop - cp.clientHeight <= buffer;
192
+ },
193
+
188
194
  checkAndFillVisibleArea: function() {
189
- // Check if we need to load more items to fill the viewport
195
+ // Trigger another fetch when current items don't overflow the viewport
190
196
  if(this.shouldStopFetches || this.isCollectionFetching) return;
191
-
192
- const $last = $('.project-list-item').last();
193
- if($last.length === 0) return;
194
-
195
- const $contentPane = $('.contentPane');
196
- if($contentPane.length === 0) return;
197
-
198
- const contentPaneBottom = $contentPane.scrollTop() + $contentPane.height();
199
- const lastItemBottom = $last.position().top + $last.outerHeight(true);
200
-
201
- // If the last item is visible (within the viewport), fetch more
202
- if(lastItemBottom <= contentPaneBottom) {
203
- this.fetchCollection();
204
- }
197
+ if(this.isNearListBottom(0)) this.fetchCollection();
205
198
  },
206
199
 
207
- doLazyScroll: function(e) {
208
- if(this.isCollectionFetching) {
209
- return;
210
- }
211
- const $last = $('.project-list-item').last();
212
- const triggerY = ($('.contentPane').offset().top + $('.contentPane').height()) - ($last.height()/2) ;
213
-
214
- if($last.offset().top < triggerY) this.fetchCollection();
200
+ doLazyScroll: function() {
201
+ // Trigger when user scrolls within one viewport of the bottom
202
+ if(this.isCollectionFetching || this.shouldStopFetches) return;
203
+ const cp = $('.contentPane')[0];
204
+ if(!cp) return;
205
+ if(this.isNearListBottom(cp.clientHeight)) this.fetchCollection();
215
206
  },
216
207
 
217
208
  doLayout: function(layout) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adapt-authoring-ui",
3
- "version": "3.0.1",
3
+ "version": "3.0.3",
4
4
  "description": "Front-end application for the Adapt authoring tool",
5
5
  "homepage": "https://github.com/adapt-security/adapt-authoring-ui",
6
6
  "license": "GPL-3.0",