Vue Animation Individual floating elements like on Coachella website - animation

Can anyone point out how to achieve something similar to
https://www.coachella.com/home/
Social section animation/carousel
Can someone point out how we may create it in a Vue object with the help of transitions and more..
HTML
<template>
<div id="app">
<div class="cent">
<button v-on:click="show = !show">Toggle</button>
</div>
<div class="cent">
<transition v-for="block in blocks" :key="block" name="fade">
<div class="block" v-if="show">
<p class="els">{{block}}</p>
</div>
</transition>
</div>
</div>
</template>
JS
export default {
name: "app",
data() {
return {
msg: "Welcome to Your Vue.js App",
show: false,
blocks: ["element", "fire", "water", "earth", "wind"]
};
}
};
CSS
.els{
background-color: aqua;
display: inline-flex;
padding:20px;
}
.cent{
margin-left:auto;
margin-right:auto;
display: flex;
justify-content: center;
flex-direction: column;
overflow: hidden;
}
.block {
font-family: Arial, Helvetica, sans-serif;
color: #fff;
flex-basis: auto;
}
.fade-enter{
}
.fade-enter-active{
animation:slideIn 1s ease-out forwards;
}
.fade-leave{
}
.fade-leave-active{
animation:slideOut 1s ease-out forwards;
}
#keyframes slideIn {
from {
transform:translateX(100%);
}
to {
transform:translateX(0%);
}
}
#keyframes slideOut {
from {
transform:translateX(0%);
}
to {
transform:translateX(100%);
}
}
Just a basic try to make elements of blocks float... But as said earlier i want to make it float like coachella site.
P.S
I have tried google and other resources like madewithvuejs and others but didn't found anything similar.
Any help would be grateful..

Related

