-
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
9ff88d5
commit e98a862
Showing
7 changed files
with
318 additions
and
49 deletions.
There are no files selected for viewing
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
72 changes: 72 additions & 0 deletions
72
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 |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<template> | ||
<h1>Dinamic content:</h1> | ||
<button @click="insert">Insert at random index</button> | ||
<button @click="reset">Reset</button> | ||
|
||
<StaggeredFadeAndSlide tag="ul" :stagger="500"> | ||
<li v-for="item in items" :key="item.id"> | ||
{{ item.id }} - {{ item.name }} | ||
<button @click="remove(item)">x</button> | ||
</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>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> | ||
</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, | ||
createResultStub, | ||
getResultsStub | ||
} from '../../../../x-components/src/__stubs__'; | ||
const suggestions = getQuerySuggestionsStub('chip', 5); | ||
const getInitialItems = () => getResultsStub(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, createResultStub(`Product ${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
171 changes: 122 additions & 49 deletions
171
packages/x-components/src/components/animations/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
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.