搜索插件、代码仓与 APP 分类

插件详情v1.1.4

bounce_tapper

流畅的点击弹跳(缩小/放大)动画,可轻松增强用户的触摸交互体验。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
156
喜欢数
32
Pub 分数
150

安装插件

flutter pub add bounce_tapper

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

BounceTapper 是一个 Flutter 包,为应用中的触摸交互添加流畅的点击弹跳动画——缩放和放大效果,以提升用户体验。它提供了一个易于使用的组件,能够对用户点击做出流畅自然的动画响应,增强反馈感和参与度。非常适合按钮、卡片或任何需要视觉响应性的交互元素。该包支持所有主要平台,包括 Android、iOS、Web、macOS、Windows 和 Linux,确保在各种设备上行为一致。通过 `flutter pub add bounce_tapper` 即可快速完成最小化设置,轻松将精致的触摸反馈集成到您的 UI 中。

适合场景

  • 增强按钮反馈
  • 改进卡片点击交互
  • 添加动态触摸响应
  • 创建引人入胜的用户界面元素
  • 支持跨平台动画

主要特点

  • 平滑收缩/增长动画
  • 轻松集成,代码量最少
  • 跨平台兼容性
  • 可自定义的动画速度
  • 内置触觉反馈
  • 轻量且高性能

适合对象

  • 寻求交互式反馈的UI设计师
  • 开发触控密集型界面的开发者
  • 需要响应式触摸元素的应用程序
  • 致力于打造精致微交互的项目
  • 面向多个平台的团队

使用建议

  • 可能需要调整以在低端设备上获得最佳性能
  • 动画行为可能需要根据特定的设计需求进行调整
  • 最好与简单、专注的触摸目标配合使用
  • 不太适合复杂的基于手势的交互
  • 超出基本弹跳参数的自定义功能有限

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Bounce Tapper

BounceTapper allows you to effortlessly apply smooth Bounce (Shrink/Grow) touch animations to your widgets. Beyond the basic Shrink/Grow animations, the package is infused with carefully optimized interaction behaviors. Major apps like the App Store, GitHub, and Slack have adopted similar touch interactions, and BounceTapper brings you refined interaction logic inspired by a thorough analysis of these leading applications.


Platform Pub Package License: MIT


Demo

Can apply exactly the same touch interactions as in the demo apps.


Key Features

  • 🔑 Extremely easy to use
  • 💻 Easily integrates with your existing widgets
  • 🛠 Highly customizable
  • 🔥 Various touch interaction logic carefully considered

Installing

To use the Easy BounceTapper package in your Flutter project, follow these steps:

  1. Depend on it

Add the following line to your project's pubspec.yaml file under the dependencies section:

dependencies:
  bounce_tapper: ^1.1.4
  1. Install it

Run the following command in your terminal or command prompt:

$ flutter pub get
  1. Import it

Add the following import statement to your Dart code:

import 'package:bounce_tapper/bounce_tapper.dart';

Usage

  1. It's incredibly simple. Just wrap the widget you want to apply the Shrink/Grow touch interaction to with BounceTapper.
BounceTapper(  
  onTap: () {},  
  child: Card(),  
)
BounceTapper(  
  child: YourCustomWidget()  
)
  1. Pass the necessary touch events to the onTap method. If you have an existing custom widget that handles touch events, you can skip passing an onTap event directly.
/// 1. Executes the touch event inside BounceTapper
BounceTapper(  
  onTap: () {
      /// Touch Event!
  },  
  child: CustomWidget(),  
)

/// 2. Listens to the child widget's touch event and executes it
BounceTapper(  
  child: CustomButton(), 
)

The onTap property is optional, so if your child widget handles touch events on its own, the Shrink/Grow animation will still be triggered even without passing a touch event to BounceTapper.


Features

BounceTapper not only offers Shrink/Grow touch animations but also provides various finely-tuned features.

1. Cancel ongoing interaction when scrolling

If you carefully observe the App Store's main page, you’ll notice that when a card view is touched and shrinks, scrolling will cancel the shrink and return the card to its original state without triggering the touch event.

BounceTapper works similarly by detecting scroll events from parent widgets and canceling the ongoing shrink animation, restoring the widget without triggering a touch event. If you prefer to keep the animation and event active even when scrolling, you can set the disableGrowOnScroll property to false.

Both vertical and horizontal scroll events are detected.

Parameter Default Description
disableBounceOnScroll true Whether to cancel ongoing animation during scroll

2. Customize Shrink/Grow animation

You can customize several aspects of the Shrink/Grow animation, such as the animation duration and the shrink size.

Although the default property values are set to feel quite natural, you can customize them if necessary.

Parameter Default Description
shrinkScaleFactor 0.965 The scale to which the widget shrinks
shrinkDuration Duration(milliseconds: 160) Duration of the shrinking animation
growDuration Duration(milliseconds: 120) Duration of the growing animation
delayedDurationBeforeGrow Duration(milliseconds: 60) Delay before growing to ensure a smooth animation
shrinkCurve Curves.easeInSine Curve used for the shrinking animation
growCurve Curves.easeOutSine Curve used for the growing animation
enable true Whether to enable touch animation and events

3. Highlight effect on touch

Just like InkWell or MaterialButton, BounceTapper also provides a highlight effect when the widget is touched, overlaying a color on the widget. You can customize the highlight color using the highlightColor property. If you don’t want any highlight effect, simply set it to Colors.transparent.

In some cases, using a widget like InkWell on a child widget with a borderRadius might cause the highlight to not clip properly, requiring you to wrap it in a ClipRRect widget.

However, BounceTapper automatically detects the nearest borderRadius from the child widget’s renderObject and clips the corners accordingly.

There are a few widgets for which renderObject cannot detect the borderRadius. In these cases, you can manually set the highlightBorderRadius to clip the highlight box with the correct radius.

BounceTapper does not interfere with the highlight touch effects of wrapped widgets like FilledButton or InkWell.

Parameter Default Description
highlightColor Color(0x1F939BAC) The color overlayed on touch
highlightBorderRadius null The borderRadius of the highlight box

4. Interaction with parent/child BounceTapper widgets

There may be cases where you need to apply another BounceTapper to a child widget within a parent BounceTapper. In such scenarios, separate touch events are triggered when the child widget is touched and when the parent widget (excluding the child) is touched. Shrink/Grow animations are applied only to the child when it is touched, while the entire parent (including the child) will shrink/grow when the parent is touched.


5. Support for various touch gestures

In addition to the onTap method, BounceTapper supports gestures like onLongPress and onLongPressUp. However, you can only assign either onTap or onLongPressUp, not both. Attempting to set both will result in an assertion error to prevent conflicting interactions.

Additionally, if you want to disable touch events and animations entirely, simply set the enable property to false.

Parameter Default Description
onTap null Method to be executed on tap
onLongPress null Method to be executed on long press
onLongPressUp null Method to be executed when long press is released
enable true Whether to enable touch animations and events

6. Prevent multiple and rapid touches

By default, the BounceTapper package prevents multiple rapid touches and simultaneous touches, ensuring that touch events aren’t triggered multiple times. If multiple BounceTapper widgets are touched at the same time, only the one that was touched first will trigger its animation and event.


7. Interaction when touch moves outside the touch area

If the widget is touched and shrinks, but the touch point moves outside the widget’s touch area, the ongoing animation will be canceled and the widget will grow back to its original size. And the touch event will not be triggered.

所属分类

源码仓库

使用此插件的项目

暂无相关数据。