michalsnik / aos

Animate on scroll library
MIT License
26.85k stars 2.6k forks source link

Change transition for mobile at element level #564

Open devindreher opened 4 years ago

devindreher commented 4 years ago

This is:

Wondering what the property is to change animation direction at an element level (e.g., div) using media queries.

For example:

@media screen and (max-width: 800px) {
.element {
data-aos="fade-up"
}
}
evankford commented 4 years ago

You can use an attribute CSS selector to get this done!

Let's say you wanted to select all .element elements with the data-aos="fade-up" property. You would use the following rule.

@media screen and (max-width: 800px) {
.element[data-aos="fade-up"] {
/* Insert changes here */
}

You may also need to target specifically once they're finished animating, so you'd use something like this:

@media screen and (max-width: 800px) {
.element.aos-animate[data-aos="fade-up"] {
/* Insert changes here */
}
devindreher commented 4 years ago

That doesn't seem to do what I need. For example, if I have elements that are set to fade up and want to change to fade-left via the media query, I can't do that:

@media screen and (max-width: 800px) { .element[data-aos="fade-up"] { data-aos="fade-left" } }

Vishesh-coder commented 2 years ago

You can add like this- If you want to change fade up to down Example-

@media screen and (max-width: 800px) { .element[data-aos="fade-up"] { transform: translateY(50px); }