Svelte - Transitions in layout not delaying {#key}ed <slot> update

I'm trying to add a transition between pages in a SvelteKit application. When navigating, the current page should fade out, and the new page should then fade in in its place. To accomplish this, in +layout.svelte, I wrapped the <slot> in a div with the in and out transitions set. I wrapped this all in {#key $page.url.pathname} so that the animations are triggered when navigating from page to page. However, my current code produces this effect:
When navigating, the content of the page updates before fading out. In other words, the destination page immediately appears, then fades out, then fades back in. At the same time, though, content in +layout.svelte (.title, at the top of the page) behaves correctly; just the content within the <slot> is bugged.
Here is the code:
+layout.svelte
<script lang="ts">
import '$lib/style.css';
import { page } from '$app/stores';
import { fade } from 'svelte/transition';
</script>
<div class="page">
<div class="bar">
Sidebar
Page 1
Page 2
</div>
<div class="content-wrapper">
{#key $page.url.pathname}
<div class="content" in:fade={{ delay: 1000, duration: 1000 }} out:fade={{ duration: 1000 }}>
<div class="title">
{$page.url.pathname}
</div>
<slot />
</div>
{/key}
</div>
</div>
<style global>
.page {
display: flex;
flex-direction: row;
box-sizing: border-box;
width: 100vw;
min-height: 100vh;
}
.bar {
display: flex;
flex-direction: column;
width: 300px;
color: white;
background: black;
}
a {
color: white;
}
.content-wrapper {
flex-grow: 1;
width: 100%;
min-height: 100vh;
}
.content {
width: 100%;
height: 100%;
}
.title {
font-size: 2em;
}
</style>
+page.svelte
<div class="page">
<div class="title">Page 1</div>
</div>
<style>
.page {
width: 100%;
height: 100%;
background: blue;
}
</style>
page2/+page.svelte
<div class="page">
<div class="title">Page 2</div>
</div>
<style>
.page {
width: 100%;
height: 100%;
background: red;
}
</style>
Is there a way to get the <slot> content to wait for the out animation to finish before updating?
Its an issue with the lifecycle of the transitions for in and out.
I usually use in:fade ONLY on elements and it looks okay. It seems using both means that while one element is going out, another is coming in at the same time in which looks funny.
Perhaps you could find out more about delay in transitions and let us know..
Happy coding☺️

how to use :deep(.className) in vue 2

i have working scss styles
.alert {
::v-deep .v-alert__border {
top: 8px;
bottom: 8px;
border-radius: 200px;
}
&:not(&--rtl) {
// styles
}
}
I want to redo these styles like this.
.alert {
:deep(.v-alert__border) {
top: 8px;
bottom: 8px;
border-radius: 200px;
}
&:not(&--rtl) {
// styles
}
}
The problem is that it doesn't work.
I use
"vue": "^2.6.11",
Found information that this functionality is not supported in "vue": "^2.6.11",.
Is it really not supported or am I doing something wrong?
Looking at the discussion found here: https://github.com/vuejs/core/issues/4745
Every example starts with :deep and never nested?
:deep(.alert.v-alert__border) {
top: 8px;
bottom: 8px;
border-radius: 200px;
}
:deep(.alert) {
.v-alert__border {
top: 8px;
bottom: 8px;
border-radius: 200px;
}
}
Perhaps one of those two works?
I tested these codes and they works for me. I am using vue version 2.6.11 and vue cli version 4.5 and sass version 1.26.5:
parent component:
<template>
<section>
<div class="myParent">
<ChildAlert></ChildAlert>
</div>
<ChildAlert></ChildAlert>
</section>
</template>
<script>
import ChildAlert from "./ChildAlert";
export default {
name: "AlertCompo",
components: {
ChildAlert
}
}
</script>
<style scoped lang="scss">
.myParent {
background-color: #000;
:deep(.myTitle) {
color: red;
}
}
</style>
child component:
<template>
<section>
<h1 class="myTitle">this is Child component</h1>
</section>
</template>
<script>
export default {
name: "ChildAlert"
}
</script>
<style scoped>
</style>

How to implement ::v-deep on Sass suffixes (&__) selector in Vue2?

I am working on scoping all the styles of our Vue2 frontend codebase to prepare for the transition into Vue3. I have read on Vue docs that the ::v-deep directive enables the child component to receive the scoped styles from their parent components.
We use Sass. Some child component classes don't get the style applied even though I have implemented ::v-deep on their parent component.
Here's the code of the style section:
<style lang="scss" scoped>
.support-category::v-deep {
.icon-back {
font-size: 14px;
color: color(text4);
}
.border-bottom {
border-bottom: 1px solid color(bg3);
}
&__subject {
font-size: 18px;
font-weight: 700;
}
&__accordion {
font-size: 15px;
ul,
ol {
margin-bottom: 0.75rem;
margin-left: 14px;
margin-top: 3px;
}
ul {
list-style-type: disc;
}
ol {
list-style-type: decimal;
}
}
}
</style>
Here's the portion of code of the template section:
<div v-if="hasSupportCategories">
<div
v-for="category in mainSupportCategory.support_categories"
:key="category.id"
class="mb-8"
>
<v-row>
<v-col :size="12">
<v-accordion
class="support-category__accordion"
:initial-active="mainSupportCategory.support_categories.length === 1"
>
<template v-slot:title>
<div class="support-category__subject pb-3 border-bottom">
{{ category.title }}
</div>
</template>
<div
v-for="item in category.support_items"
:key="item.id"
>
<v-accordion class="support-category__accordion border-bottom py-3">
<template v-slot:title>
<div class="font-bold">
{{ item.title }}
</div>
</template>
<v-markdown
:source="item.text"
class="pt-3 pb-2"
/>
</v-accordion>
</div>
</v-accordion>
</v-col>
</v-row>
</div>
</div>
The v-accordion component has ::v-deep implemented as well:
<style lang="scss" scoped>
.accordion::v-deep {
.icon-left {
margin-right: 0.75rem;
font-size: 12px;
color: color(text4);
}
}
</style>
<div class="accordion flex flex-col w-full">
<div
class="cursor-pointer"
#click="toggle"
>
<slot name="title" />
</div>
<div v-show="active">
<slot />
</div>
</div>
I have tried many techniques but nothing worked out:
&::v-deep(__subject) {
font-size: 18px;
font-weight: 700;
}
or
&::v-deep(&__subject) {
font-size: 18px;
font-weight: 700;
}
The only solution that worked is to make this suffixe selector an independent child selector.
.subject {
font-size: 18px;
font-weight: 700;
}
That works for this case but since we use suffixes a lot in the codebase I would like to find a solid solution.
Thanks!
Answer:
Use a postcss.config.js file and add a 'postcss-prefix-selector' like so to give each class a prefix.
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
'postcss-prefix-selector': {
prefix: '#single-spa-application',
},
},
};

How can I make flower animation?

How can I get this animation effect? I mean exacly this one:
I have to animate the image (I have every part of it in layers). What I should use? which way is the best?
i hope this can help,i use animation on load event using jQuery.
$( window ).on( "load", function() {
$('.main-section').toggleClass('animation-effect');
});
body {
margin: 0;
}
.main-section {
padding: 25px 0px 0 20px;
background-color: #d7f0f7;
}
.main-section .content {
max-width: 450px;
background-color: #d7f0f7;
transform: translateX(-500px);
transition: 0.8s;
}
.main-section .content .box {
height: 150px;
background-color: #e91e63;
margin-top: -15px;
transition: 0.5s;
width: 0;
}
.main-section .content .leaf {
padding-left: 100px;
}
.main-section .content .half-circle {
padding-left: 100px;
margin-top: -20px;
}
.main-section .content .half-circle-2 {
padding-left: 100px;
margin-top: -25px;
transform: rotate(-14deg);
}
.main-section .content .leaf img {
padding-left: 115px;
}
.main-section.animation-effect .content{
transform: translateX(0px);
transition: 1s;
}
.main-section.animation-effect .box {
width: 100%;
transition: 1s;
}
.main-section .content .half-circle img {
animation: rotate 3.5s infinite;
}
.main-section .content .leaf img {
animation: leaf-animation 3s infinite;
}
#keyframes rotate {
0% {
transform: rotate(-14deg);
}
50% {
transform: rotate(10deg);
}
100%
{
transform: rotate(-14deg);
}
}
#keyframes leaf-animation {
0% {
transform: rotate(0);
}
50% {
transform: rotate(3deg);
}
100% {
transform: rotate(0deg);
}
}
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<div class="main-section">
<div class="content">
<div class="leaf">
<img src="https://i.ibb.co/fSQXHD5/leaf.png" alt="leaf" border="0">
</div>
<div class="half-circle">
<img src="https://i.ibb.co/xfmy6zS/half-1.png" alt="half-1" border="0">
</div>
<div class="half-circle-2">
<img src="https://i.ibb.co/CBdVwNC/half-2.png" alt="half-2" border="0">
</div>
<div class="box">
</div>
</div>
</div>

How to make Bootstrap's dropdown on hover?

How can I make twitter bootstrap's menu dropdown be on hover instead of a click?
1.Hide dropdown-menu on mouseover.
$(document).ready(function() {
$('.nav li.dropdown').hover(function() {
$(this).addClass('open');
}, function() {
$(this).removeClass('open');
});
});
2.Hide dropdown-menu on click.
$(document).ready(function() {
$('.nav li.dropdown').hover(function() {
$(this).addClass('open');
});
});
http://jsfiddle.net/7yMsQ/1/
heres a function I'm using to get the navbar dropdowns to slide down on hover instead of just popping in
$('.navbar .dropdown').hover(function() {
$(this).find('.dropdown-menu').first().stop(true, true).delay(250).slideDown();
}, function() {
$(this).find('.dropdown-menu').first().stop(true, true).delay(100).slideUp()
});
While How to make twitter bootstrap menu dropdown on hover rather than click has been upvoted a lot, with the newer versions of Bootstrap, no need to hack at it.
http://cameronspear.com/blog/twitter-bootstrap-dropdown-on-hover-plugin/ is a replacement for the existing dropdown.js, and lets you enable on hover. No CSS modifications required.
You can simply do this by using only css. In case of button dropdown.
<div class="btn-group btn-hover-group">
Action 1
<ul class="dropdown-menu pull-right">
<li>Action 2</li>
<li>Action 3</li>
</ul>
</div>
Removed data-toggle="dropdown" from
.btn-hover-group > a:hover ~ ul{
display:block;
}
.btn-hover-group > .dropdown-menu:hover{
display:block;
}
I hope this will suffice your purpose.
You could use a bootstrap 4 like this..
<div class="dropdown">
<button class="dropbtn">Dropdown</button>
<div class="dropdown-content">
Link 1
Link 2
Link 3
</div>
</div>
then define the class property value following..it should work
.dropbtn {
background-color: #4CAF50;
color: white;
padding: 16px;
font-size: 16px;
border: none;
}
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f1f1f1;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.dropdown:hover .dropdown-content {display: block;}

Resources