mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-23 14:01:20 +08:00
@ -40,6 +40,14 @@ export class Nav extends NavBase {
|
|||||||
width() {
|
width() {
|
||||||
return this.domElement.offsetWidth;
|
return this.domElement.offsetWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get swipeBackEnabled() {
|
||||||
|
let activeItem = this.getActive();
|
||||||
|
if (activeItem) {
|
||||||
|
return activeItem.enableBack;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
new IonicComponent(Nav, {});
|
new IonicComponent(Nav, {});
|
||||||
|
|
||||||
|
@ -7,12 +7,17 @@ import {Nav} from './nav';
|
|||||||
|
|
||||||
|
|
||||||
@Directive({
|
@Directive({
|
||||||
selector: 'swipe-handle'
|
selector: 'swipe-handle',
|
||||||
|
hostProperties: {
|
||||||
|
'!nav.swipeBackEnabled': 'hidden'
|
||||||
|
}
|
||||||
})
|
})
|
||||||
export class SwipeHandle {
|
export class SwipeHandle {
|
||||||
constructor(@Parent() nav: Nav, elementRef: ElementRef) {
|
constructor(@Parent() nav: Nav, elementRef: ElementRef) {
|
||||||
let gesture = new Gesture(elementRef.domElement);
|
let gesture = new Gesture(elementRef.domElement);
|
||||||
|
|
||||||
|
this.nav = nav;
|
||||||
|
|
||||||
gesture.listen();
|
gesture.listen();
|
||||||
|
|
||||||
gesture.on('panend', onDragEnd);
|
gesture.on('panend', onDragEnd);
|
||||||
@ -23,6 +28,9 @@ export class SwipeHandle {
|
|||||||
let swipeableAreaWidth = null;
|
let swipeableAreaWidth = null;
|
||||||
|
|
||||||
function onDragEnd(ev) {
|
function onDragEnd(ev) {
|
||||||
|
ev.preventDefault();
|
||||||
|
ev.stopPropagation();
|
||||||
|
|
||||||
// TODO: POLISH THESE NUMBERS WITH GOOD MATHIFICATION
|
// TODO: POLISH THESE NUMBERS WITH GOOD MATHIFICATION
|
||||||
|
|
||||||
let progress = (ev.gesture.center.x - startX) / swipeableAreaWidth;
|
let progress = (ev.gesture.center.x - startX) / swipeableAreaWidth;
|
||||||
@ -57,6 +65,9 @@ export class SwipeHandle {
|
|||||||
|
|
||||||
function onDragHorizontal(ev) {
|
function onDragHorizontal(ev) {
|
||||||
if (startX === null) {
|
if (startX === null) {
|
||||||
|
ev.preventDefault();
|
||||||
|
ev.stopPropagation();
|
||||||
|
|
||||||
startX = ev.gesture.center.x;
|
startX = ev.gesture.center.x;
|
||||||
swipeableAreaWidth = nav.width() - startX;
|
swipeableAreaWidth = nav.width() - startX;
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ import {Tabs} from './tabs';
|
|||||||
properties: ['tab'],
|
properties: ['tab'],
|
||||||
hostProperties: {
|
hostProperties: {
|
||||||
'btnId': 'attr.id',
|
'btnId': 'attr.id',
|
||||||
'ariaControls': 'attr.aria-controls',
|
'panelId': 'attr.aria-controls',
|
||||||
'tab.isSelected': 'attr.aria-selected'
|
'tab.isSelected': 'attr.aria-selected'
|
||||||
},
|
},
|
||||||
hostAttributes: {
|
hostAttributes: {
|
||||||
@ -28,7 +28,7 @@ export class TabButton {
|
|||||||
|
|
||||||
onInit() {
|
onInit() {
|
||||||
this.btnId = 'tab-button-' + this.tab.id;
|
this.btnId = 'tab-button-' + this.tab.id;
|
||||||
this.ariaControls = 'tab-content-' + this.tab.id;
|
this.panelId = 'tab-panel-' + this.tab.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
onClick(ev) {
|
onClick(ev) {
|
||||||
|
@ -6,10 +6,10 @@ import {Injector} from 'angular2/di';
|
|||||||
|
|
||||||
import {Tabs} from './tabs';
|
import {Tabs} from './tabs';
|
||||||
import {Content} from '../content/content';
|
import {Content} from '../content/content';
|
||||||
import * as util from 'ionic/util';
|
|
||||||
import {IonicComponent} from 'ionic/config/component';
|
import {IonicComponent} from 'ionic/config/component';
|
||||||
import {NavBase} from '../nav/nav-base';
|
import {NavBase} from '../nav/nav-base';
|
||||||
|
|
||||||
|
let tabId = -1;
|
||||||
|
|
||||||
@Directive({
|
@Directive({
|
||||||
selector: 'ion-tab',
|
selector: 'ion-tab',
|
||||||
@ -19,7 +19,7 @@ import {NavBase} from '../nav/nav-base';
|
|||||||
'tabIcon'
|
'tabIcon'
|
||||||
],
|
],
|
||||||
hostProperties: {
|
hostProperties: {
|
||||||
'contentId': 'attr.id',
|
'panelId': 'attr.id',
|
||||||
'labeledBy': 'attr.aria-labelledby',
|
'labeledBy': 'attr.aria-labelledby',
|
||||||
'ariaHidden': 'attr.aria-hidden',
|
'ariaHidden': 'attr.aria-hidden',
|
||||||
'isSelected': 'class.show-tab'
|
'isSelected': 'class.show-tab'
|
||||||
@ -38,8 +38,8 @@ export class Tab {
|
|||||||
this.nav = new NavBase(loader, injector);
|
this.nav = new NavBase(loader, injector);
|
||||||
this.domElement = elementRef.domElement;
|
this.domElement = elementRef.domElement;
|
||||||
|
|
||||||
this.id = util.nextUid();
|
this.id = ++tabId;
|
||||||
this.contentId = 'tab-content-' + this.id;
|
this.panelId = 'tab-panel-' + this.id;
|
||||||
this.labeledBy = 'tab-button-' + this.id;
|
this.labeledBy = 'tab-button-' + this.id;
|
||||||
|
|
||||||
tabs.addTab(this);
|
tabs.addTab(this);
|
||||||
|
Reference in New Issue
Block a user