Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

enter-animation

Package Overview
Dependencies
Maintainers
2
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

enter-animation

进场动画js

  • 0.5.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

##EnterAnimation进场动画

NPM version build status Test coverage gemnasium deps node version npm download

Feature

  • support ie10+,chrome,firefox,safari

install

enter-animation

用法


var EnterAnimation = require('enter-animation');
var React = require('react');
React.render(<EnterAnimation type={"left"}>
<div>anim1</div>
<div>anim2</div>
<div>anim3</div>
</EnterAnimation>, container);

注:<EnterAnimation></EnterAnimation>自动转换为div,所以你有什么样式都可以在上面添加;

api

动画默认right

EnterAnimation标签下:

参数类型详细
enterobject管理进场数据
leaveobject管理当前元素出场的数据,默认null,null继承上面所有标签的值
componentstringEnterAnimation替换的标签名

enter={} or leave={}

参数类型详细
typestring执行动画的内置参数,默认;right
styleobject/string同上,style的样式动画,type有值,此项无效, 默认null
durationnumber每个动画的时间;默认0.5
delaynumber整个区块的延时,默认为0;
同startAnimation的delay
reverseboolean是否倒放,从最后一个dom开始往上播放,默认false
easestring样式缓动;默认 cubic-bezier(0.165, 0.84, 0.44, 1);
intervalnumber递增延时值,默认0.1
callbackfunction动画完成后回调

子dom标签下:

一级标签key:

参数类型详细
keystring必需,控制进出场;

二级标签或再下级标签:

参数类型详细
enter-dataobject如下data值;
data-enterJSON.string因router下enter-data无效,所以新增dom标签,router时可用,如下data值;
leave-dataobject如上,如果为null,则继承enter-data和data-enter的所有参数
data-leaveJSON String如上

注:如子节点有enter-data值,则只执行有enter-data的节点的动画; 如果标签上的enter-datatype||style,则执行EnterAnimation标签上的type||style;

##startAnimation的动画参数(EnterAnimation.to);

页面进场动画的类,通过CSS来快速完成页面刷新后的动画进场或子块的动画进场;

用法


//js触发式:
var EnterAnimation=requre('enter-animation');
EnterAnimation.to(node,vars);

参数说明

参数类型详细
nodestring要执行动画的dom(class,id);必要;
varsobject动画参数
vars参数
参数类型详细
direction"enter"动画进场或出场样式,以enter``leave两值;默认为"enter"
datastring / object执行动画的参数,有object和string两种类型,下面详解;默认为null
duration0.5动画的时间;
delaynumber整个区块的延时,默认为0;
同startAnimation的delay
easecubic-bezier(0.165, 0.84, 0.44, 1);样式缓动;
interval递增延时值。默认0.1
hideenboolean在开始动画前隐藏掉html,默认为true;
reverseboolean是否倒放,从最后一个dom开始往上播放,默认false
onCompletefunction动画完成后回调

####data参数(string|object);

data={}
参数类型详细
enterobject进场的样式
leaveobject出场样式
directionstring动画进场或出场样式,以enter``leave两值;默认为"enter",有值覆盖vars参数的direction
enter={} or leave={}
参数类型详细
typestring内置动画样式:
left right top bottom scale scaleFrom scaleX scaleY;
styleobject / stringstyle样式,如transform: translateX(100px),每个样式必须以;结束;type有值此项无效
durationvars参数的duration动画的时间;有值覆盖vars参数的duration
easevars参数的ease样式缓动;有值覆盖vars参数的ease
delay0动画的延时;默认0,依照结构递增以上的interval
queueId0动画的线程,可为多线程

支持style直接添加动画;

为string时,自动遍历node下的子节点来执行data样式;

为object时,树状形dom结构,以({})为一档标签; 如:

<div class="a">
<div class="b"></div>
<div class="c"></div>
</div>

node用的是".a",做b,c的动画,那data为:{}为最外层div;

{////外层div
children:[//子下的两div
{type:"left"},
{type:"left"}
]
}

如果元素为多个时:

<div class="a">
<ul>
<li><span></span></li>
<li><span></span></li>
<li><span></span></li>
</ul>
</div>

处理每个li里的span的动画时,data为:


[
{type:'left'},
{type:'left'},
{type:'left'}
]
router使用方法

var key = this.props.location.pathname;
<EnterAnimation>
{cloneElement(this.props.children || <div/>, {key: key})}//
</EnterAnimation>

Keywords

FAQs

Package last updated on 15 Sep 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc