mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 12:29:55 +08:00
refactor(item-options): simplify getSides()
This commit is contained in:
@ -1,7 +1,6 @@
|
|||||||
import { Directive, ElementRef, EventEmitter, Input, Output, Renderer } from '@angular/core';
|
import { Directive, ElementRef, EventEmitter, Input, Output, Renderer } from '@angular/core';
|
||||||
|
|
||||||
import { Platform } from '../../platform/platform';
|
import { Platform } from '../../platform/platform';
|
||||||
import { isPresent} from '../../util/util';
|
|
||||||
import { ITEM_SIDE_FLAG_LEFT, ITEM_SIDE_FLAG_RIGHT, ItemSliding } from './item-sliding';
|
import { ITEM_SIDE_FLAG_LEFT, ITEM_SIDE_FLAG_RIGHT, ItemSliding } from './item-sliding';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -29,6 +28,7 @@ import { ITEM_SIDE_FLAG_LEFT, ITEM_SIDE_FLAG_RIGHT, ItemSliding } from './item-s
|
|||||||
selector: 'ion-item-options',
|
selector: 'ion-item-options',
|
||||||
})
|
})
|
||||||
export class ItemOptions {
|
export class ItemOptions {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @input {string} The side the option button should be on. Defaults to `"right"`.
|
* @input {string} The side the option button should be on. Defaults to `"right"`.
|
||||||
* If you have multiple `ion-item-options`, a side must be provided for each.
|
* If you have multiple `ion-item-options`, a side must be provided for each.
|
||||||
@ -40,25 +40,26 @@ export class ItemOptions {
|
|||||||
*/
|
*/
|
||||||
@Output() ionSwipe: EventEmitter<ItemSliding> = new EventEmitter<ItemSliding>();
|
@Output() ionSwipe: EventEmitter<ItemSliding> = new EventEmitter<ItemSliding>();
|
||||||
|
|
||||||
constructor(private _elementRef: ElementRef, private _renderer: Renderer, private _plt: Platform) {}
|
constructor(
|
||||||
|
private _elementRef: ElementRef,
|
||||||
|
private _renderer: Renderer,
|
||||||
|
private _plt: Platform
|
||||||
|
) { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @hidden
|
* @hidden
|
||||||
*/
|
*/
|
||||||
getSides(): number {
|
getSides(): number {
|
||||||
if (isPresent(this.side)) {
|
switch (this.side) {
|
||||||
switch (this.side) {
|
case 'left':
|
||||||
case 'left':
|
return ITEM_SIDE_FLAG_LEFT;
|
||||||
return ITEM_SIDE_FLAG_LEFT;
|
case 'right':
|
||||||
case 'right':
|
return ITEM_SIDE_FLAG_RIGHT;
|
||||||
return ITEM_SIDE_FLAG_RIGHT;
|
case 'start':
|
||||||
case 'start':
|
return this._plt.isRTL() ? ITEM_SIDE_FLAG_RIGHT : ITEM_SIDE_FLAG_LEFT;
|
||||||
return this._plt.isRTL() ? ITEM_SIDE_FLAG_RIGHT : ITEM_SIDE_FLAG_LEFT;
|
default: // end
|
||||||
case 'end':
|
return this._plt.isRTL() ? ITEM_SIDE_FLAG_LEFT : ITEM_SIDE_FLAG_RIGHT;
|
||||||
return this._plt.isRTL() ? ITEM_SIDE_FLAG_LEFT : ITEM_SIDE_FLAG_RIGHT;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return this._plt.isRTL() ? ITEM_SIDE_FLAG_LEFT : ITEM_SIDE_FLAG_RIGHT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user