Skip to content

Commit 750bd27

Browse files
author
tangyueyang
committed
Fix swipper横向滚动导致渐变bug
1 parent 4f7523d commit 750bd27

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

lib/pages/item_info/index.dart

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,18 @@ class _ItemInfoState extends State<ItemInfo> with TickerProviderStateMixin {
4545
children: <Widget>[
4646
NotificationListener<ScrollNotification>(
4747
onNotification: (ScrollNotification notification) {
48-
var scrollY = notification.metrics.pixels;
49-
if (scrollY > 0) {
50-
var opacity = scrollY / 230;
51-
setState(() {
52-
appBarOpacity = opacity <= 1 ? opacity : 1;
53-
});
54-
} else if (scrollY < 0) {
55-
setState(() {
56-
appBarOpacity = 0;
57-
});
48+
if (notification.metrics.axis == Axis.vertical) {
49+
var scrollY = notification.metrics.pixels;
50+
if (scrollY > 0) {
51+
var opacity = scrollY / 230;
52+
setState(() {
53+
appBarOpacity = opacity <= 1 ? opacity : 1;
54+
});
55+
} else if (scrollY < 0) {
56+
setState(() {
57+
appBarOpacity = 0;
58+
});
59+
}
5860
}
5961
return false;
6062
},

0 commit comments

Comments
 (0)