Comments (4)
Hi, I don't know how Vue 3 works. But I guess you need to access the DOM element you want to manipulate
from vivus.
<template>
<svg
id="animate-icon-dlavro"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 368.5 66.62"
>
<g data-name="Camada 2">
<g
id="Camada_1-2"
data-name="Camada 1"
><path
:fill="st1Fill"
:stroke="st1Stroke"
class="cls-1"
d="M59.72,35.42a.78.78,0,0,0-.39-.69c-1.11-.65-4.73-2.35-12.13-2.35-8.79,0-28.67,5.53-46.69,31.09a2,2,0,0,0,1.62,3.15H25.58C34.57,66.62,59.46,63.22,59.72,35.42Z"
/>
...
</g>
</g>
</svg>
</template>
<script lang="ts" setup>
import Vivus from 'vivus'
import { ref, onMounted, computed, toRefs } from 'vue'
interface Props {
animate?: boolean
}
const props = withDefaults(defineProps<Props>(), {
animate: true
})
const { animate } = toRefs(props)
const isStroke = ref<boolean>(false)
const isFill = ref<boolean>(false)
const st1Fill = computed(() => {
return isFill.value ? '#43807A' : 'rgb(255,255,255)'
})
const st1Stroke = computed(() => {
return isStroke.value ? 'rgb(255,255,255)' : '#43807A'
})
const st2Fill = computed(() => {
return isFill.value ? '#2D2D2D' : 'rgb(255,255,255)'
})
const st2Stroke = computed(() => {
return isStroke.value ? 'rgb(255,255,255)' : '#2D2D2D'
})
onMounted(() => {
if (animate.value) {
const icon = new Vivus('animate-icon-dlavro', {
type: 'delayed',
duration: 150,
animTimingFunction: Vivus.EASE
})
icon.play(() => {
isFill.value = true
isStroke.value = true
// called after the animation completes
})
} else {
isFill.value = true
isStroke.value = true
}
})
</script>
<style scoped>
.cls-3 {
fill: v-bind(st2Fill);
stroke: v-bind(st2Stroke);
}
</style>
I have a vue component that is an icon.
I hope I could have helped :)
from vivus.
Hi, sorry if this is too basic, I have a Vue3 project but the import is not working for me:
import Vivus from vivus
with an npm insall. I see it included in the dependencies, but it cannot recognise 'vivus'. I never had this probem before. Not sure how to debug this.
from vivus.
@erikacamilleri I hope you're talking about the TS issue and you need to install types dep
npm install @types/vivus -D
from vivus.
Related Issues (20)
- Trigger SVG to draw as soon as you see it (very large SVG) HOT 1
- Include Start delay without Loop HOT 3
- Is vivus deprecated? HOT 1
- daisy-chaining a series of images? HOT 2
- Beginner, unable to use HOT 8
- Support for Play Pause HOT 4
- Vivus MAP Array Empty, no animation rendered. HOT 2
- Problem using stroke based mask using multiple time the same SVG file
- Is there any rewind too?
- [Feature Request] Animate individual paths HOT 2
- [Error Fix]: There is a grammatical error on the index page. HOT 2
- Text is drawing immediately HOT 2
- Is there any option to draw svg on scroll? HOT 1
- No "ease-in-out" timing function? HOT 3
- Move a pencil while drawing ? HOT 1
- Callback function for when a path is completed? HOT 1
- Animation automatically replay
- Not working for a simple test HOT 2
- Please add Shuffle/Random animation type to Vivus
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vivus.