refactor(gesture): using disabled

This commit is contained in:
Manu Mtz.-Almeida
2018-01-23 18:55:16 +01:00
parent fbf0059219
commit ef53f249bc
8 changed files with 26 additions and 28 deletions

View File

@ -952,8 +952,8 @@ declare global {
block?: string;
canStart?: GestureCallback;
direction?: string;
disabled?: boolean;
disableScroll?: boolean;
enabled?: boolean;
gestureName?: string;
gesturePriority?: number;
maxAngle?: number;

View File

@ -30,7 +30,7 @@ export class Gesture {
@Prop({ context: 'dom' }) dom: DomController;
@Prop({ context: 'enableListener' }) enableListener: EventListenerEnable;
@Prop() enabled = true;
@Prop() disabled = false;
@Prop() attachTo: ElementRef = 'child';
@Prop() autoBlockAll = false;
@Prop() block: string = null;
@ -90,7 +90,7 @@ export class Gesture {
}
this.hasPress = (types.indexOf('press') > -1);
this.enabledChanged(this.enabled);
this.disabledChanged(this.disabled);
if (this.pan || this.hasPress) {
this.dom.write(() => {
applyStyles(getElementReference(this.el, this.attachTo), GESTURE_INLINE_STYLES);
@ -103,12 +103,12 @@ export class Gesture {
}
}
@Watch('enabled')
protected enabledChanged(isEnabled: boolean) {
@Watch('disabled')
protected disabledChanged(isDisabled: boolean) {
if (this.pan || this.hasPress) {
this.enableListener(this, 'touchstart', isEnabled, this.attachTo, this.passive);
this.enableListener(this, 'mousedown', isEnabled, this.attachTo, this.passive);
if (!isEnabled) {
this.enableListener(this, 'touchstart', !isDisabled, this.attachTo, this.passive);
this.enableListener(this, 'mousedown', !isDisabled, this.attachTo, this.passive);
if (isDisabled) {
this.abortGesture();
}
}

View File

@ -37,7 +37,7 @@ string
boolean
#### enabled
#### disabled
boolean
@ -134,7 +134,7 @@ string
boolean
#### enabled
#### disabled
boolean

View File

@ -452,7 +452,7 @@ export class Menu {
'onEnd': this.onDragEnd.bind(this),
'maxEdgeStart': this.maxEdgeStart,
'edge': this.side,
'enabled': this.isActive() && this.swipeEnabled,
'disabled': !this.isActive() || !this.swipeEnabled,
'gestureName': 'menu-swipe',
'gesturePriority': 10,
'type': 'pan',

View File

@ -411,20 +411,18 @@ export class Range implements BaseInputComponent {
render() {
return [
<slot name='start'></slot>,
<ion-gesture
{...{
disableScroll: true,
onStart: this.onDragStart.bind(this),
onMove: this.onDragMove.bind(this),
onEnd: this.onDragEnd.bind(this),
enabled: !this.disabled,
gestureName: 'range',
gesturePriority: 30,
type: 'pan',
direction: 'x',
threshold: 0
}}
>
<ion-gesture {...{
disableScroll: true,
onStart: this.onDragStart.bind(this),
onMove: this.onDragMove.bind(this),
onEnd: this.onDragEnd.bind(this),
disabled: this.disabled,
gestureName: 'range',
gesturePriority: 30,
type: 'pan',
direction: 'x',
threshold: 0
}}>
<div class='range-slider'>
{this.ticks.map(t =>
<div

View File

@ -361,7 +361,7 @@ export class Refresher {
render() {
return <ion-gesture {...this.gestureConfig}
enabled={this.enabled}>
disabled={!this.enabled}>
<slot></slot>
</ion-gesture>;
}

View File

@ -268,7 +268,7 @@ export class ReorderGroup {
onStart: this.onDragStart.bind(this),
onMove: this.onDragMove.bind(this),
onEnd: this.onDragEnd.bind(this),
enabled: this.enabled,
disabled: !this.enabled,
disableScroll: true,
gestureName: 'reorder',
gesturePriority: 30,

View File

@ -207,7 +207,7 @@ export class Toggle implements CheckboxInput {
render() {
return [
<ion-gesture {...this.gestureConfig}
enabled={!this.disabled} tabIndex={-1}>
disabled={this.disabled} tabIndex={-1}>
<div class='toggle-icon'>
<div class='toggle-inner'/>
</div>