mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
Merge remote-tracking branch 'origin/master'
# Conflicts: # ionic/config/config.ts
This commit is contained in:
@@ -20,14 +20,14 @@ export class ItemSlidingGesture extends DragGesture {
|
||||
this.canDrag = true;
|
||||
this.listen();
|
||||
|
||||
this.on('tap', ev => {
|
||||
this.tap = (ev) => {
|
||||
if (!isFromOptionButtons(ev.target)) {
|
||||
let didClose = this.closeOpened();
|
||||
if (didClose) {
|
||||
preventDefault(ev);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
this.mouseOut = (ev) => {
|
||||
this.onDragEnd(ev);
|
||||
@@ -38,14 +38,14 @@ export class ItemSlidingGesture extends DragGesture {
|
||||
let itemContainerEle = getItemConatiner(ev.target);
|
||||
if (!itemContainerEle) return;
|
||||
|
||||
this.closeOpened(ev, itemContainerEle);
|
||||
this.closeOpened(itemContainerEle);
|
||||
|
||||
let openAmout = this.getOpenAmount(itemContainerEle);
|
||||
let itemData = this.get(itemContainerEle);
|
||||
this.preventDrag = (openAmout > 0);
|
||||
|
||||
if (this.preventDrag) {
|
||||
this.closeOpened(ev);
|
||||
this.closeOpened();
|
||||
return preventDefault(ev);
|
||||
}
|
||||
|
||||
@@ -57,16 +57,18 @@ export class ItemSlidingGesture extends DragGesture {
|
||||
if (ev.srcEvent.type.indexOf('mouse') > -1) {
|
||||
ev.target.addEventListener('mouseout', this.mouseOut);
|
||||
}
|
||||
|
||||
this.dragEnded = false;
|
||||
}
|
||||
|
||||
onDrag(ev) {
|
||||
if (Math.abs(ev.deltaY) > 30) {
|
||||
if (this.dragEnded || this.preventDrag || Math.abs(ev.deltaY) > 30) {
|
||||
this.preventDrag = true;
|
||||
return this.closeOpened(ev);
|
||||
return;
|
||||
}
|
||||
|
||||
let itemContainerEle = getItemConatiner(ev.target);
|
||||
if (!itemContainerEle || !isActive(itemContainerEle) || this.preventDrag) return;
|
||||
if (!itemContainerEle || !isActive(itemContainerEle)) return;
|
||||
|
||||
let itemData = this.get(itemContainerEle);
|
||||
|
||||
@@ -75,9 +77,6 @@ export class ItemSlidingGesture extends DragGesture {
|
||||
if (!itemData.optsWidth) return;
|
||||
}
|
||||
|
||||
itemContainerEle.classList.add('active-slide');
|
||||
itemContainerEle.classList.add('active-options');
|
||||
|
||||
let x = ev.center[this.direction];
|
||||
let delta = x - itemData.startX;
|
||||
|
||||
@@ -88,11 +87,18 @@ export class ItemSlidingGesture extends DragGesture {
|
||||
newX = -Math.min(-itemData.optsWidth, -itemData.optsWidth + (((delta + itemData.optsWidth) * 0.4)));
|
||||
}
|
||||
|
||||
this.open(itemContainerEle, newX, false);
|
||||
raf(() => {
|
||||
if (!this.dragEnded && !this.preventDrag) {
|
||||
isItemActive(itemContainerEle, true);
|
||||
this.open(itemContainerEle, newX, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onDragEnd(ev) {
|
||||
this.preventDrag = false;
|
||||
this.dragEnded = true;
|
||||
|
||||
let itemContainerEle = getItemConatiner(ev.target);
|
||||
if (!itemContainerEle || !isActive(itemContainerEle)) return;
|
||||
|
||||
@@ -108,12 +114,7 @@ export class ItemSlidingGesture extends DragGesture {
|
||||
if (this.getOpenAmount(itemContainerEle) < (restingPoint / 2)) {
|
||||
|
||||
// If we are going left but too slow, or going right, go back to resting
|
||||
if (ev.direction & Hammer.DIRECTION_RIGHT) {
|
||||
// Left
|
||||
restingPoint = 0;
|
||||
|
||||
} else if (Math.abs(ev.velocityX) < 0.3) {
|
||||
// Right
|
||||
if (ev.direction & Hammer.DIRECTION_RIGHT || Math.abs(ev.velocityX) < 0.3) {
|
||||
restingPoint = 0;
|
||||
}
|
||||
}
|
||||
@@ -125,7 +126,7 @@ export class ItemSlidingGesture extends DragGesture {
|
||||
});
|
||||
}
|
||||
|
||||
closeOpened(ev, doNotCloseEle) {
|
||||
closeOpened(doNotCloseEle) {
|
||||
let didClose = false;
|
||||
if (this.openItems) {
|
||||
let openItemElements = this.listEle.querySelectorAll('.active-slide');
|
||||
@@ -153,8 +154,7 @@ export class ItemSlidingGesture extends DragGesture {
|
||||
} else {
|
||||
let timerId = setTimeout(() => {
|
||||
if (slidingEle.style[CSS.transform] === '') {
|
||||
itemContainerEle.classList.remove('active-slide');
|
||||
itemContainerEle.classList.remove('active-options');
|
||||
isItemActive(itemContainerEle, false);
|
||||
this.openItems--;
|
||||
}
|
||||
}, 400);
|
||||
@@ -165,6 +165,12 @@ export class ItemSlidingGesture extends DragGesture {
|
||||
slidingEle.style[CSS.transform] = (openAmount ? 'translate3d(' + -openAmount + 'px,0,0)' : '');
|
||||
|
||||
if (isFinal) {
|
||||
if (openAmount) {
|
||||
isItemActive(itemContainerEle, true);
|
||||
this.on('tap', this.tap);
|
||||
} else {
|
||||
this.off('tap', this.tap);
|
||||
}
|
||||
this.enableScroll(!openAmount);
|
||||
}
|
||||
}
|
||||
@@ -197,6 +203,11 @@ export class ItemSlidingGesture extends DragGesture {
|
||||
}
|
||||
}
|
||||
|
||||
function isItemActive(ele, isActive) {
|
||||
ele.classList[isActive ? 'add' : 'remove']('active-slide');
|
||||
ele.classList[isActive ? 'add' : 'remove']('active-options');
|
||||
}
|
||||
|
||||
function preventDefault(ev) {
|
||||
ev.preventDefault();
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ ion-item-options {
|
||||
right: 0;
|
||||
z-index: $z-index-item-options;
|
||||
height: 100%;
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
ion-item-sliding.active-slide {
|
||||
@@ -39,7 +39,7 @@ ion-item-sliding.active-slide {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
&.active-options ion-item-options{
|
||||
opacity: 1;
|
||||
&.active-options ion-item-options {
|
||||
visibility: visible;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,9 +83,9 @@
|
||||
</ion-item-options>
|
||||
</ion-item-sliding>
|
||||
|
||||
<ion-item-sliding *ng-for="#item of getItems()">
|
||||
<ion-item-sliding *ng-for="#data of getItems()" #item>
|
||||
<ion-item text-wrap detail-push>
|
||||
<h3>ng-for {{item}}</h3>
|
||||
<h3>ng-for {{data}}</h3>
|
||||
</ion-item>
|
||||
<ion-item-options>
|
||||
<button primary (click)="archive($event, item)">Archive</button>
|
||||
|
||||
@@ -33,6 +33,7 @@ export class List extends Ion {
|
||||
constructor(elementRef: ElementRef, config: Config, private zone: NgZone) {
|
||||
super(elementRef, config);
|
||||
this.ele = elementRef.nativeElement;
|
||||
this._enableSliding = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,18 +77,22 @@ export class List extends Ion {
|
||||
}
|
||||
|
||||
enableSlidingItems(shouldEnable) {
|
||||
this._enableSliding = shouldEnable;
|
||||
|
||||
if (this._init) {
|
||||
if (shouldEnable) {
|
||||
this.zone.runOutsideAngular(() => {
|
||||
setTimeout(() => {
|
||||
this.slidingGesture = new ItemSlidingGesture(this, this.ele);
|
||||
});
|
||||
});
|
||||
|
||||
} else {
|
||||
this.slidingGesture && this.slidingGesture.unlisten();
|
||||
if (this._enableSliding !== shouldEnable) {
|
||||
this._enableSliding = shouldEnable;
|
||||
|
||||
if (shouldEnable) {
|
||||
console.debug('enableSlidingItems');
|
||||
this.zone.runOutsideAngular(() => {
|
||||
setTimeout(() => {
|
||||
this.slidingGesture = new ItemSlidingGesture(this, this.ele);
|
||||
});
|
||||
});
|
||||
|
||||
} else {
|
||||
this.slidingGesture && this.slidingGesture.unlisten();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {Menu} from './menu';
|
||||
import {SlideEdgeGesture} from 'ionic/gestures/slide-edge-gesture';
|
||||
import {SlideEdgeGesture} from '../../gestures/slide-edge-gesture';
|
||||
|
||||
import * as util from 'ionic/util';
|
||||
|
||||
|
||||
@@ -116,16 +116,14 @@ class MenuPushType extends MenuType {
|
||||
let easing = 'ease';
|
||||
let duration = 250;
|
||||
|
||||
let contentClosedX, contentOpenedX, menuClosedX, menuOpenedX;
|
||||
let contentOpenedX, menuClosedX, menuOpenedX;
|
||||
|
||||
if (menu.side == 'right') {
|
||||
contentOpenedX = -menu.width() + 'px';
|
||||
contentClosedX = '0px';
|
||||
menuOpenedX = (menu.platform.width() - menu.width()) + 'px';
|
||||
menuClosedX = menu.platform.width() + 'px';
|
||||
} else {
|
||||
contentOpenedX = menu.width() + 'px';
|
||||
contentClosedX = '0px';
|
||||
menuOpenedX = '0px';
|
||||
menuClosedX = -menu.width() + 'px';
|
||||
}
|
||||
@@ -139,7 +137,7 @@ class MenuPushType extends MenuType {
|
||||
this.open.add(menuOpen);
|
||||
|
||||
let contentOpen = new Animation(menu.getContentElement());
|
||||
contentOpen.fromTo(TRANSLATE_X, contentClosedX, contentOpenedX);
|
||||
contentOpen.fromTo(TRANSLATE_X, '0px', contentOpenedX);
|
||||
this.open.add(contentOpen);
|
||||
|
||||
let menuClose = new Animation(menu.getMenuElement());
|
||||
@@ -147,7 +145,7 @@ class MenuPushType extends MenuType {
|
||||
this.close.add(menuClose);
|
||||
|
||||
let contentClose = new Animation(menu.getContentElement());
|
||||
contentClose.fromTo(TRANSLATE_X, contentOpenedX, contentClosedX);
|
||||
contentClose.fromTo(TRANSLATE_X, contentOpenedX, '0px');
|
||||
this.close.add(contentClose);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,14 +147,19 @@ export class Menu extends Ion {
|
||||
if (!type) {
|
||||
type = this.config.get('menuType');
|
||||
}
|
||||
|
||||
this._type = new menuTypes[type](this);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
if (this.config.get('animate') === false) {
|
||||
this._type.open.duration(33);
|
||||
this._type.close.duration(33);
|
||||
_getType() {
|
||||
if (!this._type) {
|
||||
this._type = new menuTypes[this.type](this);
|
||||
|
||||
if (this.config.get('animate') === false) {
|
||||
this._type.open.duration(33);
|
||||
this._type.close.duration(33);
|
||||
}
|
||||
}
|
||||
return this._type;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -171,7 +176,7 @@ export class Menu extends Ion {
|
||||
|
||||
this._before();
|
||||
|
||||
return this._type.setOpen(shouldOpen).then(() => {
|
||||
return this._getType().setOpen(shouldOpen).then(() => {
|
||||
this._after(shouldOpen);
|
||||
});
|
||||
}
|
||||
@@ -185,7 +190,7 @@ export class Menu extends Ion {
|
||||
|
||||
this._before();
|
||||
|
||||
this._type.setProgressStart(this.isOpen);
|
||||
this._getType().setProgressStart(this.isOpen);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -196,7 +201,7 @@ export class Menu extends Ion {
|
||||
if (this.isEnabled) {
|
||||
this._prevent();
|
||||
this.app.setTransitioning(true);
|
||||
this._type.setProgess(value);
|
||||
this._getType().setProgess(value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,7 +213,7 @@ export class Menu extends Ion {
|
||||
if (this.isEnabled) {
|
||||
this._prevent();
|
||||
this.app.setTransitioning(true);
|
||||
this._type.setProgressEnd(shouldComplete).then(isOpen => {
|
||||
this._getType().setProgressEnd(shouldComplete).then(isOpen => {
|
||||
this._after(isOpen);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -450,7 +450,7 @@ export class NavController extends Ion {
|
||||
return done();
|
||||
}
|
||||
|
||||
this._setZIndex(enteringView.instance, leavingView.instance, opts.direction);
|
||||
this._setZIndex(enteringView.instance, leavingView && leavingView.instance, opts.direction);
|
||||
|
||||
this._zone.runOutsideAngular(() => {
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ export class OverlayController {
|
||||
this.app.setEnabled(true);
|
||||
this.app.setTransitioning(false);
|
||||
instance.onPageDidEnter && instance.onPageDidEnter();
|
||||
resolve();
|
||||
resolve(instance);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -119,7 +119,7 @@ export class Refresher {
|
||||
|
||||
this.showIcon = util.isDefined(this.refreshingIcon);
|
||||
|
||||
this._touchMoveListener = this._handleTouchMov.bind(this);
|
||||
this._touchMoveListener = this._handleTouchMove.bind(this);
|
||||
this._touchEndListener = this._handleTouchEnd.bind(this);
|
||||
this._handleScrollListener = this._handleScroll.bind(this);
|
||||
sc.addEventListener('touchmove', this._touchMoveListener);
|
||||
|
||||
@@ -31,10 +31,10 @@ import {isObject, isDefined, isFunction, isArray, extend} from '../util/util';
|
||||
* @App({
|
||||
* template: `<ion-nav [root]="root"></ion-nav>`
|
||||
* config: {
|
||||
* 'tabbarPlacement': 'bottom',
|
||||
* tabbarPlacement: 'bottom',
|
||||
* platforms: {
|
||||
* ios: {
|
||||
* 'tabbarPlacement': 'top',
|
||||
* tabbarPlacement: 'top',
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
@@ -45,7 +45,7 @@ import {isObject, isDefined, isFunction, isArray, extend} from '../util/util';
|
||||
*
|
||||
* ```html
|
||||
* <ion-tabs tabbar-placement="top">
|
||||
* <ion-tab tab-title="Dash" tab-icon="pulse" [root]="DashRoot"></ion-tab>
|
||||
* <ion-tab tab-title="Dash" tab-icon="pulse" [root]="tabRoot"></ion-tab>
|
||||
* </ion-tabs>
|
||||
* ```
|
||||
*
|
||||
|
||||
@@ -7,7 +7,7 @@ import {IONIC_DIRECTIVES} from './directives';
|
||||
|
||||
/**
|
||||
* _For more information on how pages are created, see the [NavController API
|
||||
* reference](../../Nav/NavController/#creating_pages)._
|
||||
* reference](../../components/nav/NavController/#creating_pages)._
|
||||
*
|
||||
* The Page decorator indicates that the decorated class is an Ionic
|
||||
* navigation component, meaning it can be navigated to using a NavController.
|
||||
|
||||
@@ -35,7 +35,10 @@ export class Gesture {
|
||||
}
|
||||
this.hammertime.on(type, cb);
|
||||
(this._callbacks[type] || (this._callbacks[type] = [])).push(cb);
|
||||
//this.element.addEventListener(type, cb);
|
||||
}
|
||||
|
||||
off(type, cb) {
|
||||
this.hammertime.off(type, this._callbacks[type] ? cb : null);
|
||||
}
|
||||
|
||||
listen() {
|
||||
@@ -46,7 +49,6 @@ export class Gesture {
|
||||
if (this.hammertime) {
|
||||
for (let type in this._callbacks) {
|
||||
for (let i = 0; i < this._callbacks[type].length; i++) {
|
||||
//this.element.removeEventListener(type, this._callbacks[type][i]);
|
||||
this.hammertime.off(type, this._callbacks[type]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ export class SqlStorage extends StorageEngine {
|
||||
query(query, ...params) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._db.transaction((tx) => {
|
||||
ts.executeSql(query, params, (tx, res) => {
|
||||
tx.executeSql(query, params, (tx, res) => {
|
||||
resolve({
|
||||
tx: tx,
|
||||
res: res
|
||||
|
||||
@@ -28,8 +28,8 @@ export class Storage {
|
||||
remove(key) {
|
||||
return this._strategy.remove(key);
|
||||
}
|
||||
query(query) {
|
||||
return this._strategy.query(key);
|
||||
query(query, params) {
|
||||
return this._strategy.query(query, params);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ export class StorageEngine {
|
||||
remove(key) {
|
||||
throw Error("remove() not implemented for this storage engine");
|
||||
}
|
||||
query(query) {
|
||||
query(query, params) {
|
||||
throw Error("query() not implemented for this storage engine");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user