refactor(logic): simplify some operations
This commit is contained in:
parent
c912e00c07
commit
ed0206f06e
|
|
@ -266,9 +266,8 @@ class _CardSwiperState extends State<CardSwiper>
|
|||
|
||||
void _calculateAngle() {
|
||||
if (_angle <= _maxAngle && _angle >= -_maxAngle) {
|
||||
_tapOnTop
|
||||
? _angle = (_maxAngle / 100) * (_left / 10)
|
||||
: _angle = (_maxAngle / 100) * (_left / 10) * -1;
|
||||
_angle = (_maxAngle / 100) * (_left / 10);
|
||||
if (_tapOnTop) _angle *= -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -325,11 +324,8 @@ class _CardSwiperState extends State<CardSwiper>
|
|||
void _swipeHorizontal(BuildContext context) {
|
||||
_leftAnimation = Tween<double>(
|
||||
begin: _left,
|
||||
end: (_left == 0)
|
||||
? (widget.direction == CardSwiperDirection.right)
|
||||
? MediaQuery.of(context).size.width
|
||||
: -MediaQuery.of(context).size.width
|
||||
: (_left > widget.threshold)
|
||||
end: (_left == 0 && widget.direction == CardSwiperDirection.right) ||
|
||||
_left > widget.threshold
|
||||
? MediaQuery.of(context).size.width
|
||||
: -MediaQuery.of(context).size.width,
|
||||
).animate(_animationController);
|
||||
|
|
@ -363,11 +359,8 @@ class _CardSwiperState extends State<CardSwiper>
|
|||
).animate(_animationController);
|
||||
_topAnimation = Tween<double>(
|
||||
begin: _top,
|
||||
end: (_top == 0)
|
||||
? (widget.direction == CardSwiperDirection.bottom)
|
||||
? MediaQuery.of(context).size.height
|
||||
: -MediaQuery.of(context).size.height
|
||||
: (_top > widget.threshold)
|
||||
end: (_top == 0 && widget.direction == CardSwiperDirection.bottom) ||
|
||||
_top > widget.threshold
|
||||
? MediaQuery.of(context).size.height
|
||||
: -MediaQuery.of(context).size.height,
|
||||
).animate(_animationController);
|
||||
|
|
|
|||
Loading…
Reference in New Issue