ListVisualisation.carousel constructor
Displays items in an SnappyListView like a carousel.
The intensity of depth perception can be configured with scalePerUnit
and the perception of rotation with wheelPixelRadius
(radius of the
3d carousel)
Implementation
ListVisualisation.carousel({
double scalePerUnit = 400,
double wheelPixelRadius = 400,
}) : _parameters = ((item) {
double scale = 1;
double sizeChange = 0;
if (item.isInBuilderSizes) {
final degrees = 360 /
((2 * pi * wheelPixelRadius) / item.distanceToCurrentPage!);
final depth =
wheelPixelRadius - cos(degrees * (pi / 180)) * wheelPixelRadius;
scale = (1 - depth / scalePerUnit).clamp(0, 1);
sizeChange = (1 - scale) * item.orthogonalScrollDirectionSize;
}
return ListVisualisationParameters(
transform: Matrix4Transform()
.scale(scale)
.translate(
x: item.axis == Axis.vertical ? sizeChange / 2 : 0,
y: item.axis == Axis.horizontal ? sizeChange / 2 : 0,
)
.matrix4,
curve: Curves.linear,
duration: const Duration(milliseconds: 0),
);
});