Skip to content

Commit

Permalink
fix(util): pass an option to default to right side in isRightSide
Browse files Browse the repository at this point in the history
  • Loading branch information
brandyscarney committed Apr 25, 2017
1 parent 67af71b commit 7bcf5a0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/item/item-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class ItemOptions {
* @hidden
*/
isRightSide(): boolean {
return isRightSide(this.side, this._plt.isRTL);
return isRightSide(this.side, this._plt.isRTL, true);
}

/**
Expand Down
15 changes: 12 additions & 3 deletions src/util/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,24 @@ export function isCheckedProperty(a: any, b: any): boolean {
return (a == b); // tslint:disable-line
};

/** @hidden */
export type Side = 'left' | 'right' | 'start' | 'end';

export function isRightSide(side: Side, isRTL: boolean): boolean {
/**
* @hidden
* Given a side, return if it should be on the right
* based on the value of dir
* @param side the side
* @param isRTL whether the application dir is rtl
* @param defaultRight whether the default side is right
*/
export function isRightSide(side: Side, isRTL: boolean, defaultRight: boolean = false): boolean {
switch (side) {
case 'right': return true;
case 'left': return false;
case 'end': return !isRTL;
// 'start' by default
default: return isRTL;
case 'start': return isRTL;
default: return defaultRight ? !isRTL : isRTL;
}
}

Expand Down

0 comments on commit 7bcf5a0

Please sign in to comment.