jackpot 04

In this example below you will see how to do a jackpot 04 with some HTML / CSS and Javascript

Thumbnail
This awesome code was written by benoitwimart, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright benoitwimart ©
  • HTML
  • CSS
  • JavaScript
    <button id="launch">GO ! </button>
<div class="numbers">
  <div id="one">
    <ul>
      <li>5</li>
      <li>1</li>
      <li>2</li>
      <li>3</li>
      <li>4</li>
      <li>5</li>
      <li>1</li>
    </ul>
  </div>

  <div id="two">
    <ul>
      <li>5</li>
      <li>1</li>
      <li>2</li>
      <li>3</li>
      <li>4</li>
      <li>5</li>
      <li>1</li>
    </ul>
  </div>

  <div id="three">
    <ul>
      <li>5</li>
      <li>1</li>
      <li>2</li>
      <li>3</li>
      <li>4</li>
      <li>5</li>
      <li>1</li>
    </ul>
  </div>
</div>
<div id="link-frame">
  <a id="link" href="">lien gagnant</a>
</div>

/*Downloaded from https://www.codeseek.co/benoitwimart/jackpot-04-ZoryGm */
    body{
  font-family:sans-serif;
}
#one,#two,#three{
  width:30px;
  height:30px;
  overflow:hidden;
  display:inline-block;
}
ul{
  margin:0;
  padding:0;
}

li{
  display:block;
  height:30px;
  line-height:30px;
  width:30px;
}

#link-frame{
  height:30px;
  line-height:30px;
  overflow:hidden;
}

#link{
  display:block;
}


/*Downloaded from https://www.codeseek.co/benoitwimart/jackpot-04-ZoryGm */
    var button = document.querySelector("#launch");
var link = document.querySelector("#link");

var combi = ["111", "222", "333", "444", "555", "123", "452", "151", "113"];
var tl;

button.addEventListener("click", function() {
  if (typeof tl==='undefined' || tl.isActive() === false) {
    var randomCombi = combi[Math.floor(Math.random() * combi.length)];
    console.log(randomCombi);
    tl = new TimelineMax();
    tl.to("#link", 0.3, { y: 30 });
    tl.to("ul", 1, { color: "#000" });

    tl.to(
      "#one ul",
      5,
      {
        y: -600 - Number(randomCombi[0]) * 30,
        modifiers: {
          y: function(y) {
            var newY = y % 150; // 150 = 5 * 30
            return newY;
          }
        }
      },
      "-=1.3"
    );

    tl.to(
      "#two ul",
      5,
      {
        y: -600 - Number(randomCombi[1]) * 30,
        modifiers: {
          y: function(y) {
            var newY = y % 150; // 150 = 5 * 30
            return newY;
          }
        }
      },
      "-=4.9"
    );

    tl.to(
      "#three ul",
      5,
      {
        y: -600 - Number(randomCombi[2]) * 30,
        modifiers: {
          y: function(y) {
            var newY = y % 150; // 150 = 5 * 30
            return newY;
          }
        }
      },
      "-=4.9"
    );

    tl.staggerTo("ul", 0.8, { color: "#fa0" }, 0.2);

    switch (randomCombi) {
      case "111":
        tl.set("#link", { attr: { href: "https://google.fr" } });
        break;
      case "222":
        tl.set("#link", { attr: { href: "https://google.com" } });
        break;
      case "333":
        tl.set("#link", { attr: { href: "https://google.be" } });
        break;
      default:
        tl.set("#link", { attr: { href: "#" } });
        break;
    }
    tl.fromTo("#link", 0.3, { y: -30 }, { y: 0 });
  }
});


Comments