mirror of
https://github.com/Iconica-Development/flutter_carousel.git
synced 2025-05-19 04:13:43 +02:00
Merge pull request #2 from Iconica-Development/feature/add-opacity-transition
feat: add opacity to card transition
This commit is contained in:
commit
fd1fafe5b1
5 changed files with 58 additions and 10 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
## 0.1.0
|
||||||
|
|
||||||
|
* add opacity as an option to the card transform
|
||||||
|
|
||||||
## 0.0.1
|
## 0.0.1
|
||||||
|
|
||||||
* TODO: Describe initial release.
|
* TODO: Describe initial release.
|
||||||
|
|
|
@ -60,16 +60,47 @@ class _CarouselExampleAppState extends State<CarouselExampleApp> {
|
||||||
onCardClick: _onClick,
|
onCardClick: _onClick,
|
||||||
transforms: [
|
transforms: [
|
||||||
CardTransform(
|
CardTransform(
|
||||||
x: 220, y: -85, angle: -math.pi / 12, scale: 0.3),
|
x: 220,
|
||||||
|
y: -85,
|
||||||
|
angle: -math.pi / 12,
|
||||||
|
scale: 0.3,
|
||||||
|
opacity: 0.2,
|
||||||
|
),
|
||||||
CardTransform(
|
CardTransform(
|
||||||
x: 230, y: -80, angle: math.pi / 12, scale: 0.5),
|
x: 230,
|
||||||
|
y: -80,
|
||||||
|
angle: math.pi / 12,
|
||||||
|
scale: 0.5,
|
||||||
|
opacity: 0.4,
|
||||||
|
),
|
||||||
CardTransform(
|
CardTransform(
|
||||||
x: 200, y: -75, angle: -math.pi / 12, scale: 0.6),
|
x: 200,
|
||||||
|
y: -75,
|
||||||
|
angle: -math.pi / 12,
|
||||||
|
scale: 0.6,
|
||||||
|
opacity: 0.6,
|
||||||
|
),
|
||||||
CardTransform(
|
CardTransform(
|
||||||
x: 110, y: -60, angle: math.pi / 12, scale: 0.7),
|
x: 110,
|
||||||
CardTransform(x: 0, y: 0, angle: 0, scale: 1),
|
y: -60,
|
||||||
|
angle: math.pi / 12,
|
||||||
|
scale: 0.7,
|
||||||
|
opacity: 0.8,
|
||||||
|
),
|
||||||
CardTransform(
|
CardTransform(
|
||||||
x: -270, y: 70, angle: -math.pi / 50, scale: 1),
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
angle: 0,
|
||||||
|
scale: 1,
|
||||||
|
opacity: 1.0,
|
||||||
|
),
|
||||||
|
CardTransform(
|
||||||
|
x: -270,
|
||||||
|
y: 70,
|
||||||
|
angle: -math.pi / 50,
|
||||||
|
scale: 1,
|
||||||
|
opacity: 0.5,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
builder: _buildCard,
|
builder: _buildCard,
|
||||||
),
|
),
|
||||||
|
|
|
@ -5,11 +5,21 @@ class CardTransform {
|
||||||
this.y = 0,
|
this.y = 0,
|
||||||
this.angle = 0,
|
this.angle = 0,
|
||||||
this.scale = 1,
|
this.scale = 1,
|
||||||
});
|
this.opacity = 1.0,
|
||||||
|
}) : assert(
|
||||||
|
opacity >= 0,
|
||||||
|
'Opacity cannot be negative',
|
||||||
|
),
|
||||||
|
assert(
|
||||||
|
opacity <= 1.0,
|
||||||
|
'Opacity needs to be between 0.0 and 1.0',
|
||||||
|
);
|
||||||
|
|
||||||
double x;
|
double x;
|
||||||
double y;
|
double y;
|
||||||
double angle;
|
double angle;
|
||||||
double scale;
|
double scale;
|
||||||
|
double opacity;
|
||||||
|
|
||||||
/// [transitionPos] is a position value of a swipe for example.
|
/// [transitionPos] is a position value of a swipe for example.
|
||||||
/// [other] is the position, scale, rotation
|
/// [other] is the position, scale, rotation
|
||||||
|
@ -20,6 +30,7 @@ class CardTransform {
|
||||||
y: _transformValue(y, other.y, transitionPos),
|
y: _transformValue(y, other.y, transitionPos),
|
||||||
angle: _transformValue(angle, other.angle, transitionPos),
|
angle: _transformValue(angle, other.angle, transitionPos),
|
||||||
scale: _transformValue(scale, other.scale, transitionPos),
|
scale: _transformValue(scale, other.scale, transitionPos),
|
||||||
|
opacity: _transformValue(opacity, other.opacity, transitionPos),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,10 @@ class CarouselCard extends StatelessWidget {
|
||||||
angle: cardTransform.angle,
|
angle: cardTransform.angle,
|
||||||
child: Transform.scale(
|
child: Transform.scale(
|
||||||
scale: cardTransform.scale,
|
scale: cardTransform.scale,
|
||||||
child: child,
|
child: Opacity(
|
||||||
|
opacity: cardTransform.opacity,
|
||||||
|
child: child,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
name: carousel
|
name: carousel
|
||||||
description: card carousel
|
description: card carousel
|
||||||
version: 0.0.1
|
version: 0.1.0
|
||||||
homepage:
|
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.17.6 <3.0.0"
|
sdk: ">=2.17.6 <3.0.0"
|
||||||
|
|
Loading…
Reference in a new issue