Hey,
I am using
let mm = gsap.matchMedia();
mm.add(
{
portrait: "(max-aspect-ratio: 7/3)",
landscape: "(max-aspect-ratio: 2)"
}, (context) => {
let {portrait, landscape} = context.conditions;
let tl = gsap.timeline({repeat: -1, repeatDelay: 7});
tl.from("#banner", {opacity:0, ease: "power2.out", duration: 0.4, delay:0.5});
tl.from("#guy", {yPercent:-100, ease: "bounce", duration: 0.6, delay:0.5});
tl.from("#textOne", {
yPercent: portrait ? 0 : -100,
xPercent: portrait ? -100 : 0,
ease: "power2.out", duration: 0.4});
tl.to("#textOne", {
yPercent: portrait ? 0 : 100,
xPercent: portrait ? 100 : 0,
ease: "power2.in", duration: 0.4, delay: 2});
tl.from("#textTwo", {
yPercent: portrait ? 0 : -100,
xPercent: portrait ? -100 : 0,
ease: "power2.out", duration: 0.4});
tl.to("#textTwo", {
yPercent: portrait ? 0 : 100,
xPercent: portrait ? 100 : 0,
ease: "power2.in", duration: 0.4, delay: 2});
tl.from("#packShotBG", {
scaleX: landscape ? 100 : 0,
scaleY: landscape ? 0 : 100,
ease: "power4.out", duration: 0.4, delay: 1});
tl.from("#packShotBG2", {
scaleX: landscape ? 100 : 0,
scaleY: landscape ? 0 : 100,
ease: "power4.out", duration: 0.4, delay: -0.2});
tl.from("#claim", {opacity:0, ease: "power4.out", duration: 0.4, delay: -0.2});
tl.from("#mainLogo", {opacity:0, ease: "power4.out", duration: 0.4, delay: -0.2});
tl.from("#subLogo", {opacity:0, ease: "power4.out", duration: 0.4, delay: -0.2});
}
)
to make my animation horizontally or vertically depending on the aspect ratio of the screen.
Now I wanted to test different scenarios on tried
mm.add(
{
portrait: false,
landscape: true
}, (context) => {
let {portrait, landscape} = context.conditions;
...
to force a certain behaviour. But I now get a syntax error.
Is there any way to set forced conditions without changing too much of my code?
TYVM
kws