搜尋套件、儲存庫與 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.

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。