Skip to content

Commit

Permalink
fix(picker): stop animation when it's closed
Browse files Browse the repository at this point in the history
fixes #15854
  • Loading branch information
manucorporat committed Oct 8, 2018
1 parent 8cb1886 commit e81af2d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
8 changes: 4 additions & 4 deletions core/src/components/checkbox/checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,19 @@ export class Checkbox implements ComponentInterface {
});
}

onChange() {
private onChange() {
this.checked = !this.checked;
}

onKeyUp() {
private onKeyUp() {
this.keyFocus = true;
}

onFocus() {
private onFocus() {
this.ionFocus.emit();
}

onBlur() {
private onBlur() {
this.keyFocus = false;
this.ionBlur.emit();
}
Expand Down
20 changes: 14 additions & 6 deletions core/src/components/picker-column/picker-column.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ export class PickerColumnCmp implements ComponentInterface {
}

async componentDidLoad() {
// get the scrollable element within the column
const colEl = this.optsEl!;

// get the height of one option
this.optHeight = (colEl.firstElementChild ? colEl.firstElementChild.clientHeight : 0);
const colEl = this.optsEl;
if (colEl) {
this.optHeight = (colEl.firstElementChild ? colEl.firstElementChild.clientHeight : 0);
}

this.refresh();

Expand All @@ -65,6 +65,10 @@ export class PickerColumnCmp implements ComponentInterface {
this.gesture.setDisabled(false);
}

componentDidUnload() {
cancelAnimationFrame(this.rafId);
}

private setSelected(selectedIndex: number, duration: number) {
// if there is a selected index, then figure out it's y position
// if there isn't a selected index, then just use the top y position
Expand All @@ -78,6 +82,10 @@ export class PickerColumnCmp implements ComponentInterface {
}

private update(y: number, duration: number, saveY: boolean) {
if (!this.optsEl) {
return;
}

// ensure we've got a good round number :)
let translateY = 0;
let translateZ = 0;
Expand All @@ -86,7 +94,7 @@ export class PickerColumnCmp implements ComponentInterface {
const durationStr = (duration === 0) ? null : duration + 'ms';
const scaleStr = `scale(${this.scaleFactor})`;

const children = this.optsEl!.children;
const children = this.optsEl.children;
for (let i = 0; i < children.length; i++) {
const button = children[i] as HTMLElement;
const opt = col.options[i];
Expand Down Expand Up @@ -282,7 +290,7 @@ export class PickerColumnCmp implements ComponentInterface {
}
}

const selectedIndex = clamp(min, this.col.selectedIndex!, max);
const selectedIndex = clamp(min, this.col.selectedIndex || 0, max);
if (this.col.prevSelected !== selectedIndex) {
const y = (selectedIndex * this.optHeight) * -1;
this.velocity = 0;
Expand Down
10 changes: 5 additions & 5 deletions core/src/components/radio/radio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,24 +146,24 @@ export class Radio implements ComponentInterface {
});
}

onClick() {
private onClick() {
this.checkedChanged(true);
}

onChange() {
private onChange() {
this.checked = true;
this.nativeInput.focus();
}

onKeyUp() {
private onKeyUp() {
this.keyFocus = true;
}

onFocus() {
private onFocus() {
this.ionFocus.emit();
}

onBlur() {
private onBlur() {
this.keyFocus = false;
this.ionBlur.emit();
}
Expand Down

0 comments on commit e81af2d

Please sign in to comment.