-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(staggered-fade-and-slide): use Vue native staggered transition
- Loading branch information
1 parent
7137d0a
commit e2d332c
Showing
5 changed files
with
321 additions
and
33 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
packages/_vue3-migration-test/src/components/animations/test-staggered-fade-and-slide.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,67 @@ | ||
<template> | ||
<h1>Static content:</h1> | ||
<StaggeredFadeAndSlide tag="ul" :stagger="50"> | ||
<li key="1">Element to animate</li> | ||
<li key="2">Element to animate</li> | ||
<li key="3">Element to animate</li> | ||
</StaggeredFadeAndSlide> | ||
<br /> | ||
<h1>Animation as prop</h1> | ||
<BaseSuggestions :suggestions="suggestions" :animation="StaggeredFadeAndSlide" :stagger="50"> | ||
<template #default="{ suggestion }"> | ||
<span>{{ suggestion.query }}</span> | ||
</template> | ||
</BaseSuggestions> | ||
<br /> | ||
|
||
<h1>Dinamic content:</h1> | ||
<button @click="insert">Insert at random index</button> | ||
<button @click="reset">Reset</button> | ||
|
||
<StaggeredFadeAndSlide tag="ul" :stagger="50"> | ||
<li v-for="item in items" :key="item" class="item"> | ||
{{ item }} | ||
<button @click="remove(item)">x</button> | ||
</li> | ||
</StaggeredFadeAndSlide> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ref } from 'vue'; | ||
import StaggeredFadeAndSlide from '../../../../x-components/src/components/animations/staggered-fade-and-slide.vue'; | ||
import BaseSuggestions from '../../../../x-components/src/components/suggestions/base-suggestions.vue'; | ||
import { getQuerySuggestionsStub } from '../../../../x-components/src/__stubs__'; | ||
const suggestions = getQuerySuggestionsStub('chip', 5); | ||
const getInitialItems = () => [1, 2, 3, 4, 5]; | ||
const items = ref(getInitialItems()); | ||
let id = items.value.length + 1; | ||
/** | ||
* Insert a new item at a random index. | ||
*/ | ||
function insert() { | ||
const i = Math.round(Math.random() * items.value.length); | ||
items.value.splice(i, 0, id++); | ||
} | ||
/** | ||
* Reset the list of items. | ||
*/ | ||
function reset() { | ||
items.value = getInitialItems(); | ||
id = items.value.length + 1; | ||
} | ||
/** | ||
* Remove an item from the list. | ||
* | ||
* @param item - The item to remove. | ||
*/ | ||
function remove(item: any) { | ||
const i = items.value.indexOf(item); | ||
if (i > -1) { | ||
items.value.splice(i, 1); | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.