Skip to content

Commit

Permalink
fix(sliding): fix core gesture logic + priority configuration
Browse files Browse the repository at this point in the history
fixes #14763
  • Loading branch information
manucorporat committed Aug 7, 2018
1 parent 419ef7b commit a77ee2a
Show file tree
Hide file tree
Showing 18 changed files with 42 additions and 33 deletions.
8 changes: 3 additions & 5 deletions core/src/components/button/button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,13 @@

transition: var(--transition);


border-width: var(--border-width);
border-style: var(--border-style);
border-color: var(--border-color);

outline: none;

background: var(--background);

line-height: 1;
Expand Down Expand Up @@ -154,11 +157,6 @@
// opacity: var(--opacity-hover);
// }

.button-native:active,
.button-native:focus {
outline: none;
}

.button-inner {
display: flex;

Expand Down
3 changes: 0 additions & 3 deletions core/src/components/item-option/item-option.ios.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
// --------------------------------------------------

: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;
}

Expand Down
3 changes: 0 additions & 3 deletions core/src/components/item-option/item-option.md.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
// --------------------------------------------------

: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-weight: 500;

Expand Down
14 changes: 8 additions & 6 deletions core/src/components/item-option/item-option.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
// --------------------------------------------------

:host {
--ion-color-base: #{ion-color(primary, base)};
--ion-color-contrast: #{ion-color(primary, contrast)};

color: #{current-color(contrast)};
}

.item-option-native {
@include text-inherit();
@include padding(0, .7em);

width: 100%;
Expand All @@ -18,15 +22,13 @@
outline: none;

background: #{current-color(base)};
color: inherit;

font-family: inherit;
font-size: inherit;
font-weight: inherit;

letter-spacing: inherit;
cursor: pointer;
appearance: none;
}

.item-option-native:hover {
opacity: 0.8;
}

.item-option-button-inner {
Expand Down
1 change: 1 addition & 0 deletions core/src/components/item-options/item-options.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ ion-item-options {

font-size: 14px;

user-select: none;
z-index: $z-index-item-options;

&.hydrated {
Expand Down
4 changes: 4 additions & 0 deletions core/src/components/item-sliding/item-sliding.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ ion-item-sliding {
user-select: none;
}

ion-item-sliding .item {
user-select: none;
}

.item-sliding-active-slide .item {
position: relative;

Expand Down
6 changes: 3 additions & 3 deletions core/src/components/item-sliding/item-sliding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class ItemSliding {
el: this.el,
queue: this.queue,
gestureName: 'item-swipe',
gesturePriority: -10,
gesturePriority: 20,
threshold: 5,
canStart: this.canStart.bind(this),
onStart: this.onDragStart.bind(this),
Expand Down Expand Up @@ -152,7 +152,7 @@ export class ItemSliding {
this.closeOpened();
return false;
}
return true;
return !!(this.rightOptions || this.leftOptions);
}

private onDragStart() {
Expand Down Expand Up @@ -295,7 +295,7 @@ export class ItemSliding {
}

/** @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)
// depends on three booleans (isCloseDirection, isMovingFast, isOnCloseZone)
// and it ended up being too complicated to be written manually without errors
Expand Down
6 changes: 6 additions & 0 deletions core/src/components/item-sliding/test/basic/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@

<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>
<ion-button expand="block" onclick="toggleSliding()">Toggle sliding</ion-button>
<ion-button expand="block" onclick="toggleDynamicOptions()">Toggle Dynamic Options</ion-button>
Expand Down
3 changes: 3 additions & 0 deletions core/src/components/item/item.scss
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@

button, a {
cursor: pointer;
user-select: none;

-webkit-user-drag: none;
}

.item-state {
Expand Down
2 changes: 1 addition & 1 deletion core/src/components/menu/menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export class Menu {
el: this.doc,
queue: this.queue,
gestureName: 'menu-swipe',
gesturePriority: 10,
gesturePriority: 40,
threshold: 10,
canStart: this.canStart.bind(this),
onWillStart: this.onWillStart.bind(this),
Expand Down
2 changes: 1 addition & 1 deletion core/src/components/nav/nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export class Nav implements NavOutlet {
el: this.win.document.body,
queue: this.queue,
gestureName: 'goback-swipe',
gesturePriority: 10,
gesturePriority: 30,
threshold: 10,
canStart: this.canSwipeBack.bind(this),
onStart: this.swipeBackStart.bind(this),
Expand Down
2 changes: 1 addition & 1 deletion core/src/components/picker-column/picker-column.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class PickerColumnCmp {
el: this.el,
queue: this.queue,
gestureName: 'picker-swipe',
gesturePriority: 10,
gesturePriority: 100,
threshold: 0,
onStart: this.onDragStart.bind(this),
onMove: this.onDragMove.bind(this),
Expand Down
6 changes: 3 additions & 3 deletions core/src/components/range/range.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export class Range implements BaseInput {
el: this.rangeSlider!,
queue: this.queue,
gestureName: 'range',
gesturePriority: 30,
gesturePriority: 100,
threshold: 0,
onStart: this.onDragStart.bind(this),
onMove: this.onDragMove.bind(this),
Expand Down Expand Up @@ -391,7 +391,7 @@ export class Range implements BaseInput {
}
}

export function ratioToValue(
function ratioToValue(
ratio: number,
min: number,
max: number,
Expand All @@ -404,6 +404,6 @@ export function ratioToValue(
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);
}
5 changes: 4 additions & 1 deletion core/src/components/refresher/refresher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export class Refresher {
gestureName: 'refresher',
gesturePriority: 10,
direction: 'y',
threshold: 5,
threshold: 10,
passive: false,
canStart: this.canStart.bind(this),
onStart: this.onStart.bind(this),
Expand Down Expand Up @@ -175,6 +175,8 @@ export class Refresher {
}

private onStart() {
console.log('start');

this.progress = 0;
this.state = RefresherState.Inactive;
}
Expand Down Expand Up @@ -341,6 +343,7 @@ export class Refresher {

hostData() {
return {
slot: 'fixed',
class: {
...createThemedClasses(this.mode, 'refresher'),

Expand Down
2 changes: 1 addition & 1 deletion core/src/components/reorder-group/reorder-group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class ReorderGroup {
el: this.doc.body,
queue: this.queue,
gestureName: 'reorder',
gesturePriority: 30,
gesturePriority: 90,
disableScroll: true,
threshold: 0,
direction: 'y',
Expand Down
2 changes: 1 addition & 1 deletion core/src/components/toggle/toggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export class Toggle implements CheckboxInput {
el: this.el,
queue: this.queue,
gestureName: 'toggle',
gesturePriority: 30,
gesturePriority: 100,
threshold: 0,
onStart: this.onDragStart.bind(this),
onMove: this.onDragMove.bind(this),
Expand Down
6 changes: 2 additions & 4 deletions core/src/utils/gesture/gesture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,8 @@ export function createGesture(config: GestureConfig): Gesture {
// gesture is currently being detected
calcGestureData(detail, ev);
if (pan.detect(detail.currentX, detail.currentY)) {
if (pan.isGesture()) {
if (!tryToCapturePan()) {
abortGesture();
}
if (!pan.isGesture() || !tryToCapturePan()) {
abortGesture();
}
}
}
Expand Down

0 comments on commit a77ee2a

Please sign in to comment.