Skip to content

Commit 253091d

Browse files
committed
scroll fix
1 parent 9920395 commit 253091d

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

backend/src/main/java/com/thughari/jobtrackerpro/service/CareerResourceService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public CareerResourcePageResponse getResourcePage(int page, int size, String que
5454
String normalizedCategory = normalizeFilter(category);
5555
String normalizedType = normalizeType(type);
5656

57-
var pageable = PageRequest.of(sanitizedPage, sanitizedSize, Sort.by(Sort.Direction.DESC, "createdAt"));
57+
var pageable = PageRequest.of(sanitizedPage, sanitizedSize, Sort.by(Sort.Order.asc("category"), Sort.Order.asc("title")));
5858
var resourcePage = resourceRepository.findAll(buildResourceFilter(normalizedQuery, normalizedCategory, normalizedType), pageable);
5959

6060
var content = resourcePage.getContent().stream()

frontend/src/app/components/resources/resources.component.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,19 +240,23 @@ export class ResourcesComponent implements OnDestroy {
240240
onModeChange(mode: 'link' | 'file') { this.contributionMode = mode; }
241241
formatFileSize(s?: number) { return s ? (s < 1048576 ? `${Math.ceil(s/1024)}KB` : `${(s/1048576).toFixed(1)}MB`) : ''; }
242242

243-
@HostListener('window:scroll')
243+
@HostListener('window:scroll', [])
244244
onWindowScroll() {
245-
if (this.viewMode() === 'mine' || this.showAddResourceModal() || this.showDeleteConfirm()) return;
245+
if (this.viewMode() !== 'community') return;
246+
if (this.showAddResourceModal() || this.showDeleteConfirm()) return;
246247
if (!this.hasNext() || this.isLoading() || this.isLoadingMore()) return;
247248

248-
const pos = (document.documentElement.scrollTop || document.body.scrollTop) + document.documentElement.offsetHeight;
249-
const max = document.documentElement.scrollHeight;
250-
if (max - pos < 300) {
249+
const scrollTop = window.scrollY || document.documentElement.scrollTop;
250+
const viewportHeight = window.innerHeight;
251+
const fullHeight = document.documentElement.scrollHeight;
252+
253+
const distanceFromBottom = fullHeight - (scrollTop + viewportHeight);
254+
if (distanceFromBottom <= 120) {
251255
if (this.scrollLoadDebounceRef) return;
252256
this.scrollLoadDebounceRef = setTimeout(() => {
253257
this.scrollLoadDebounceRef = null;
254258
this.loadResources();
255-
}, 400);
259+
}, 300);
256260
}
257261
}
258262
}

0 commit comments

Comments
 (0)