Git Product home page Git Product logo

gonnavis / vue-animation-timeline Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wx-dongxing/vue-animation-timeline

0.0 0.0 0.0 9.94 MB

A visual element animation configuration editor based on timeline,compatible with vue2.x and vue3

Home Page: https://wx-dongxing.github.io/vue-animation-timeline/

License: MIT License

JavaScript 2.93% HTML 0.97% Vue 74.61% TypeScript 20.99% Shell 0.50%

vue-animation-timeline's Introduction

Vue Animation Timeline

A visual element animation configuration editor based on timeline。

github npm support jetBrains

preview

English | 简体中文

✨ Features

  • 🚀 Visual element animation configuration based on timeline
  • 💫 Support CSS Transform animation Properties
  • ✅ Compatible with vue2.x and vue3

📦 Install

vue2.x
yarn add vue-animation-timeline
vue3
yarn add vue-animation-timeline@next

🧐 Usage

vue2.x
import Vue from 'vue';
import VueAnimationTimeline from 'vue-animation-timeline';

Vue.use(VueAnimationTimeline)
vue3
import { createApp } from 'vue';
import VueAnimationTimeline from 'vue-animation-timeline';

const app = createApp({});

app.use(VueAnimationTimeline);

app.mount('#app');

💡 Example

<template>
  <main>
    <section class="widgets">
      <div
          class="widget"
          v-for="widget in widgets"
          :key="widget.id"
          v-animation="widget"
      >
        {{ widget.name }}
      </div>
    </section>
    
    <animation-timeline :widgets="widgets" :fields="fields" @onUpdate="handleUpdate" />
  </main>
</template>
<script>
import { defineComponent, ref, reactive } from 'vue'

export default defineComponent({
  // vue2.x
  data () {
    return {
      widgets: [
        { id: 1, name: 'A', y: 32, x: 72, width: 84, height: 84 },
      ],
      fields: {
        name: 'name',
        width: 'width',
        height: 'height',
        top: 'y',
        left: 'x',
      }
    }
  },
  methods: {
    handleUpdate(widgets) {
      this.widgets = widgets;
    },
  },
  // vue3
  setup() {
    const widgets = ref([
      { id: 1, name: 'A', y: 32, x: 72, width: 84, height: 84 },
    ]);

    const fields = reactive({
      name: 'name',
      width: 'width',
      height: 'height',
      top: 'y',
      left: 'x',
    });
    
    const handleUpdate = (widgets) => {
      widgets.value = widgets;
    };
    
    return {
      widgets,
      fields,
      handleUpdate,
    }
  },
})
</script>
<style scoped>
.widgets {
  position: relative;
}

.widget {
  position: absolute;
}
</style>

🔧 Config

Properties

widgets: Element arrays
fields: Field mapping
Properties Description
key Unique identifier
name Name field mapping,default 'name'
width Width field mapping,default 'width'
height Width field mapping,default 'width'
top Absolute positioning top field mapping,default 'top'
left Absolute positioning left field mapping,default 'left'

Instance Properties

$animate: animate instance
Function Description
play Execute animation
pause Pause animation
restart Restart animation
seek Execute animation to a given time,example animate.seek(1000): execute animation to 1s

Shortcut Key

Key Description
space Play And Pause
⌘ + backspace Back
⌘ + enter Restart
Decrease 20ms
Increase 20ms
control + shift + ← Jump To Previous Anchor
control + shift + → Jump To Next Anchor

Event

onUpdate: Update current widget configs
onSelect: Select current widget

License

MIT

Copyright (c) 2021 Dong Xing

vue-animation-timeline's People

Contributors

wx-dongxing 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.