mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
fix: convert property bag to args
This commit is contained in:
@@ -63,10 +63,7 @@ function initializeTapAndDoubleTapGestureListener() {
|
||||
|
||||
public onLongPress(motionEvent: android.view.MotionEvent): void {
|
||||
if (this._type & GestureTypes.longPress && this._observer?.callback) {
|
||||
new DOMEvent('longPress').dispatchTo({
|
||||
target: this._target,
|
||||
data: _getLongPressArgs(GestureTypes.longPress, this._target, GestureStateTypes.began, motionEvent),
|
||||
});
|
||||
new DOMEvent('longPress').dispatchTo(this._target, _getLongPressArgs(GestureTypes.longPress, this._target, GestureStateTypes.began, motionEvent));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,10 +71,7 @@ function initializeTapAndDoubleTapGestureListener() {
|
||||
if (this._target.getGestureObservers(GestureTypes.doubleTap).length) {
|
||||
this._tapTimeoutId = timer.setTimeout(() => {
|
||||
if (this._type & GestureTypes.tap && this._observer?.callback) {
|
||||
new DOMEvent('tap').dispatchTo({
|
||||
target: this._target,
|
||||
data: _getTapArgs(GestureTypes.tap, this._target, motionEvent),
|
||||
});
|
||||
new DOMEvent('tap').dispatchTo(this._target, _getTapArgs(GestureTypes.tap, this._target, motionEvent));
|
||||
}
|
||||
timer.clearTimeout(this._tapTimeoutId);
|
||||
}, TapAndDoubleTapGestureListenerImpl.DoubleTapTimeout);
|
||||
@@ -85,10 +79,7 @@ function initializeTapAndDoubleTapGestureListener() {
|
||||
}
|
||||
|
||||
if (this._type & GestureTypes.tap && this._observer?.callback) {
|
||||
new DOMEvent('tap').dispatchTo({
|
||||
target: this._target,
|
||||
data: _getTapArgs(GestureTypes.tap, this._target, motionEvent),
|
||||
});
|
||||
new DOMEvent('tap').dispatchTo(this._target, _getTapArgs(GestureTypes.tap, this._target, motionEvent));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,10 +88,7 @@ function initializeTapAndDoubleTapGestureListener() {
|
||||
timer.clearTimeout(this._tapTimeoutId);
|
||||
}
|
||||
if (this._type & GestureTypes.doubleTap && this._observer?.callback) {
|
||||
new DOMEvent('doubleTap').dispatchTo({
|
||||
target: this._target,
|
||||
data: _getTapArgs(GestureTypes.doubleTap, this._target, motionEvent),
|
||||
});
|
||||
new DOMEvent('doubleTap').dispatchTo(this._target, _getTapArgs(GestureTypes.doubleTap, this._target, motionEvent));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -137,10 +125,7 @@ function initializePinchGestureListener() {
|
||||
this._scale = detector.getScaleFactor();
|
||||
|
||||
if (this._observer?.callback) {
|
||||
new DOMEvent('pinch').dispatchTo({
|
||||
target: this._target,
|
||||
data: new PinchGestureEventData(this._target, detector, this._scale, this._target, GestureStateTypes.began),
|
||||
});
|
||||
new DOMEvent('pinch').dispatchTo(this._target, new PinchGestureEventData(this._target, detector, this._scale, this._target, GestureStateTypes.began));
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -150,10 +135,7 @@ function initializePinchGestureListener() {
|
||||
this._scale *= detector.getScaleFactor();
|
||||
|
||||
if (this._observer?.callback) {
|
||||
new DOMEvent('pinch').dispatchTo({
|
||||
target: this._target,
|
||||
data: new PinchGestureEventData(this._target, detector, this._scale, this._target, GestureStateTypes.changed),
|
||||
});
|
||||
new DOMEvent('pinch').dispatchTo(this._target, new PinchGestureEventData(this._target, detector, this._scale, this._target, GestureStateTypes.changed));
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -163,10 +145,7 @@ function initializePinchGestureListener() {
|
||||
this._scale *= detector.getScaleFactor();
|
||||
|
||||
if (this._observer?.callback) {
|
||||
new DOMEvent('pinch').dispatchTo({
|
||||
target: this._target,
|
||||
data: new PinchGestureEventData(this._target, detector, this._scale, this._target, GestureStateTypes.ended),
|
||||
});
|
||||
new DOMEvent('pinch').dispatchTo(this._target, new PinchGestureEventData(this._target, detector, this._scale, this._target, GestureStateTypes.ended));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -212,19 +191,13 @@ function initializeSwipeGestureListener() {
|
||||
if (Math.abs(deltaX) > SWIPE_THRESHOLD && Math.abs(velocityX) > SWIPE_VELOCITY_THRESHOLD) {
|
||||
if (deltaX > 0) {
|
||||
if (this._observer?.callback) {
|
||||
new DOMEvent('swipe').dispatchTo({
|
||||
target: this._target,
|
||||
data: _getSwipeArgs(SwipeDirection.right, this._target, initialEvent, currentEvent),
|
||||
});
|
||||
new DOMEvent('swipe').dispatchTo(this._target, _getSwipeArgs(SwipeDirection.right, this._target, initialEvent, currentEvent));
|
||||
}
|
||||
|
||||
result = true;
|
||||
} else {
|
||||
if (this._observer?.callback) {
|
||||
new DOMEvent('swipe').dispatchTo({
|
||||
target: this._target,
|
||||
data: _getSwipeArgs(SwipeDirection.left, this._target, initialEvent, currentEvent),
|
||||
});
|
||||
new DOMEvent('swipe').dispatchTo(this._target, _getSwipeArgs(SwipeDirection.left, this._target, initialEvent, currentEvent));
|
||||
}
|
||||
result = true;
|
||||
}
|
||||
@@ -233,18 +206,12 @@ function initializeSwipeGestureListener() {
|
||||
if (Math.abs(deltaY) > SWIPE_THRESHOLD && Math.abs(velocityY) > SWIPE_VELOCITY_THRESHOLD) {
|
||||
if (deltaY > 0) {
|
||||
if (this._observer?.callback) {
|
||||
new DOMEvent('swipe').dispatchTo({
|
||||
target: this._target,
|
||||
data: _getSwipeArgs(SwipeDirection.down, this._target, initialEvent, currentEvent),
|
||||
});
|
||||
new DOMEvent('swipe').dispatchTo(this._target, _getSwipeArgs(SwipeDirection.down, this._target, initialEvent, currentEvent));
|
||||
}
|
||||
result = true;
|
||||
} else {
|
||||
if (this._observer?.callback) {
|
||||
new DOMEvent('swipe').dispatchTo({
|
||||
target: this._target,
|
||||
data: _getSwipeArgs(SwipeDirection.up, this._target, initialEvent, currentEvent),
|
||||
});
|
||||
new DOMEvent('swipe').dispatchTo(this._target, _getSwipeArgs(SwipeDirection.up, this._target, initialEvent, currentEvent));
|
||||
}
|
||||
result = true;
|
||||
}
|
||||
@@ -372,10 +339,7 @@ export class GesturesObserver extends GesturesObserverBase {
|
||||
this._eventData.prepare(this.target, motionEvent);
|
||||
|
||||
if (this.callback) {
|
||||
new DOMEvent('touch').dispatchTo({
|
||||
target: this.target,
|
||||
data: this._eventData,
|
||||
});
|
||||
new DOMEvent('touch').dispatchTo(this.target, this._eventData);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -504,10 +468,7 @@ class CustomPanGestureDetector {
|
||||
private trackStop(currentEvent: android.view.MotionEvent, cacheEvent: boolean) {
|
||||
if (this.isTracking) {
|
||||
if (this.observer?.callback) {
|
||||
new DOMEvent('pan').dispatchTo({
|
||||
target: this.target,
|
||||
data: _getPanArgs(this.deltaX, this.deltaY, this.target, GestureStateTypes.ended, null, currentEvent),
|
||||
});
|
||||
new DOMEvent('pan').dispatchTo(this.target, _getPanArgs(this.deltaX, this.deltaY, this.target, GestureStateTypes.ended, null, currentEvent));
|
||||
}
|
||||
|
||||
this.deltaX = undefined;
|
||||
@@ -529,10 +490,7 @@ class CustomPanGestureDetector {
|
||||
this.isTracking = true;
|
||||
|
||||
if (this.observer?.callback) {
|
||||
new DOMEvent('pan').dispatchTo({
|
||||
target: this.target,
|
||||
data: _getPanArgs(0, 0, this.target, GestureStateTypes.began, null, currentEvent),
|
||||
});
|
||||
new DOMEvent('pan').dispatchTo(this.target, _getPanArgs(0, 0, this.target, GestureStateTypes.began, null, currentEvent));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -542,10 +500,7 @@ class CustomPanGestureDetector {
|
||||
this.deltaY = current.y - this.initialY;
|
||||
|
||||
if (this.observer?.callback) {
|
||||
new DOMEvent('pan').dispatchTo({
|
||||
target: this.target,
|
||||
data: _getPanArgs(this.deltaX, this.deltaY, this.target, GestureStateTypes.changed, null, currentEvent),
|
||||
});
|
||||
new DOMEvent('pan').dispatchTo(this.target, _getPanArgs(this.deltaX, this.deltaY, this.target, GestureStateTypes.changed, null, currentEvent));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -665,10 +620,7 @@ class CustomRotateGestureDetector {
|
||||
};
|
||||
|
||||
if (this.observer?.callback) {
|
||||
new DOMEvent('rotation').dispatchTo({
|
||||
target: this.target,
|
||||
data: args,
|
||||
});
|
||||
new DOMEvent('rotation').dispatchTo(this.target, args);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -134,141 +134,37 @@ export class GesturesObserver extends GesturesObserverBase {
|
||||
// release, we may make them bubbling.
|
||||
|
||||
if (type & GestureTypes.tap) {
|
||||
nativeView.addGestureRecognizer(
|
||||
this._createRecognizer(
|
||||
GestureTypes.tap,
|
||||
(args) =>
|
||||
args.view &&
|
||||
new DOMEvent('tap').dispatchTo({
|
||||
target: args.view as View,
|
||||
data: _getTapData(args),
|
||||
})
|
||||
)
|
||||
);
|
||||
nativeView.addGestureRecognizer(this._createRecognizer(GestureTypes.tap, (args) => args.view && new DOMEvent('tap').dispatchTo(args.view as View, _getTapData(args))));
|
||||
}
|
||||
|
||||
if (type & GestureTypes.doubleTap) {
|
||||
nativeView.addGestureRecognizer(
|
||||
this._createRecognizer(
|
||||
GestureTypes.doubleTap,
|
||||
(args) =>
|
||||
args.view &&
|
||||
new DOMEvent('doubleTap').dispatchTo({
|
||||
target: args.view as View,
|
||||
data: _getTapData(args),
|
||||
})
|
||||
)
|
||||
);
|
||||
nativeView.addGestureRecognizer(this._createRecognizer(GestureTypes.doubleTap, (args) => args.view && new DOMEvent('doubleTap').dispatchTo(args.view as View, _getTapData(args))));
|
||||
}
|
||||
|
||||
if (type & GestureTypes.pinch) {
|
||||
nativeView.addGestureRecognizer(
|
||||
this._createRecognizer(
|
||||
GestureTypes.pinch,
|
||||
(args) =>
|
||||
args.view &&
|
||||
new DOMEvent('pinch').dispatchTo({
|
||||
target: args.view as View,
|
||||
data: _getPinchData(args),
|
||||
})
|
||||
)
|
||||
);
|
||||
nativeView.addGestureRecognizer(this._createRecognizer(GestureTypes.pinch, (args) => args.view && new DOMEvent('pinch').dispatchTo(args.view as View, _getPinchData(args))));
|
||||
}
|
||||
|
||||
if (type & GestureTypes.pan) {
|
||||
nativeView.addGestureRecognizer(
|
||||
this._createRecognizer(
|
||||
GestureTypes.pan,
|
||||
(args) =>
|
||||
args.view &&
|
||||
new DOMEvent('pan').dispatchTo({
|
||||
target: args.view as View,
|
||||
data: _getPanData(args, target.nativeViewProtected),
|
||||
})
|
||||
)
|
||||
);
|
||||
nativeView.addGestureRecognizer(this._createRecognizer(GestureTypes.pan, (args) => args.view && new DOMEvent('pan').dispatchTo(args.view as View, _getPanData(args, target.nativeViewProtected))));
|
||||
}
|
||||
|
||||
if (type & GestureTypes.swipe) {
|
||||
nativeView.addGestureRecognizer(
|
||||
this._createRecognizer(
|
||||
GestureTypes.swipe,
|
||||
(args) =>
|
||||
args.view &&
|
||||
new DOMEvent('swipe').dispatchTo({
|
||||
target: args.view as View,
|
||||
data: _getSwipeData(args),
|
||||
}),
|
||||
UISwipeGestureRecognizerDirection.Down
|
||||
)
|
||||
);
|
||||
nativeView.addGestureRecognizer(this._createRecognizer(GestureTypes.swipe, (args) => args.view && new DOMEvent('swipe').dispatchTo(args.view as View, _getSwipeData(args)), UISwipeGestureRecognizerDirection.Down));
|
||||
|
||||
nativeView.addGestureRecognizer(
|
||||
this._createRecognizer(
|
||||
GestureTypes.swipe,
|
||||
(args) =>
|
||||
args.view &&
|
||||
new DOMEvent('swipe').dispatchTo({
|
||||
target: args.view as View,
|
||||
data: _getSwipeData(args),
|
||||
}),
|
||||
UISwipeGestureRecognizerDirection.Left
|
||||
)
|
||||
);
|
||||
nativeView.addGestureRecognizer(this._createRecognizer(GestureTypes.swipe, (args) => args.view && new DOMEvent('swipe').dispatchTo(args.view as View, _getSwipeData(args)), UISwipeGestureRecognizerDirection.Left));
|
||||
|
||||
nativeView.addGestureRecognizer(
|
||||
this._createRecognizer(
|
||||
GestureTypes.swipe,
|
||||
(args) =>
|
||||
args.view &&
|
||||
new DOMEvent('swipe').dispatchTo({
|
||||
target: args.view as View,
|
||||
data: _getSwipeData(args),
|
||||
}),
|
||||
UISwipeGestureRecognizerDirection.Right
|
||||
)
|
||||
);
|
||||
nativeView.addGestureRecognizer(this._createRecognizer(GestureTypes.swipe, (args) => args.view && new DOMEvent('swipe').dispatchTo(args.view as View, _getSwipeData(args)), UISwipeGestureRecognizerDirection.Right));
|
||||
|
||||
nativeView.addGestureRecognizer(
|
||||
this._createRecognizer(
|
||||
GestureTypes.swipe,
|
||||
(args) =>
|
||||
args.view &&
|
||||
new DOMEvent('swipe').dispatchTo({
|
||||
target: args.view as View,
|
||||
data: _getSwipeData(args),
|
||||
}),
|
||||
UISwipeGestureRecognizerDirection.Up
|
||||
)
|
||||
);
|
||||
nativeView.addGestureRecognizer(this._createRecognizer(GestureTypes.swipe, (args) => args.view && new DOMEvent('swipe').dispatchTo(args.view as View, _getSwipeData(args)), UISwipeGestureRecognizerDirection.Up));
|
||||
}
|
||||
|
||||
if (type & GestureTypes.rotation) {
|
||||
nativeView.addGestureRecognizer(
|
||||
this._createRecognizer(
|
||||
GestureTypes.rotation,
|
||||
(args) =>
|
||||
args.view &&
|
||||
new DOMEvent('rotation').dispatchTo({
|
||||
target: args.view as View,
|
||||
data: _getRotationData(args),
|
||||
})
|
||||
)
|
||||
);
|
||||
nativeView.addGestureRecognizer(this._createRecognizer(GestureTypes.rotation, (args) => args.view && new DOMEvent('rotation').dispatchTo(args.view as View, _getRotationData(args))));
|
||||
}
|
||||
|
||||
if (type & GestureTypes.longPress) {
|
||||
nativeView.addGestureRecognizer(
|
||||
this._createRecognizer(
|
||||
GestureTypes.longPress,
|
||||
(args) =>
|
||||
args.view &&
|
||||
new DOMEvent('longPress').dispatchTo({
|
||||
target: args.view as View,
|
||||
data: _getLongPressData(args),
|
||||
})
|
||||
)
|
||||
);
|
||||
nativeView.addGestureRecognizer(this._createRecognizer(GestureTypes.longPress, (args) => args.view && new DOMEvent('longPress').dispatchTo(args.view as View, _getLongPressData(args))));
|
||||
}
|
||||
|
||||
if (type & GestureTypes.touch) {
|
||||
|
||||
Reference in New Issue
Block a user