fix(build): moving classes outside gesture-controller

This commit is contained in:
Manu Mtz.-Almeida
2018-02-22 16:29:11 +01:00
parent 9a2b89015a
commit 27b7d4fa66
6 changed files with 137 additions and 140 deletions

View File

@@ -0,0 +1,127 @@
export class GestureDelegate {
private ctrl: any|null;
constructor(
ctrl: any,
private gestureDelegateId: number,
private name: string,
private priority: number,
private disableScroll: boolean
) {
this.ctrl = ctrl;
}
canStart(): boolean {
if (!this.ctrl) {
return false;
}
return this.ctrl.canStart(this.name);
}
start(): boolean {
if (!this.ctrl) {
return false;
}
return this.ctrl.start(this.name, this.gestureDelegateId, this.priority);
}
capture(): boolean {
if (!this.ctrl) {
return false;
}
const captured = this.ctrl.capture(this.name, this.gestureDelegateId, this.priority);
if (captured && this.disableScroll) {
this.ctrl.disableScroll(this.gestureDelegateId);
}
return captured;
}
release() {
if (this.ctrl) {
this.ctrl.release(this.gestureDelegateId);
if (this.disableScroll) {
this.ctrl.enableScroll(this.gestureDelegateId);
}
}
}
destroy() {
this.release();
this.ctrl = null;
}
}
export class BlockerDelegate {
private ctrl: any|null;
constructor(
private blockerDelegateId: number,
ctrl: any,
private disable: string[] | undefined,
private disableScroll: boolean
) {
this.ctrl = ctrl;
}
block() {
if (!this.ctrl) {
return;
}
if (this.disable) {
for (const gesture of this.disable) {
this.ctrl.disableGesture(gesture, this.blockerDelegateId);
}
}
if (this.disableScroll) {
this.ctrl.disableScroll(this.blockerDelegateId);
}
}
unblock() {
if (!this.ctrl) {
return;
}
if (this.disable) {
for (const gesture of this.disable) {
this.ctrl.enableGesture(gesture, this.blockerDelegateId);
}
}
if (this.disableScroll) {
this.ctrl.enableScroll(this.blockerDelegateId);
}
}
destroy() {
this.unblock();
this.ctrl = null;
}
}
export interface GestureConfig {
name: string;
priority: number;
disableScroll: boolean;
}
export interface BlockerConfig {
disable?: string[];
disableScroll?: boolean;
}
export const BLOCK_ALL: BlockerConfig = {
disable: ['menu-swipe', 'goback-swipe'],
disableScroll: true
};

View File

@@ -1,4 +1,5 @@
import { Component, Event, EventEmitter, Method } from '@stencil/core';
import { GestureConfig, GestureDelegate, BlockerConfig, BlockerDelegate } from './gesture-controller-utils';
@Component({
@@ -122,130 +123,3 @@ export class GestureController {
return this.gestureId++;
}
}
export class GestureDelegate {
private ctrl: GestureController|null;
constructor(
ctrl: GestureController,
private gestureDelegateId: number,
private name: string,
private priority: number,
private disableScroll: boolean
) {
this.ctrl = ctrl;
}
canStart(): boolean {
if (!this.ctrl) {
return false;
}
return this.ctrl.canStart(this.name);
}
start(): boolean {
if (!this.ctrl) {
return false;
}
return this.ctrl.start(this.name, this.gestureDelegateId, this.priority);
}
capture(): boolean {
if (!this.ctrl) {
return false;
}
const captured = this.ctrl.capture(this.name, this.gestureDelegateId, this.priority);
if (captured && this.disableScroll) {
this.ctrl.disableScroll(this.gestureDelegateId);
}
return captured;
}
release() {
if (this.ctrl) {
this.ctrl.release(this.gestureDelegateId);
if (this.disableScroll) {
this.ctrl.enableScroll(this.gestureDelegateId);
}
}
}
destroy() {
this.release();
this.ctrl = null;
}
}
export class BlockerDelegate {
private ctrl: GestureController|null;
constructor(
private blockerDelegateId: number,
ctrl: GestureController,
private disable: string[] | undefined,
private disableScroll: boolean
) {
this.ctrl = ctrl;
}
block() {
if (!this.ctrl) {
return;
}
if (this.disable) {
for (const gesture of this.disable) {
this.ctrl.disableGesture(gesture, this.blockerDelegateId);
}
}
if (this.disableScroll) {
this.ctrl.disableScroll(this.blockerDelegateId);
}
}
unblock() {
if (!this.ctrl) {
return;
}
if (this.disable) {
for (const gesture of this.disable) {
this.ctrl.enableGesture(gesture, this.blockerDelegateId);
}
}
if (this.disableScroll) {
this.ctrl.enableScroll(this.blockerDelegateId);
}
}
destroy() {
this.unblock();
this.ctrl = null;
}
}
export interface GestureConfig {
name: string;
priority: number;
disableScroll: boolean;
}
export interface BlockerConfig {
disable?: string[];
disableScroll?: boolean;
}
export const BLOCK_ALL: BlockerConfig = {
disable: ['menu-swipe', 'goback-swipe'],
disableScroll: true
};

View File

@@ -1,7 +1,7 @@
import { Component, Event, EventEmitter, EventListenerEnable, Listen, Prop, Watch } from '@stencil/core';
import { ElementRef, assert, now, updateDetail } from '../../utils/helpers';
import { BLOCK_ALL, BlockerConfig, BlockerDelegate, GestureDelegate } from '../gesture-controller/gesture-controller';
import { DomController } from '../../index';
import { DomController, BlockerDelegate, GestureDelegate, BlockerConfig } from '../../index';
import { BLOCK_ALL } from '../gesture-controller/gesture-controller-utils';
import { PanRecognizer } from './recognizers';

View File

@@ -0,0 +1,2 @@
export * from './menu';

View File

@@ -1,6 +1,5 @@
import { Component, Element, Event, EventEmitter, EventListenerEnable, Listen, Method, Prop } from '@stencil/core';
import { Config, DomController, GestureDetail } from '../../index';
import { GestureDelegate } from '../gesture-controller/gesture-controller';
import { Config, DomController, GestureDetail, GestureDelegate } from '../../index';
@Component({
@@ -65,7 +64,9 @@ export class Scroll {
name: 'scroll',
priority: 100,
disableScroll: false,
}).then(gesture => this.gesture = gesture);
}).then((gesture) => {
this.gesture = gesture
});
}
componentDidLoad() {

View File

@@ -33,14 +33,7 @@ export { FabButton } from './components/fab-button/fab-button';
export { Footer } from './components/footer/footer';
export { Gesture, GestureCallback, GestureDetail } from './components/gesture/gesture';
export { PanRecognizer } from './components/gesture/recognizers';
export {
BLOCK_ALL,
BlockerDelegate,
GestureController,
GestureDelegate,
BlockerConfig,
GestureConfig,
} from './components/gesture-controller/gesture-controller';
export * from './components/gesture-controller/gesture-controller-utils';
export { Grid } from './components/grid/grid';
export { Header } from './components/header/header';
export { InfiniteScroll } from './components/infinite-scroll/infinite-scroll';