vue.js 组件交互_使用Vue.js创建交互式动画

本文介绍了如何使用Vue.js组件vue-kinesis来创建交互式动画。内容包括vue-kinesis的安装、默认导入、浏览器支持、组件用法、属性详细说明以及从vue-mouse-parallax迁移的方法。
摘要由CSDN通过智能技术生成

vue.js 组件交互

视觉运动 (vue-kinesis)

Easy to use Vue.js components for creating interactive animations.

易于使用的Vue.js组件可用于创建交互式动画。

安装 (Installation)

npm install --save vue-kinesis

默认导入 (Default import)

Install all the components:

安装所有组件:

import Vue from 'vue'
import VueKinesis from 'vue-kinesis'

Vue.use(VueKinesis)

Use specific components:

使用特定的组件:

import Vue from 'vue'
import { KinesisContainer, KinesisElement } from 'vue-kinesis'

Vue.component('kinesis-container', KinesisContainer)
Vue.component('kinesis-element', KinesisElement)

浏览器 (Browser)

<script src="vue.js"></script>
<script src="vue-kinesis.min.js"></script>

用法 (Usage)

How to use

如何使用

道具 (Props)

运动容器 (kinesis-container)

PropTypeDefault ValueDescription
activeBooleantrueTo enable or disable the interactions
durationNumber1000Speed of the parallax animation in ms
easingString"cubic-bezier(0.23, 1, 0.32, 1)"Easing of the parallax animation
tagStringdivTakes any valid html tag
eventString"move"Event to which the container will react. Possible values are "move" and "scroll"
perspectiveNumber1000Effective for the 'depth' parallax type
audioStringPath towards an audio file
playAudioBooleanStart/Stop the attached audio file
Struts 类型 默认值 描述
活性 布尔型 真正 启用或禁用交互
持续时间 1000 视差动画的速度(毫秒)
缓和 “立方贝塞尔曲线(0.23,1,0.32,1)” 视差动画的缓和
标签 div 接受任何有效的html标签
事件 “移动” 容器将对其作出React的事件。 可能的值为“ move”和“ scroll”
透视 1000 对“深度”视差类型有效
音讯 音频文件的路径
playAudio 布尔型 开始/停止附加的音频文件

运动学元素 (kinesis-element)

PropTypeDefault ValueDescription
strengthNumber10Strength of the motion effect
typeString"translate"translate - rotate - scale - scaleX - scaleY - depth - depth_inv
tagString"div"Takes any valid html tag
transformOriginString"center"Similar to the CSS transform-origin property
originXNumber50The motion's origin relative to the container, on the X axis. 50 being the center of the container, 0 the left side, 100 the right side.
originYNumber50The motion's origin relative to the container, on the Y axis. 50 being the center of the container, 0 the top side, 100 the bottom side.
axisStringnullConstrain the movement to one axis. Possible values: "x" - "y"
maxXNumbernullLimit the maximum range of the movement on the X axis
maxYNumbernullLimit the maximum range of the movement on the Y axis
minXNumbernullLimit the minimum range of the movement on the X axis
minYNumbernullLimit the minimum range of the movement on the Y axis
cycleNumber0How many times the movement will repeat
Struts 类型 默认值 描述
强度 10 运动效果的强度
类型 “翻译” 平移-旋转-缩放-scaleX-scaleY-深度-depth_inv
标签 “ div” 接受任何有效的html标签
transformOrigin “中央” 类似于CSS transform-origin属性
OriginX 50 X轴上相对于容器的运动原点。 50是容器的中心,0是左侧,100是右侧。
起源 50 动作的原点相对于容器,在Y轴上。 50是容器的中心,0是顶部,100是底部。
空值 将运动限制在一个轴上。 可能的值:“ x”-“ y”
最大X 空值 限制X轴上最大移动范围
最大 空值 限制Y轴上的最大移动范围
minX 空值 限制X轴上移动的最小范围
最小 空值 限制Y轴上运动的最小范围
周期 0 运动将重复多少次

运动音频 (kinesis-audio)

PropTypeDefault ValueDescription
audioIndexNumber50To which frequency to react, on a range of integer values that goes from 0 to 127.
strengthNumber10Strength of the motion effect
typeString"translate"translate - rotate - scale - scaleX - scaleY - depth - depth_inv
tagString"div"Takes any valid html tag
transformOriginString"center"Similar to the CSS transform-origin property
originXNumber50The motion's origin relative to the container, on the X axis. 50 being the center of the container, 0 the left side, 100 the right side.
originYNumber50The motion's origin relative to the container, on the Y axis. 50 being the center of the container, 0 the top side, 100 the bottom side.
axisStringnullConstrain the movement to one axis. Possible values: "x" - "y"
maxXNumbernullLimit the maximum range of the movement on the X axis
maxYNumbernullLimit the maximum range of the movement on the Y axis
minXNumbernullLimit the minimum range of the movement on the X axis
minYNumbernullLimit the minimum range of the movement on the Y axis
cycleNumber0How many times the movement will repeat
Struts 类型 默认值 描述
audioIndex 50 从0到127的整数值范围内的React频率。
强度 10 运动效果的强度
类型 “翻译” 平移-旋转-缩放-scaleX-scaleY-深度-depth_inv
标签 “ div” 接受任何有效的html标签
transformOrigin “中央” 类似于CSS transform-origin属性
OriginX 50 X轴上相对于容器的运动原点。 50是容器的中心,0是左侧,100是右侧。
起源 50 动作的原点相对于容器,在Y轴上。 50是容器的中心,0是顶部,100是底部。
空值 将运动限制在一个轴上。 可能的值:“ x”-“ y”
最大X 空值 限制X轴上最大移动范围
最大 空值 限制Y轴上的最大移动范围
minX 空值 限制X轴上移动的最小范围
最小 空值 限制Y轴上运动的最小范围
周期 0 运动将重复多少次

从Vue-Mouse-Parallax迁移 (Migrating from vue-mouse-parallax)

Migration from vue-mouse-parallax is quite easy:

从vue-mouse-parallax迁移非常容易:

组件 (Components)

  • parallax-container -> kinesis-container

    视差容器->运动容器

  • parallax-element -> kinesis-element

    视差元素->运动学元素

道具 (Props)

  • parallaxStrength -> strength

    视差强度->强度

  • animationDuration -> duration

    animationDuration->持续时间

支撑值 (Prop values)

  • translation -> translate

    翻译->翻译

  • rotation -> rotate

    旋转->旋转

翻译自: https://vuejsexamples.com/create-interactive-animations-with-vue-js/

vue.js 组件交互

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值