瀏覽代碼

refactor(Profile/Activity): Changed scroll fetching to match other areas of the site

Owen Diffey 3 年之前
父節點
當前提交
96beb76e38
共有 2 個文件被更改,包括 11 次插入13 次删除
  1. 10 12
      frontend/src/pages/Profile/Tabs/RecentActivity.vue
  2. 1 1
      frontend/src/pages/Profile/index.vue

+ 10 - 12
frontend/src/pages/Profile/Tabs/RecentActivity.vue

@@ -11,7 +11,7 @@
 
 			<hr class="section-horizontal-rule" />
 
-			<div id="activity-items" @scroll="handleScroll">
+			<div id="activity-items">
 				<activity-item
 					class="item activity-item universal-item"
 					v-for="activity in activities"
@@ -77,6 +77,8 @@ export default {
 		})
 	},
 	mounted() {
+		window.addEventListener("scroll", this.handleScroll);
+
 		ws.onConnect(this.init);
 
 		this.socket.on("event:activity.updated", res => {
@@ -105,6 +107,9 @@ export default {
 			this.offsettedFromNextSet = 0;
 		});
 	},
+	unmounted() {
+		window.removeEventListener("scroll", this.handleScroll);
+	},
 	methods: {
 		init() {
 			if (this.myUserId !== this.userId)
@@ -145,14 +150,13 @@ export default {
 				}
 			);
 		},
-		handleScroll(event) {
-			const scrollPosition =
-				event.target.clientHeight + event.target.scrollTop;
-			const bottomPosition = event.target.scrollHeight;
+		handleScroll() {
+			const scrollPosition = document.body.clientHeight + window.scrollY;
+			const bottomPosition = document.body.scrollHeight;
 
 			if (this.loadAllSongs) return false;
 
-			if (scrollPosition + 100 >= bottomPosition) this.getSet();
+			if (scrollPosition + 400 >= bottomPosition) this.getSet();
 
 			return this.maxPosition === this.position;
 		},
@@ -167,12 +171,6 @@ export default {
 	border: 0 !important;
 }
 
-#activity-items {
-	overflow: auto;
-	min-height: auto;
-	max-height: 570px;
-}
-
 .content a {
 	border-bottom: 0;
 }

+ 1 - 1
frontend/src/pages/Profile/index.vue

@@ -424,7 +424,7 @@ export default {
 		}
 
 		.item {
-			overflow: initial;
+			overflow: hidden;
 
 			&:not(:last-of-type) {
 				margin-bottom: 10px;