1 Star 1 Fork 0

ezm-eric / image-transition-3d

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

image-transition-3d

介绍

主要用于将图片做瓦片处理, 并进行异步动画切换。

快速使用

安装依赖

npm install image-transition-3d --save

# or

yarn add image-transition-3d

注册组件到 Vue

import Vue from 'vue'
import ImageTransition3d from "image-transition-3d";

Vue.use(ImageTransition3d);

使用

<template>
    <div id="app">
        <div style="width: 800px;height: 480px;position:relative;">
            <image-transition-3d
                    v-model="imageIndex"
                    :images="images"
            />
        </div>
    </div>
</template>

<script>
    export default {
        name: 'App',
        components: {},
        data() {
            return {
                // 当前显示图片(数组下标)
                imageIndex: 0,
                // 图片 src 列表
                images: [
                    '/image/1.jpg',
                    '/image/2.jpg',
                    '/image/3.jpg',
                    '/image/4.jpg',
                ],
            };
        }
    }
</script>

参数列表

参数 类型 说明
images Array<String> 图片 src 连接列表
value Integer 当前显示的 src 列表下标
cols Integer 列数
rows Integer 行数
customTransitions Array<CustomTransition> 自定义动画列表
duration Integer 动画切换图片间隔 ( ms )
useTransitionNames Array<Object> 切换随机使用的动画名称

CustomTransition

参数 类型 说明
name Object 动画名称(全局唯一)
leaveStyle Function(index) 返回离开的样式的方法, index 为瓦片下标
enterStyle Function(index) 返回进入样式的开始位置样式
leaveDistributionTime Integer , Function(index) 瓦片动画开始随机延时范围
leaveDuration Integer, Function(index) 单个瓦片离开动画过度时间
enterDuration Integer, Function(index) 单个瓦片进入动画过度时间

使用指定动画配置

<template>
    <div id="app">
        <div style="width: 800px;height: 480px;position:relative;">
            <image-transition-3d
                    v-model="imageIndex"
                    :images="images"
                    :custom-transitions="customTransitions"
                    :use-transition-names="useTransitionNames"
            />
        </div>
    </div>
</template>

<script>
    export default {
        name: 'App',
        components: {},
        data() {
            return {
                imageIndex: 0,
                images: [
                    '/image/1.jpg',
                    '/image/2.jpg',
                    '/image/3.jpg',
                    '/image/4.jpg',
                ],
                // 自定义动画
                customTransitions: [
                    {
                        // 动画名称
                        name: "me",
                        // 离开动画 i : 第 i 个瓦片, 横着数
                        leaveStyle: function (i) {
                            return {
                                "opacity": 0,
                                "transform": "translateX(100px)"
                            }
                        },
                        // 入场动画
                        enterStyle: function (i) {
                            return {
                                "opacity": 0,
                                "transform": "translateX(-100px)"
                            }
                        },
                        // 异步离开的最大时间跨度 会随机一个时间开始单个瓦片动画
                        leaveDistributionTime: 1000,
                        // 离开动画过渡时间
                        leaveDuration: 1000,
                        // 入场动画过度时间
                        enterDuration: 1000,
                    }
                ],
                useTransitionNames: ['me']
            };
        }
    }
</script>

问题反馈

仓库

github: https://github.com/fangjc1986/image-transition-3d.git

MIT License Copyright (c) 2020 eric.fang Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

图片破碎过渡动画 展开 收起
JavaScript
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/ezm-eric/image-transition-3d.git
git@gitee.com:ezm-eric/image-transition-3d.git
ezm-eric
image-transition-3d
image-transition-3d
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891