Giter VIP home page Giter VIP logo

piu_animation's Introduction

类似加入购物车动画【PiuAnimation】

PiuAnimation,piu~~~的一下,可用作加入购物车、保存截屏等动画特效

Look

MacDown Screenshot

无用功能第一弹:

悬停动画一【异步任务返回true】:

MacDown Screenshot

悬停动画二【异步任务返回false】:

MacDown Screenshot

添加方法【第一种,普通的缩放piu动画】

PiuAnimation.addAnimation(
        rootKey,   //主Widget GlobalKey
        piuWidget, //Child
        endOffset, //终点坐标
        maxWidth:MediaQuery.of(context).size.width, //Child最大宽度
        doSomethingBeginCallBack:(){ //动画开始回调
            print("动画开始");
        },
        doSomethingFinishCallBack:(){ //动画结束回调
            print("动画结束");
        });
//其中还有动画时长、悬停最小宽度等属性设置

添加方法【第二种,悬停loading动画】

PiuAnimation.addAnimation(rootKey,piuWidget,endOffset,
        maxWidth:MediaQuery.of(context).size.width,
        loadingCallback:loadingCallBack,
        doSomethingBeginCallBack:(){
            print("动画开始");
        },doSomethingFinishCallBack:(success){
            if(success){
                print("loading 成功 动画结束");
            }else{
                print("loading 失败 动画结束");
            }
        });

//异步方法定义,demo先通过delayed使用,正常业务逻辑中可以通过接口回调控制true和false
        //任务成功
        Future<bool> loadingSuccessFunction() {
            return Future.delayed(const Duration(milliseconds: 2000),(){
                return true;
            });
        }

        //任务失败
        Future<bool> loadingFieldFunction() {
            return Future.delayed(const Duration(milliseconds: 2000),(){
                return false;
            });
        }

使用方式详见main.dart

//通过GlobalKey获取终点坐标,及大小等
//demo终点坐标为按钮的中心点
RenderBox box = key.currentContext!.findRenderObject() as RenderBox;
    var offset = box.localToGlobal(Offset.zero);
    Offset endOffset =
        Offset(offset.dx + box.size.width / 2, offset.dy + box.size.height / 2);

GitHub地址: GitHub

piu_animation's People

Contributors

metrolh avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.