Skip to content

Commit

Permalink
feat: expose delayUntil prop, iterate on example
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Rothenberg authored and mattrothenberg committed Nov 9, 2019
1 parent c4eded4 commit acab245
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 11 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
"build-storybook": "build-storybook -s ./storybook-assets",
"prepublishOnly": "npm run build"
},
"dependencies": {
"flip-toolkit": "^7.0.6"
},
"devDependencies": {
"@babel/core": "^7.6.0",
"@babel/preset-env": "^7.6.0",
Expand All @@ -36,5 +33,8 @@
"vue-loader": "^15.7.0",
"vue-router": "^3.0.3",
"vue-template-compiler": "^2.6.10"
},
"dependencies": {
"flip-toolkit": "^7.0.6"
}
}
2 changes: 2 additions & 0 deletions src/Flipped.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export default {
props: {
flipId: String,
inverseFlipId: String,
delayUntil: String,
stagger: [String, Boolean],
shouldFlip: Function,
shouldInvert: Function,
Expand All @@ -26,6 +27,7 @@ export default {
this.addFlippedElement({
element: this.$el,
flipId: this.flipId,
delayUntil: this.delayUntil,
shouldFlip: this.shouldFlip,
shouldInvert: this.shouldInvert,
onStart: el => this.$emit("on-start", { el, id: this.flipId }),
Expand Down
2 changes: 2 additions & 0 deletions src/Flipper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export default {
addFlippedElement({
element,
flipId,
delayUntil,
stagger,
shouldFlip,
shouldInvert,
Expand All @@ -45,6 +46,7 @@ export default {
this.flipInstance.addFlipped({
element,
flipId,
...(delayUntil ? { delayUntil } : undefined),
...(stagger ? { stagger } : undefined),
...(shouldFlip ? { shouldFlip } : undefined),
...(shouldInvert ? { shouldInvert } : undefined),
Expand Down
51 changes: 43 additions & 8 deletions stories/Accordion.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,49 @@
<template>
<Flipper :flipKey="focused" spring="gentle" :staggerConfig="staggerConfig">
<Flipper :flipKey="focused" :staggerConfig="staggerConfig">
<div class="m-4">
<div v-for="(num, index) in list" :key="index">
<Flipped :flipId="`card-${index}`" v-if="index !== focused" stagger="card">
<div @click="toggleItem(index)" role="button" class="bg-grey h-8 my-4"></div>
<Flipped
:shouldInvert="shouldFlip(index)"
:flipId="`card-${index}`"
v-if="index !== focused"
stagger="card"
>
<div
@click="toggleItem(index)"
role="button"
class="bg-grey h-8 my-4 flex items-center p-4"
>
<Flipped :inverseFlipId="`card-${index}`">
<div>
<Flipped
:delayUntil="`card-${index}`"
:shouldFlip="shouldFlip(index)"
:flipId="`avatar-card-${index}`"
>
<div class="bg-grey-dark rounded-full w-3 h-3"></div>
</Flipped>
</div>
</Flipped>
</div>
</Flipped>
<Flipped :flipId="`card-${index}`" v-else stagger="card">
<div @click="toggleItem(index)" role="button" class="bg-grey h-32 my-4"></div>
<div
@click="toggleItem(index)"
role="button"
class="bg-grey h-32 my-4 flex items-center justify-center p-4"
>
<Flipped :inverseFlipId="`card-${index}`">
<div>
<Flipped
delayUntil="foo"
:shouldFlip="shouldFlip(index)"
:flipId="`avatar-card-${index}`"
>
<div class="bg-grey-dark rounded-full w-12 h-12"></div>
</Flipped>
</div>
</Flipped>
</div>
</Flipped>
</div>
</div>
Expand All @@ -26,11 +63,10 @@ export default {
data() {
return {
focused: null,
list: Array(6)
list: Array(8)
.fill()
.map(() => ({
open: false,
description: ["a", "b", "c"]
open: false
}))
};
},
Expand Down Expand Up @@ -60,7 +96,6 @@ export default {
return {
card: {
reverse: this.focused === null,
// reverse: true,
speed: 0.1
}
};
Expand Down

0 comments on commit acab245

Please sign in to comment.