Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

202
Vistas
i want to toggle between two functions this code works only one time but i want to make it work each time i click
let callOne = true;
let hamburger = document.getElementById("hamburger");

hamburger.addEventListener("click", (e) => {toggleFct();});

function one() {t1.play();callOne = false;}

function two() {t0.play(); callOne = true;}

function toggleFct() { callOne ? one() : two();}

let t1 = gsap.timeline({ paused: true, reversed: true });

t1.to(".div-first", { ease: "power2.in", x: "-200%", duration: 2 });

t1.to(".div-second", { ease: "power2.in", x: "-300%", duration: 2 },"-=2");

t1.to(".div-third", { ease: "power2.in", x: "-400%", duration: 2 }, "-=2");

t1.to(header, { ease: "power2.in", x: "-400%", duration: 2 }, "-=2");

t1.to(wrap, { ease: "power2.in", x: "-400%", duration: 2 }, "-=2");

let t0 = gsap.timeline({ paused: true, reversed: true });

t0.to(".div-first", { ease: "power2.in", x: "100%", duration: 2 });

t0.to(".div-second", { ease: "power2.in", x: "200%", duration: 2 }, "-=2");

t0.to(".div-third", { ease: "power2.in", x: "300%", duration: 2 }, "-=2");

t0.to(header, { ease: "power2.in", x: "400%", duration: 2 }, "-=2");

t0.to(wrap, { ease: "power2.in", x: "0%", duration: 2 }, "-=2");

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

let callOne = true; let hamburger = document.getElementById("hamburger");

hamburger.addEventListener("click", (e) => {toggleFct();});

function one() {t1.play(0);callOne = false;}

function two() {t0.play(0); callOne = true;}

function toggleFct() { callOne ? one() : two();}

about 4 years ago · Juan Pablo Isaza Denunciar

0

When I try to do the following :

let callOne = true;

function one() {console.log("one");callOne = false;}

function two() {console.log("two"); callOne = true;}

function toggleFct() { callOne ? one() : two();}

It works just fine...

btw you can rewrite

hamburger.addEventListener("click", (e) => {toggleFct();});

as...

hamburger.addEventListener("click", toggleFct)
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda