mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 03:32:21 +08:00
docs(): add more docs about virtual-scroll and ion-img
This commit is contained in:
@ -1,98 +1,6 @@
|
|||||||
# ion-fab
|
# ion-img
|
||||||
|
|
||||||
Fabs are container elements that contain one or more fab buttons. They should be placed in a fixed position that does not scroll with the content. The following attributes can be used to position the fab with respect to the content:
|
Img is a tag that will lazyily load an image when ever the tag is in the viewport. This is extremely useful when generating a large list as images are only loaded when they're visible. The component uses [Intersection Observer](https://caniuse.com/#feat=intersectionobserver) internally, which is supported in most modern browser, but falls back to a `setTimeout` when it is not supported.
|
||||||
|
|
||||||
| Value | Alignment | Details |
|
|
||||||
|--------------|------------|---------------------------------------------------------------------------|
|
|
||||||
| `top` | vertical | Places the container at the top of the content. |
|
|
||||||
| `bottom` | vertical | Places the container at the bottom of the content. |
|
|
||||||
| `middle` | vertical | Places the container in the middle vertically. |
|
|
||||||
| `edge` | vertical | Used to place the container between the content and the header/footer. |
|
|
||||||
| `left` | horizontal | Places the container on the left. |
|
|
||||||
| `right` | horizontal | Places the container on the right. |
|
|
||||||
| `center` | horizontal | Places the container in the center horizontally. |
|
|
||||||
|
|
||||||
The fab should have one main fab button. Fabs can also contain fab lists which contain related buttons that show when the main fab button is clicked. The same fab container can contain several [fab list](../../fab-list/FabList) elements with different side values.
|
|
||||||
|
|
||||||
```html
|
|
||||||
<ion-content>
|
|
||||||
<!-- fab placed to the top right -->
|
|
||||||
<ion-fab top right slot="fixed">
|
|
||||||
<ion-fab-button>
|
|
||||||
<ion-icon name="add"></ion-icon>
|
|
||||||
</ion-fab-button>
|
|
||||||
</ion-fab>
|
|
||||||
|
|
||||||
<!-- fab placed to the bottom right -->
|
|
||||||
<ion-fab bottom right slot="fixed">
|
|
||||||
<ion-fab-button>
|
|
||||||
<ion-icon name="arrow-dropleft"></ion-icon>
|
|
||||||
</ion-fab-button>
|
|
||||||
</ion-fab>
|
|
||||||
|
|
||||||
<!-- fab placed to the top left -->
|
|
||||||
<ion-fab top left slot="fixed">
|
|
||||||
<ion-fab-button>
|
|
||||||
<ion-icon name="arrow-dropright"></ion-icon>
|
|
||||||
</ion-fab-button>
|
|
||||||
</ion-fab>
|
|
||||||
|
|
||||||
<!-- fab placed to the bottom left -->
|
|
||||||
<ion-fab bottom left slot="fixed">
|
|
||||||
<ion-fab-button>
|
|
||||||
<ion-icon name="arrow-dropup"></ion-icon>
|
|
||||||
</ion-fab-button>
|
|
||||||
</ion-fab>
|
|
||||||
|
|
||||||
<!-- fab placed to the left and middle -->
|
|
||||||
<ion-fab left middle slot="fixed">
|
|
||||||
<ion-fab-button>
|
|
||||||
<ion-icon name="share"></ion-icon>
|
|
||||||
</ion-fab-button>
|
|
||||||
</ion-fab>
|
|
||||||
|
|
||||||
<!-- fab placed to the right and middle -->
|
|
||||||
<ion-fab right middle slot="fixed">
|
|
||||||
<ion-fab-button>
|
|
||||||
<ion-icon name="add"></ion-icon>
|
|
||||||
</ion-fab-button>
|
|
||||||
</ion-fab>
|
|
||||||
|
|
||||||
<!-- fab placed to the top and right and on the top edge of the content overlapping header -->
|
|
||||||
<ion-fab top right edge slot="fixed">
|
|
||||||
<ion-fab-button>
|
|
||||||
<ion-icon name="person"></ion-icon>
|
|
||||||
</ion-fab-button>
|
|
||||||
</ion-fab>
|
|
||||||
|
|
||||||
<!-- fab placed to the bottom and left and on the bottom edge of the content overlapping footer with a list to the right -->
|
|
||||||
<ion-fab bottom left edge slot="fixed">
|
|
||||||
<ion-fab-button>
|
|
||||||
<ion-icon name="settings"></ion-icon>
|
|
||||||
</ion-fab-button>
|
|
||||||
<ion-fab-list side="end">
|
|
||||||
<ion-fab-button><ion-icon name="logo-vimeo"></ion-icon></ion-fab-button>
|
|
||||||
</ion-fab-list>
|
|
||||||
</ion-fab>
|
|
||||||
|
|
||||||
<!-- fab placed in the center of the content with a list on each side -->
|
|
||||||
<ion-fab center middle slot="fixed">
|
|
||||||
<ion-fab-button><ion-icon name="share"></ion-icon></ion-fab-button>
|
|
||||||
<ion-fab-list side="top">
|
|
||||||
<ion-fab-button><ion-icon name="logo-vimeo"></ion-icon></ion-fab-button>
|
|
||||||
</ion-fab-list>
|
|
||||||
<ion-fab-list side="bottom">
|
|
||||||
<ion-fab-button><ion-icon name="logo-facebook"></ion-icon></ion-fab-button>
|
|
||||||
</ion-fab-list>
|
|
||||||
<ion-fab-list side="start">
|
|
||||||
<ion-fab-button><ion-icon name="logo-googleplus"></ion-icon></ion-fab-button>
|
|
||||||
</ion-fab-list>
|
|
||||||
<ion-fab-list side="end">
|
|
||||||
<ion-fab-button><ion-icon name="logo-twitter"></ion-icon></ion-fab-button>
|
|
||||||
</ion-fab-list>
|
|
||||||
</ion-fab>
|
|
||||||
</ion-content>
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Auto Generated Below -->
|
<!-- Auto Generated Below -->
|
||||||
|
10
core/src/components/img/usage/angular.md
Normal file
10
core/src/components/img/usage/angular.md
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
```html
|
||||||
|
<ion-list>
|
||||||
|
<ion-item *ngFor="let item of items">
|
||||||
|
<ion-thumbnail slot="start">
|
||||||
|
<ion-img [src]="item.src"></ion-img>
|
||||||
|
</ion-thumbnail>
|
||||||
|
<ion-label>{{item.text}}</ion-label>
|
||||||
|
</ion-item>
|
||||||
|
</ion-list>
|
||||||
|
```
|
@ -17,7 +17,7 @@ The `virtualScroll` and `*virtualItem` properties can be added to any element.
|
|||||||
```html
|
```html
|
||||||
<ion-list [virtualScroll]="items">
|
<ion-list [virtualScroll]="items">
|
||||||
<ion-item *virtualItem="let item">
|
<ion-item *virtualItem="let item">
|
||||||
{% raw %}{{ item }}{% endraw %}
|
{{ item }}
|
||||||
</ion-item>
|
</ion-item>
|
||||||
</ion-list>
|
</ion-list>
|
||||||
```
|
```
|
||||||
|
66
core/src/components/virtual-scroll/usage/angular.md
Normal file
66
core/src/components/virtual-scroll/usage/angular.md
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
```html
|
||||||
|
<ion-content>
|
||||||
|
<ion-virtual-scroll [items]="items" approxItemHeight="320px">
|
||||||
|
<ion-card *virtualItem="let item; let itemBounds = bounds;">
|
||||||
|
<div>
|
||||||
|
<img [src]="item.imgSrc" [height]="item.imgHeight" [alt]="item.name">
|
||||||
|
</div>
|
||||||
|
<ion-card-header>
|
||||||
|
<ion-card-title>{{ item.name }}</ion-card-title>
|
||||||
|
</ion-card-header>
|
||||||
|
<ion-card-content>{{ item.content }}</ion-card-content>
|
||||||
|
</ion-card>
|
||||||
|
</ion-virtual-scroll>
|
||||||
|
</ion-content>
|
||||||
|
```
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
export class VirtualScrollPageComponent {
|
||||||
|
items: any[] = [];
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
for (let i = 0; i < 1000; i++) {
|
||||||
|
this.items.push({
|
||||||
|
name: i + ' - ' + images[rotateImg],
|
||||||
|
imgSrc: getImgSrc(),
|
||||||
|
avatarSrc: getImgSrc(),
|
||||||
|
imgHeight: Math.floor(Math.random() * 50 + 150),
|
||||||
|
content: lorem.substring(0, Math.random() * (lorem.length - 100) + 100)
|
||||||
|
});
|
||||||
|
|
||||||
|
rotateImg++;
|
||||||
|
if (rotateImg === images.length) {
|
||||||
|
rotateImg = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const lorem = `Lorem ipsum dolor sit amet, consectetur adipiscing elit, seddo eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.`;
|
||||||
|
|
||||||
|
const images = [
|
||||||
|
'bandit',
|
||||||
|
'batmobile',
|
||||||
|
'blues-brothers',
|
||||||
|
'bueller',
|
||||||
|
'delorean',
|
||||||
|
'eleanor',
|
||||||
|
'general-lee',
|
||||||
|
'ghostbusters',
|
||||||
|
'knight-rider',
|
||||||
|
'mirth-mobile'
|
||||||
|
];
|
||||||
|
|
||||||
|
function getImgSrc() {
|
||||||
|
const src = `https://dummyimage.com/600x400/${Math.round(
|
||||||
|
Math.random() * 99999
|
||||||
|
)}/fff.png`;
|
||||||
|
rotateImg++;
|
||||||
|
if (rotateImg === images.length) {
|
||||||
|
rotateImg = 0;
|
||||||
|
}
|
||||||
|
return src;
|
||||||
|
}
|
||||||
|
|
||||||
|
let rotateImg = 0;
|
||||||
|
```
|
Reference in New Issue
Block a user