mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-23 05:58:26 +08:00
fix(menu): rtl support
This commit is contained in:
@ -7,7 +7,8 @@ import { Platform } from '../platform/platform';
|
||||
* @hidden
|
||||
*/
|
||||
export class SlideEdgeGesture extends SlideGesture {
|
||||
public edges: Array<string>;
|
||||
|
||||
public edges: string[];
|
||||
public maxEdgeStart: any;
|
||||
private _d: any;
|
||||
|
||||
@ -23,31 +24,42 @@ export class SlideEdgeGesture extends SlideGesture {
|
||||
}
|
||||
|
||||
setEdges(edges: string) {
|
||||
this.edges = edges.split(' ');
|
||||
const isRTL = this.plt.isRTL;
|
||||
this.edges = edges.split(' ').map((value) => {
|
||||
switch (value) {
|
||||
case 'start': return isRTL ? 'right' : 'left';
|
||||
case 'end': return isRTL ? 'left' : 'right';
|
||||
default: value;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
canStart(ev: any): boolean {
|
||||
let coord = pointerCoord(ev);
|
||||
const coord = pointerCoord(ev);
|
||||
this._d = this.getContainerDimensions();
|
||||
return this.edges.every(edge => this._checkEdge(edge, coord));
|
||||
}
|
||||
|
||||
getContainerDimensions() {
|
||||
const plt = this.plt;
|
||||
return {
|
||||
left: 0,
|
||||
top: 0,
|
||||
width: this.plt.width(),
|
||||
height: this.plt.height()
|
||||
width: plt.width(),
|
||||
height: plt.height()
|
||||
};
|
||||
}
|
||||
|
||||
_checkEdge(edge: string, pos: any) {
|
||||
_checkEdge(edge: string, pos: any): boolean {
|
||||
const data = this._d;
|
||||
const maxEdgeStart = this.maxEdgeStart;
|
||||
switch (edge) {
|
||||
case 'left': return pos.x <= this._d.left + this.maxEdgeStart;
|
||||
case 'right': return pos.x >= this._d.width - this.maxEdgeStart;
|
||||
case 'top': return pos.y <= this._d.top + this.maxEdgeStart;
|
||||
case 'bottom': return pos.y >= this._d.height - this.maxEdgeStart;
|
||||
case 'left': return pos.x <= data.left + maxEdgeStart;
|
||||
case 'right': return pos.x >= data.width - maxEdgeStart;
|
||||
case 'top': return pos.y <= data.top + maxEdgeStart;
|
||||
case 'bottom': return pos.y >= data.height - maxEdgeStart;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user