Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

208
Views
quiero alternar entre dos funciones, este código funciona solo una vez, pero quiero que funcione cada vez que hago clic
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({ pausado: verdadero, invertido: verdadero });

t1.to(".div-primero", { facilidad: "power2.in", x: "-200%", duración: 2 });

t1.to(".div-segundo", { facilidad: "power2.in", x: "-300%", duración: 2 },"-=2");

t1.to(".div-tercero", { facilidad: "power2.in", x: "-400%", duración: 2 }, "-=2");

t1.to(header, { facilidad: "power2.in", x: "-400%", duración: 2 }, "-=2");

t1.to(wrap, { facilidad: "power2.in", x: "-400%", duración: 2 }, "-=2");

let t0 = gsap.timeline({ pausado: verdadero, invertido: verdadero });

t0.to(".div-primero", { facilidad: "power2.in", x: "100%", duración: 2 });

t0.to(".div-segundo", { facilidad: "power2.in", x: "200%", duración: 2 }, "-=2");

t0.to(".div-tercero", { facilidad: "power2.in", x: "300%", duración: 2 }, "-=2");

t0.to(header, { facilidad: "power2.in", x: "400%", duración: 2 }, "-=2");

t0.to(wrap, { facilidad: "power2.in", x: "0%", duración: 2 }, "-=2");

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

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

hamburguesa.addEventListener("clic", (e) => {toggleFct();});

función uno() {t1.play(0);callOne = false;}

función dos() {t0.play(0); llamarUno = verdadero;}

function toggleFct() { callOne ? uno dos();}

about 4 years ago · Juan Pablo Isaza Report

0

Cuando trato de hacer lo siguiente:

 let callOne = true; function one() {console.log("one");callOne = false;} function two() {console.log("two"); callOne = true;} function toggleFct() { callOne ? one() : two();}

Funciona bien...

por cierto puedes reescribir

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

como...

 hamburger.addEventListener("click", toggleFct)
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!