Skip to content

Commit 6d4f61b

Browse files
committed
Working on figure out the cause of high cpu usage.
1 parent 22c90f4 commit 6d4f61b

File tree

3 files changed

+28
-56
lines changed

3 files changed

+28
-56
lines changed

src/app/home/home.page.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,10 @@
110110
</ion-toolbar>
111111
</ion-header>
112112

113-
<ion-content
113+
<ion-content [scrollEvents]="true"
114114
fxLayout="row"
115115
fxLayoutAlign="center start"
116+
(ionScroll)="onScroll($event)"
116117
style="padding: 10px;">
117118
<!-- 已下载/保存书籍列表 -->
118119
<app-book-list *ngIf="!search"

src/app/home/home.page.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@ import {
99
MatDialog,
1010
} from '@angular/material/dialog';
1111

12-
import {FormControl, FormGroupDirective, NgForm, Validators} from '@angular/forms';
12+
import {
13+
FormControl,
14+
FormGroupDirective,
15+
NgForm,
16+
Validators
17+
} from '@angular/forms';
18+
1319
import {ErrorStateMatcher} from '@angular/material/core';
1420
import {PageEvent} from '@angular/material/paginator';
1521

@@ -263,6 +269,25 @@ export class HomePage implements OnInit, AfterViewInit {
263269
});
264270
}
265271

272+
onScroll = async ($event) => {
273+
if(!this.search || this.searchEnd){ return; }
274+
if($event.target.localName !== 'ion-content') { return; }
275+
276+
const scrollElement = await $event.target.getScrollElement();
277+
const scrollHeight = scrollElement.scrollHeight - scrollElement.clientHeight;
278+
279+
const currentScrollDepth = $event.detail.scrollTop;
280+
281+
if(currentScrollDepth === scrollHeight){
282+
if(
283+
this.bookListCloud.length%20 === 0
284+
&& !(/gitlab/.test(this.platformSelected))
285+
){
286+
this.cloudSearch(this.bookListCloud.length/20 + 1);
287+
}
288+
}
289+
}
290+
266291
historySearch = (keywords: string, platform: string) => {
267292
this.keywords = keywords;
268293
this.platformSelected = platform;

src/polyfills.ts

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,3 @@
1-
/**
2-
* This file includes polyfills needed by Angular and is loaded before the app.
3-
* You can add your own extra polyfills to this file.
4-
*
5-
* This file is divided into 2 sections:
6-
* 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
7-
* 2. Application imports. Files imported after ZoneJS that should be loaded before your main
8-
* file.
9-
*
10-
* The current setup is for so-called "evergreen" browsers; the last versions of browsers that
11-
* automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
12-
* Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
13-
*
14-
* Learn more in https://angular.io/guide/browser-support
15-
*/
16-
17-
/***************************************************************************************************
18-
* BROWSER POLYFILLS
19-
*/
20-
21-
/** IE10 and IE11 requires the following for NgClass support on SVG elements */
22-
// import 'classlist.js'; // Run `npm install --save classlist.js`.
23-
24-
/**
25-
* Web Animations `@angular/platform-browser/animations`
26-
* Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
27-
* Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
28-
*/
29-
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
30-
31-
/**
32-
* By default, zone.js will patch all possible macroTask and DomEvents
33-
* user can disable parts of macroTask/DomEvents patch by setting following flags
34-
* because those flags need to be set before `zone.js` being loaded, and webpack
35-
* will put import in the top of bundle, so user need to create a separate file
36-
* in this directory (for example: zone-flags.ts), and put the following flags
37-
* into that file, and then add the following code before importing zone.js.
38-
* import './zone-flags.ts';
39-
*
40-
* The flags allowed in zone-flags.ts are listed here.
41-
*
42-
* The following flags will work for all browsers.
43-
*
44-
* (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
45-
* (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
46-
* (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
47-
*
48-
* in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
49-
* with the following flag, it will bypass `zone.js` patch for IE/Edge
50-
*
51-
* (window as any).__Zone_enable_cross_context_check = true;
52-
*
53-
*/
54-
551
import './zone-flags';
562

573
/***************************************************************************************************

0 commit comments

Comments
 (0)