fix(content): scrollToPoint reliability

fixes #15257
This commit is contained in:
Manu Mtz.-Almeida
2018-08-21 18:18:25 +02:00
parent c567a82bfc
commit e0f12598aa
4 changed files with 8 additions and 15 deletions

View File

@ -2107,7 +2107,7 @@ declare global {
* The text to display on the ok button. Default: `OK`.
*/
'okText': string;
'open': (ev?: UIEvent | undefined) => Promise<HTMLIonActionSheetElement> | Promise<HTMLIonAlertElement> | Promise<HTMLIonPopoverElement>;
'open': (ev?: UIEvent | undefined) => Promise<HTMLIonPopoverElement> | Promise<HTMLIonActionSheetElement> | Promise<HTMLIonAlertElement>;
/**
* The text to display when the select is empty.
*/

View File

@ -206,7 +206,7 @@ export class Content {
}
let resolve!: () => void;
let startTime: number;
let startTime = 0;
const promise = new Promise<void>(r => resolve = r);
const fromY = el.scrollTop;
const fromX = el.scrollLeft;
@ -216,11 +216,11 @@ export class Content {
// scroll loop
const step = (timeStamp: number) => {
let linearTime = Math.min(1, ((timeStamp - startTime) / duration));
const easedT = (--linearTime) * linearTime * linearTime + 1;
const linearTime = Math.min(1, ((timeStamp - startTime) / duration)) - 1;
const easedT = Math.pow(linearTime, 3) + 1;
if (deltaY !== 0) {
el.scrollTop = (easedT * deltaY) + fromY;
el.scrollTop = Math.floor((easedT * deltaY) + fromY);
}
if (deltaX !== 0) {
el.scrollLeft = Math.floor((easedT * deltaX) + fromX);
@ -233,14 +233,9 @@ export class Content {
requestAnimationFrame(step);
} else {
this.isScrolling = false;
resolve();
}
};
// start scroll loop
this.isScrolling = true;
// chill out for a frame first
requestAnimationFrame(ts => {
startTime = ts;
@ -353,7 +348,6 @@ function updateScrollDetail(
detail.startX = currentX;
detail.startY = currentY;
detail.velocityX = detail.velocityY = 0;
console.log('hhhhhh');
}
detail.timeStamp = timestamp;
detail.currentX = detail.scrollLeft = currentX;

View File

@ -16,9 +16,9 @@ The ripple effect component adds the [Material Design ink ripple interaction eff
## Methods
| Method | Description |
| ----------- | ------------------------------------------- |
| `addRipple` | Adds the ripple effect to the parent elment |
| Method | Description |
| ----------- | -------------------------------------------- |
| `addRipple` | Adds the ripple effect to the parent element |
----------------------------------------------

View File

@ -12,7 +12,6 @@
| Property | Attribute | Description | Type |
| -------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
| `color` | `color` | The color to use from your application's color palette. Default options are: `"primary"`, `"secondary"`, `"tertiary"`, `"success"`, `"warning"`, `"danger"`, `"light"`, `"medium"`, and `"dark"`. For more information on colors, see [theming](/docs/theming/basics). | `Color` |
| `mode` | `mode` | The mode determines which platform styles to use. Possible values are: `"ios"` or `"md"`. | `Mode` |
----------------------------------------------