Bounce 包提供了一个 Flutter 小部件,当被触摸时,其子组件会添加平滑的缩放和旋转动画。它通过动态响应触摸输入来增强用户交互,创造出一种活泼且引人入胜的反馈效果。适用于按钮、卡片或任何交互元素,可在 Android、iOS、Web、macOS、Windows 和 Linux 等所有主要平台上使用。该动画流畅且可自定义,设置简单。特别有助于提升数字界面的触觉体验。
适合场景
交互式按钮
卡片的触摸反馈
游戏化用户界面元素
移动应用微交互
Web 界面增强功能
主要特点
平滑缩放和旋转动画
基于触摸的触发
跨平台支持
最小配置
对触摸位置敏感
适合对象
寻求互动反馈的应用开发者
设计师通过动态效果提升用户体验
需要轻量级动画的项目
Flutter 初学者探索手势
触摸操作密集型应用
使用建议
可能不适合极简设计风格
复杂布局上的性能影响
除了缩放和旋转外,自定义功能有限
建议谨慎使用,以避免分散注意力
需要处理手势检测
原始 README
以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。
Bounce
This package adds a new Bounce widget that applies a tap-triggered bounce animation to Flutter widgets. Depending on the touch location, a tilt effect is also added on the child.
To see examples of the following effect on a device or simulator:
cd example/
flutter run --release
How to use
First, add the dependency to your pubspec.yaml file:
dependencies:bounce:^<latest-version>
Then, wrap your target widget as child of a Bounce widget. You may optionally specify additional behavior, such as disabling the tilt effect by adding tilt: false to the constructor. The simplest usage of this widget is the following :
You may specify the maximum angle applied by the tilt effect using the tiltAngle. This angle will be reached when the child widget is tapped at its edges. No tilt is applied when the child is tapped exactly at its center.
Scale effect
You may specify the maximum factor applied by the scale effect using the scaleFactor parameter.
Tap delay
To fine tune your user experience, you may want the various effects to animate back for a few milliseconds after the tap has occured. By default, this delay is set to 150 milliseconds.
Filter quality
The Bounce widget implementation wraps the child with a matrix-based Transform widget. On most platforms, it is a good practice to have it set to FilterQuality.high, which is the default value. You may specify other FilterQuality values directly from the widget's constructor :