File

my-lib/list/list-item/list-item.ts

Extends

Antd

Metadata

encapsulation ViewEncapsulation.None
selector list-item,[listItem]
templateUrl ./list-item.html

Index

Properties
Methods
Inputs
Outputs
HostListeners
Accessors

Constructor

constructor(ele: ElementRef, render: Renderer2)
Parameters :
Name Type Optional Description
ele ElementRef
render Renderer2

Inputs

arrow
bottom

Type: any

disabled

Type: any

error

Type: any

extra

Type: string | TemplateRef

middle

Type: any

multiple
thumb

Type: string

top

Type: any

Outputs

onClick $event type: EventEmitter<any>

HostListeners

click
Arguments : '$event'
click(e: )
touchend
Arguments : '$event'
touchend()
touchstart
Arguments : '$event'
touchstart(e: )

Methods

initRipple
initRipple()
Returns : void
setItemActive
setItemActive(isTrue?: boolean)
Parameters :
Name Type Optional Description
isTrue boolean true
Returns : void

Properties

_arrow
_arrow: string
Type : string
_multiple
_multiple: boolean
Type : boolean
Default value : false
_thumb
_thumb: string
Type : string
brief
brief: TemplateRef<any>
Type : TemplateRef<any>
Decorators : ContentChild
listRipple
listRipple: ListRippleDirective
Type : ListRippleDirective
Decorators : ViewChild
thumbRef
thumbRef: TemplateRef<any>
Type : TemplateRef<any>
Decorators : ContentChild

Accessors

multiple
setmultiple(val: )
disabled
setdisabled(val: any)
error
seterror(val: any)
top
settop(val: any)
middle
setmiddle(val: any)
bottom
setbottom(val: any)
thumb
setthumb(val: string)
extraType
getextraType()
arrow
setarrow(val: )
import {
    ViewEncapsulation, Component, HostBinding, Input,
    ChangeDetectorRef, OnChanges, SimpleChanges,
    ElementRef, Renderer2, ContentChild, TemplateRef,
    HostListener, ViewChild, EventEmitter, Output
} from '@angular/core';
import { fromEvent, isMeepoTrue, merge } from 'meepo-utils';
import { listPrefixCls } from '../var';
import { Antd } from '../../antd';
import { ListRippleDirective } from '../list-ripple/list-ripple';
@Component({
    selector: 'list-item,[listItem]',
    templateUrl: './list-item.html',
    encapsulation: ViewEncapsulation.None
})
export class ListItemComponent extends Antd {
    @ContentChild('thumb') thumbRef: TemplateRef<any>;
    @ContentChild('brief') brief: TemplateRef<any>;

    _multiple: boolean = false;
    @Input()
    set multiple(val) {
        this._multiple = this.isMeepoTrue(val);
        this.addToClass('-multiple', isMeepoTrue(val));
    }

    @Input()
    set disabled(val: any) {
        this.addToClass('-disabled', isMeepoTrue(val));
    }

    @Input()
    set error(val: any) {
        this.addToClass('-error', isMeepoTrue(val));
    }

    @Input()
    set top(val: any) {
        this.addToClass('-top', isMeepoTrue(val));
    }

    @Input()
    set middle(val: any) {
        this.addToClass('-middle', isMeepoTrue(val));
    }

    @Input()
    set bottom(val: any) {
        this.addToClass('-bottom', isMeepoTrue(val));
    }

    _thumb: string;
    @Input()
    set thumb(val: string) {
        this._thumb = val;
    }

    @Input() extra: string | TemplateRef<any>;
    get extraType() {
        return typeof this.extra;
    }

    _arrow: string;
    @Input()
    set arrow(val: 'horizontal' | 'up' | 'down' | 'empty') {
        val = val || 'horizontal';
        this._arrow = val;
    }

    // new
    @ViewChild(ListRippleDirective) listRipple: ListRippleDirective;
    @Output() onClick: EventEmitter<any> = new EventEmitter();

    @HostListener('click', ['$event'])
    click(e) {
        this.onClick.emit();
    }

    @HostListener('touchstart', ['$event'])
    touchstart(e) {
        this.setItemActive(true);
    }

    @HostListener('touchend', ['$event'])
    touchend() {
        this.setItemActive(false);
    }

    constructor(
        ele: ElementRef,
        render: Renderer2
    ) {
        super(ele, render, 'list-item');
        this.addToClass('-middle', true);
        this.initRipple();
    }

    initRipple() {
        const start$ = merge(
            fromEvent(this.ele.nativeElement, 'mousedown'),
            fromEvent(this.ele.nativeElement, 'touchstart')
        );
        start$
            .map((e: any) => {
                const Item = this.ele.nativeElement;
                const ClientRect = e.currentTarget.getBoundingClientRect();
                const res = this._getPosition(e);
                const pointX = res.y - ClientRect.left - Item.offsetWidth / 2;
                const pointY = res.y - ClientRect.top - Item.offsetWidth / 2;
                return { x: pointX, y: pointY }
            })
            .subscribe(res => {
                const Item = this.ele.nativeElement;
                const RippleWidth = Math.max(Item.offsetHeight, Item.offsetWidth);
                this.listRipple && this.listRipple.setAnimate(res, RippleWidth);
            });
    }

    setItemActive(isTrue?: boolean) {
        this.addToClass('-active', isTrue);
    }
}
<div class="{{_name}}-thumb" *ngIf="_thumb && !thumbRef">
    <img [src]="_thumb" />
</div>
<ng-container *ngIf="thumbRef">
    <div class="{{_name}}-thumb">
        <ng-container *ngTemplateOutlet="thumbRef"></ng-container>
    </div>
</ng-container>
<div class="am-list-line" [class.am-list-line-multiple]="_multiple">
    <div class="{{_name}}-content">
        <ng-content></ng-content>
        <div class="{{_name}}-brief" *ngIf="brief">
            <ng-container *ngTemplateOutlet="brief"></ng-container>
        </div>
    </div>
    <div class="{{_name}}-extra" *ngIf="extra && extraType === 'string'">
        {{extra}}
    </div>
    <div class="{{_name}}-extra" *ngIf="extra && extraType !== 'string'">
        <ng-container *ngTemplateOutlet="extra"></ng-container>
    </div>
    <div [listArrow]="_arrow"></div>
</div>
<div listRipple style="display: none;"></div>
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""