forked from ustbhuangyi/better-scroll
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ustbhuangyi#1116 from ustbhuangyi/fix-ios-blink
Fix ios blink
- Loading branch information
Showing
6 changed files
with
74 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { Direction } from '@better-scroll/shared-utils' | ||
import { TranslaterPoint } from '../translater' | ||
|
||
type Position = { | ||
x: number | ||
y: number | ||
} | ||
// iOS 13.6 - 14.x, window.getComputedStyle sometimes will get wrong transform value | ||
// when bs use transition mode | ||
// eg: translateY -100px -> -200px, when the last frame which is about to scroll to -200px | ||
// window.getComputedStyle(this.content) will calculate transformY to be -100px(startPoint) | ||
// it is weird | ||
// so we should validate position caculated by 'window.getComputedStyle' | ||
export const isValidPostion = ( | ||
startPoint: TranslaterPoint, | ||
endPoint: TranslaterPoint, | ||
currentPos: Position, | ||
prePos: Position | ||
) => { | ||
const computeDirection = (endValue: number, startValue: number) => { | ||
const delta = endValue - startValue | ||
const direction = | ||
delta > 0 | ||
? Direction.Negative | ||
: delta < 0 | ||
? Direction.Positive | ||
: Direction.Default | ||
return direction | ||
} | ||
const directionX = computeDirection(endPoint.x, startPoint.x) | ||
const directionY = computeDirection(endPoint.y, startPoint.y) | ||
const deltaX = currentPos.x - prePos.x | ||
const deltaY = currentPos.y - prePos.y | ||
|
||
return directionX * deltaX <= 0 && directionY * deltaY <= 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters