0.3.0 • Published 3 years ago

vue-animation-timeline v0.3.0

Weekly downloads
41
License
MIT
Repository
github
Last release
3 years ago

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
PropertiesDescription
keyUnique identifier
nameName field mapping,default 'name'
widthWidth field mapping,default 'width'
heightWidth field mapping,default 'width'
topAbsolute positioning top field mapping,default 'top'
leftAbsolute positioning left field mapping,default 'left'

Instance Properties

animate: animate instance
FunctionDescription
playExecute animation
pausePause animation
restartRestart animation
seekExecute animation to a given time,example animate.seek(1000): execute animation to 1s

Event

onUpdate: Update widgets configs,The parameter is the widgets array to which the animation configuration has been added

License

MIT

Copyright (c) 2021 Dong Xing

0.3.0

3 years ago

0.2.5

3 years ago

0.2.4

3 years ago

0.2.3

3 years ago

3.0.2

3 years ago

0.2.2

3 years ago

3.0.1

3 years ago

0.1.10

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

3.0.0

3 years ago

0.1.9

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago