mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 12:29:55 +08:00
refactor(gesture): using disabled
This commit is contained in:
2
packages/core/src/components.d.ts
vendored
2
packages/core/src/components.d.ts
vendored
@ -952,8 +952,8 @@ declare global {
|
||||
block?: string;
|
||||
canStart?: GestureCallback;
|
||||
direction?: string;
|
||||
disabled?: boolean;
|
||||
disableScroll?: boolean;
|
||||
enabled?: boolean;
|
||||
gestureName?: string;
|
||||
gesturePriority?: number;
|
||||
maxAngle?: number;
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ string
|
||||
boolean
|
||||
|
||||
|
||||
#### enabled
|
||||
#### disabled
|
||||
|
||||
boolean
|
||||
|
||||
@ -134,7 +134,7 @@ string
|
||||
boolean
|
||||
|
||||
|
||||
#### enabled
|
||||
#### disabled
|
||||
|
||||
boolean
|
||||
|
||||
|
@ -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',
|
||||
|
@ -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
|
||||
|
@ -361,7 +361,7 @@ export class Refresher {
|
||||
|
||||
render() {
|
||||
return <ion-gesture {...this.gestureConfig}
|
||||
enabled={this.enabled}>
|
||||
disabled={!this.enabled}>
|
||||
<slot></slot>
|
||||
</ion-gesture>;
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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>
|
||||
|
Reference in New Issue
Block a user