mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 03:32:21 +08:00
fix(sliding): fix core gesture logic + priority configuration
fixes #14763
This commit is contained in:
@ -123,10 +123,13 @@
|
|||||||
|
|
||||||
transition: var(--transition);
|
transition: var(--transition);
|
||||||
|
|
||||||
|
|
||||||
border-width: var(--border-width);
|
border-width: var(--border-width);
|
||||||
border-style: var(--border-style);
|
border-style: var(--border-style);
|
||||||
border-color: var(--border-color);
|
border-color: var(--border-color);
|
||||||
|
|
||||||
|
outline: none;
|
||||||
|
|
||||||
background: var(--background);
|
background: var(--background);
|
||||||
|
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
@ -154,11 +157,6 @@
|
|||||||
// opacity: var(--opacity-hover);
|
// opacity: var(--opacity-hover);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
.button-native:active,
|
|
||||||
.button-native:focus {
|
|
||||||
outline: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.button-inner {
|
.button-inner {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
||||||
|
@ -5,9 +5,6 @@
|
|||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
|
||||||
:host {
|
:host {
|
||||||
--ion-color-base: #{$item-option-button-ios-background-color};
|
|
||||||
--ion-color-contrast: #{$item-option-button-ios-text-color};
|
|
||||||
|
|
||||||
font-size: $item-option-button-ios-font-size;
|
font-size: $item-option-button-ios-font-size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,9 +5,6 @@
|
|||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
|
||||||
:host {
|
:host {
|
||||||
--ion-color-base: #{$item-option-button-md-background-color};
|
|
||||||
--ion-color-contrast: #{$item-option-button-md-text-color};
|
|
||||||
|
|
||||||
font-size: $item-option-button-md-font-size;
|
font-size: $item-option-button-md-font-size;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
|
|
||||||
|
@ -4,10 +4,14 @@
|
|||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
|
||||||
:host {
|
:host {
|
||||||
|
--ion-color-base: #{ion-color(primary, base)};
|
||||||
|
--ion-color-contrast: #{ion-color(primary, contrast)};
|
||||||
|
|
||||||
color: #{current-color(contrast)};
|
color: #{current-color(contrast)};
|
||||||
}
|
}
|
||||||
|
|
||||||
.item-option-native {
|
.item-option-native {
|
||||||
|
@include text-inherit();
|
||||||
@include padding(0, .7em);
|
@include padding(0, .7em);
|
||||||
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@ -18,15 +22,13 @@
|
|||||||
outline: none;
|
outline: none;
|
||||||
|
|
||||||
background: #{current-color(base)};
|
background: #{current-color(base)};
|
||||||
color: inherit;
|
|
||||||
|
|
||||||
font-family: inherit;
|
cursor: pointer;
|
||||||
font-size: inherit;
|
|
||||||
font-weight: inherit;
|
|
||||||
|
|
||||||
letter-spacing: inherit;
|
|
||||||
appearance: none;
|
appearance: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item-option-native:hover {
|
||||||
|
opacity: 0.8;
|
||||||
}
|
}
|
||||||
|
|
||||||
.item-option-button-inner {
|
.item-option-button-inner {
|
||||||
|
@ -35,6 +35,7 @@ ion-item-options {
|
|||||||
|
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
|
|
||||||
|
user-select: none;
|
||||||
z-index: $z-index-item-options;
|
z-index: $z-index-item-options;
|
||||||
|
|
||||||
&.hydrated {
|
&.hydrated {
|
||||||
|
@ -14,6 +14,10 @@ ion-item-sliding {
|
|||||||
user-select: none;
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ion-item-sliding .item {
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
.item-sliding-active-slide .item {
|
.item-sliding-active-slide .item {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ export class ItemSliding {
|
|||||||
el: this.el,
|
el: this.el,
|
||||||
queue: this.queue,
|
queue: this.queue,
|
||||||
gestureName: 'item-swipe',
|
gestureName: 'item-swipe',
|
||||||
gesturePriority: -10,
|
gesturePriority: 20,
|
||||||
threshold: 5,
|
threshold: 5,
|
||||||
canStart: this.canStart.bind(this),
|
canStart: this.canStart.bind(this),
|
||||||
onStart: this.onDragStart.bind(this),
|
onStart: this.onDragStart.bind(this),
|
||||||
@ -152,7 +152,7 @@ export class ItemSliding {
|
|||||||
this.closeOpened();
|
this.closeOpened();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return !!(this.rightOptions || this.leftOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
private onDragStart() {
|
private onDragStart() {
|
||||||
@ -295,7 +295,7 @@ export class ItemSliding {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @hidden */
|
/** @hidden */
|
||||||
export function swipeShouldReset(isResetDirection: boolean, isMovingFast: boolean, isOnResetZone: boolean): boolean {
|
function swipeShouldReset(isResetDirection: boolean, isMovingFast: boolean, isOnResetZone: boolean): boolean {
|
||||||
// The logic required to know when the sliding item should close (openAmount=0)
|
// The logic required to know when the sliding item should close (openAmount=0)
|
||||||
// depends on three booleans (isCloseDirection, isMovingFast, isOnCloseZone)
|
// depends on three booleans (isCloseDirection, isMovingFast, isOnCloseZone)
|
||||||
// and it ended up being too complicated to be written manually without errors
|
// and it ended up being too complicated to be written manually without errors
|
||||||
|
@ -26,6 +26,12 @@
|
|||||||
|
|
||||||
<ion-content>
|
<ion-content>
|
||||||
|
|
||||||
|
<ion-refresher id="refresher">
|
||||||
|
<ion-refresher-content pulling-text="Pull to refresh..." refreshing-spinner="bubbles" refreshing-text="Refreshing...">
|
||||||
|
</ion-refresher-content>
|
||||||
|
</ion-refresher>
|
||||||
|
|
||||||
|
|
||||||
<div padding>
|
<div padding>
|
||||||
<ion-button expand="block" onclick="toggleSliding()">Toggle sliding</ion-button>
|
<ion-button expand="block" onclick="toggleSliding()">Toggle sliding</ion-button>
|
||||||
<ion-button expand="block" onclick="toggleDynamicOptions()">Toggle Dynamic Options</ion-button>
|
<ion-button expand="block" onclick="toggleDynamicOptions()">Toggle Dynamic Options</ion-button>
|
||||||
|
@ -84,6 +84,9 @@
|
|||||||
|
|
||||||
button, a {
|
button, a {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
user-select: none;
|
||||||
|
|
||||||
|
-webkit-user-drag: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.item-state {
|
.item-state {
|
||||||
|
@ -179,7 +179,7 @@ export class Menu {
|
|||||||
el: this.doc,
|
el: this.doc,
|
||||||
queue: this.queue,
|
queue: this.queue,
|
||||||
gestureName: 'menu-swipe',
|
gestureName: 'menu-swipe',
|
||||||
gesturePriority: 10,
|
gesturePriority: 40,
|
||||||
threshold: 10,
|
threshold: 10,
|
||||||
canStart: this.canStart.bind(this),
|
canStart: this.canStart.bind(this),
|
||||||
onWillStart: this.onWillStart.bind(this),
|
onWillStart: this.onWillStart.bind(this),
|
||||||
|
@ -114,7 +114,7 @@ export class Nav implements NavOutlet {
|
|||||||
el: this.win.document.body,
|
el: this.win.document.body,
|
||||||
queue: this.queue,
|
queue: this.queue,
|
||||||
gestureName: 'goback-swipe',
|
gestureName: 'goback-swipe',
|
||||||
gesturePriority: 10,
|
gesturePriority: 30,
|
||||||
threshold: 10,
|
threshold: 10,
|
||||||
canStart: this.canSwipeBack.bind(this),
|
canStart: this.canSwipeBack.bind(this),
|
||||||
onStart: this.swipeBackStart.bind(this),
|
onStart: this.swipeBackStart.bind(this),
|
||||||
|
@ -58,7 +58,7 @@ export class PickerColumnCmp {
|
|||||||
el: this.el,
|
el: this.el,
|
||||||
queue: this.queue,
|
queue: this.queue,
|
||||||
gestureName: 'picker-swipe',
|
gestureName: 'picker-swipe',
|
||||||
gesturePriority: 10,
|
gesturePriority: 100,
|
||||||
threshold: 0,
|
threshold: 0,
|
||||||
onStart: this.onDragStart.bind(this),
|
onStart: this.onDragStart.bind(this),
|
||||||
onMove: this.onDragMove.bind(this),
|
onMove: this.onDragMove.bind(this),
|
||||||
|
@ -148,7 +148,7 @@ export class Range implements BaseInput {
|
|||||||
el: this.rangeSlider!,
|
el: this.rangeSlider!,
|
||||||
queue: this.queue,
|
queue: this.queue,
|
||||||
gestureName: 'range',
|
gestureName: 'range',
|
||||||
gesturePriority: 30,
|
gesturePriority: 100,
|
||||||
threshold: 0,
|
threshold: 0,
|
||||||
onStart: this.onDragStart.bind(this),
|
onStart: this.onDragStart.bind(this),
|
||||||
onMove: this.onDragMove.bind(this),
|
onMove: this.onDragMove.bind(this),
|
||||||
@ -391,7 +391,7 @@ export class Range implements BaseInput {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ratioToValue(
|
function ratioToValue(
|
||||||
ratio: number,
|
ratio: number,
|
||||||
min: number,
|
min: number,
|
||||||
max: number,
|
max: number,
|
||||||
@ -404,6 +404,6 @@ export function ratioToValue(
|
|||||||
return clamp(min, value, max);
|
return clamp(min, value, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function valueToRatio(value: number, min: number, max: number): number {
|
function valueToRatio(value: number, min: number, max: number): number {
|
||||||
return clamp(0, (value - min) / (max - min), 1);
|
return clamp(0, (value - min) / (max - min), 1);
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ export class Refresher {
|
|||||||
gestureName: 'refresher',
|
gestureName: 'refresher',
|
||||||
gesturePriority: 10,
|
gesturePriority: 10,
|
||||||
direction: 'y',
|
direction: 'y',
|
||||||
threshold: 5,
|
threshold: 10,
|
||||||
passive: false,
|
passive: false,
|
||||||
canStart: this.canStart.bind(this),
|
canStart: this.canStart.bind(this),
|
||||||
onStart: this.onStart.bind(this),
|
onStart: this.onStart.bind(this),
|
||||||
@ -175,6 +175,8 @@ export class Refresher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private onStart() {
|
private onStart() {
|
||||||
|
console.log('start');
|
||||||
|
|
||||||
this.progress = 0;
|
this.progress = 0;
|
||||||
this.state = RefresherState.Inactive;
|
this.state = RefresherState.Inactive;
|
||||||
}
|
}
|
||||||
@ -341,6 +343,7 @@ export class Refresher {
|
|||||||
|
|
||||||
hostData() {
|
hostData() {
|
||||||
return {
|
return {
|
||||||
|
slot: 'fixed',
|
||||||
class: {
|
class: {
|
||||||
...createThemedClasses(this.mode, 'refresher'),
|
...createThemedClasses(this.mode, 'refresher'),
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ export class ReorderGroup {
|
|||||||
el: this.doc.body,
|
el: this.doc.body,
|
||||||
queue: this.queue,
|
queue: this.queue,
|
||||||
gestureName: 'reorder',
|
gestureName: 'reorder',
|
||||||
gesturePriority: 30,
|
gesturePriority: 90,
|
||||||
disableScroll: true,
|
disableScroll: true,
|
||||||
threshold: 0,
|
threshold: 0,
|
||||||
direction: 'y',
|
direction: 'y',
|
||||||
|
@ -116,7 +116,7 @@ export class Toggle implements CheckboxInput {
|
|||||||
el: this.el,
|
el: this.el,
|
||||||
queue: this.queue,
|
queue: this.queue,
|
||||||
gestureName: 'toggle',
|
gestureName: 'toggle',
|
||||||
gesturePriority: 30,
|
gesturePriority: 100,
|
||||||
threshold: 0,
|
threshold: 0,
|
||||||
onStart: this.onDragStart.bind(this),
|
onStart: this.onDragStart.bind(this),
|
||||||
onMove: this.onDragMove.bind(this),
|
onMove: this.onDragMove.bind(this),
|
||||||
|
@ -111,13 +111,11 @@ export function createGesture(config: GestureConfig): Gesture {
|
|||||||
// gesture is currently being detected
|
// gesture is currently being detected
|
||||||
calcGestureData(detail, ev);
|
calcGestureData(detail, ev);
|
||||||
if (pan.detect(detail.currentX, detail.currentY)) {
|
if (pan.detect(detail.currentX, detail.currentY)) {
|
||||||
if (pan.isGesture()) {
|
if (!pan.isGesture() || !tryToCapturePan()) {
|
||||||
if (!tryToCapturePan()) {
|
|
||||||
abortGesture();
|
abortGesture();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function fireOnMove() {
|
function fireOnMove() {
|
||||||
// Since fireOnMove is called inside a RAF, onEnd() might be called,
|
// Since fireOnMove is called inside a RAF, onEnd() might be called,
|
||||||
|
Reference in New Issue
Block a user