Coder Social home page Coder Social logo

karas-frame-animate's Introduction

karas-frame-animate

FrameAnimate component for karas.


karas帧动画组件。

NPM version

Install

npm install karas
npm install karas-frame-animate

Usage

import FrameAnimate from 'karas-frame-animate';

karas.render(
  <canvas width="720" height="720">
    <FrameAnimate style={{
                    position: 'absolute',
                    left: '50%',
                    top: '50%',
                    width: 200,
                    height: 200,
                    translateX: '-50%',
                    translateY: '-50%',
                  }}
                  list={[{
                    url: 'https://gw-office.alipayobjects.com/a/g/wealthprod/Karas/demo/7y/body.png', // 帧动画图片
                    row: 1, // 图片有几行
                    column: 9, // 图片有几列
                    number: 9, // 总帧数,默认${row} * ${column},特殊情况下如多行最后一行数量不满传入自定义总数 
                  }]}
                  duration={500} // 整体动画时长
                  direction={'normal'} // 动画轮播方向,默认normal正向结束后从头开始,alternate会在正向结束后反向
                  playbackRate={1} // 播放速率
                  autoPlay={true} // 自动播放
    />
  </canvas>
);

method

  • pause() 暂停
  • resume() 恢复
  • play() 从头播放
  • stop() 停止并回到第一帧
  • pauseTo(n) 暂停到多少ms
  • pauseToFrame(n) 暂停到第n帧

get/set

  • duration 播放时长,单位ms,默认1000
  • playbackRate 播放速率,默认1
  • direction 播放方向,传alternate为来回反复
  • iterations 播放次数,超过次数停止,默认Infinity
  • fill 动画开始前结束后是否停留,默认both,可选forwardsbackwardsnone

event

  • frame 每次刷新后触发

License

[MIT License]

karas-frame-animate's People

Contributors

army8735 avatar

Watchers

 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.