sky-accordion - npm explorer

`


Accordion GSAP TweenLite animation


`javascript
// This import way ensures SSR executes without errors
const GSAP = {};

if (typeof window !== 'undefined') {
GSAP.TweenLite = require('gsap/all').TweenLite;
GSAP.CSSPlugin = require('gsap/all').CSSPlugin;
}

export default {
name: 'ParentComponent',
mounted() {
this.$on('statusChange', (payload) => {
payload.status
? this.tweenOpen(payload.vm.nodes.content)
: this.tweenClose(payload.vm.nodes.content);
});

this.$refs.mygroup.inActiveElements.forEach((el) => {
this.tweenSet(el.nodes.content, 0);
});
},
methods: {
closeAll() {
this.$refs.mygroup.closeAll();
},
openAll() {
this.$refs.mygroup.openAll();
},
tweenOpen(element) {
// Enable animation to height auto.
this.tweenSet(element, 'auto');

GSAP.TweenLite.from(
element,
0.3,
{ height: 0 },
);
},
tweenClose(element) {
GSAP.TweenLite.to(
element,
0.3,
{ height: 0 },
);
},
tweenSet(element, height) {
GSAP.TweenLite.set(element, { height });
},
},
}
`


Single wrapper GSAP Tweelite animation


`javascript
// This import way ensures SSR executes without errors
const GSAP = {};

if (typeof window !== 'undefined') {
GSAP.TweenLite = require('gsap/all').TweenLite;
GSAP.CSSPlugin = require('gsap/all').CSSPlugin;
}

export default {
name: 'ParentComponent',
mounted() {
this.$on('statusChange', (payload) => {
payload.status
? this.tweenOpen(payload.vm.nodes.content)
: this.tweenClose(payload.vm.nodes.content);
});

if (this.$refs.singleton && !this.$refs.singleton.status) {
this.tweenSet(this.$refs.singleton.nodes.content, 0);
}
},
methods: {
close() {
this.$refs.singleton.close();
},
open() {
this.$refs.singleton.open();
},
tweenOpen(element) {
this.tweenSet(element, 'auto');

GSAP.TweenLite.from(
element,
0.3,
{ height: 0 },
);
},
tweenClose(element) {
GSAP.TweenLite.to(
element,
0.3,
{ height: 0 },
);
},
tweenSet(element, height) {
GSAP.TweenLite.set(element, { height });
},
},
}
`


CSS only animation


`css
.sky-accordion-content {
max-height: 0;
transition: max-height 0.3s ease-out;
overflow: hidden;
}

.sky-accordion-wrapper--is-active .sky-accordion-content {
transition: max-height 0.3s ease-in;
max-height: 500px;
}
``

Todo


- implement a11y
- deeplinkage support (determine if to be inside or outside module)