|
2 | 2 | <html lang="en" dir="ltr"> |
3 | 3 | <head> |
4 | 4 | <meta charset="UTF-8" /> |
5 | | - <title>Infinite Scroll - Basic</title> |
| 5 | + <title>Infinite Scroll - Top</title> |
6 | 6 | <meta |
7 | 7 | name="viewport" |
8 | 8 | content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" |
|
18 | 18 | <ion-app> |
19 | 19 | <ion-header> |
20 | 20 | <ion-toolbar> |
21 | | - <ion-title>Infinite Scroll - Basic</ion-title> |
| 21 | + <ion-title>Infinite Scroll - Top</ion-title> |
22 | 22 | </ion-toolbar> |
23 | 23 | </ion-header> |
24 | 24 |
|
|
28 | 28 | </ion-infinite-scroll-content> |
29 | 29 | </ion-infinite-scroll> |
30 | 30 |
|
31 | | - <button onclick="toggleInfiniteScroll()" class="expand">Toggle InfiniteScroll</button> |
| 31 | + <div id="list"></div> |
32 | 32 |
|
33 | | - <ion-list id="list"></ion-list> |
| 33 | + <button onclick="toggleInfiniteScroll()" class="expand">Toggle InfiniteScroll</button> |
34 | 34 | </ion-content> |
35 | 35 | </ion-app> |
36 | 36 |
|
|
46 | 46 | console.log('Loading data...'); |
47 | 47 | await wait(500); |
48 | 48 | infiniteScroll.complete(); |
49 | | - appendItems(); |
| 49 | + appendNewItems(); |
50 | 50 | // Custom event consumed in the e2e tests |
51 | 51 | window.dispatchEvent(new CustomEvent('ionInfiniteComplete')); |
52 | 52 |
|
53 | 53 | console.log('Done'); |
54 | 54 | }); |
55 | 55 |
|
56 | | - function appendItems() { |
| 56 | + // Add initial items |
| 57 | + function appendInitialItems() { |
57 | 58 | for (var i = 0; i < 30; i++) { |
58 | 59 | const el = document.createElement('ion-item'); |
59 | | - el.textContent = `${1 + i}`; |
| 60 | + el.textContent = `Item ${1 + i}`; |
| 61 | + list.appendChild(el); |
| 62 | + } |
| 63 | + } |
| 64 | + |
| 65 | + // Add newly loaded items with special styling |
| 66 | + function appendNewItems() { |
| 67 | + const randomColor = '#' + Math.floor(Math.random()*16777215).toString(16).padStart(6, '0'); |
| 68 | + |
| 69 | + // Reverse the order of the items to match |
| 70 | + // the order of the initial items |
| 71 | + for (var i = 29; i >= 0; i--) { |
| 72 | + const el = document.createElement('ion-item'); |
| 73 | + el.textContent = `Item ${i + 1}`; |
| 74 | + el.style.borderLeft = `4px solid ${randomColor}`; |
60 | 75 | list.prepend(el); |
61 | 76 | } |
62 | 77 | } |
|
69 | 84 | }); |
70 | 85 | } |
71 | 86 |
|
72 | | - appendItems(); |
| 87 | + appendInitialItems(); |
73 | 88 | </script> |
74 | 89 | </body> |
75 | 90 | </html> |
0 commit comments