JSFiddle - React, Tailwind, and code Playground

by unknown601

HTML

<script src="http://fonts.googleapis.com/css?family=Roboto:400,300,100,500,700"></script>
<div id="gallery-container">
<div class="gallery">
    <ul>
        <li> <a href="#" title="">
               <img src="http://th08.deviantart.net/fs71/200H/i/2012/190/b/7/bastique_graffiti_art_car__02__golf_mkv_r32_by_bastiqueart-d56k7iu.jpg" width="300" height="169" />
               <div class="info"><h3 class="heading">Lorem ipsum</h3>
        <p>dolor sit amet, consectetur adipiscing elit. Nam vel ultricies sem. Praesent posuere, augue quis aliquet vestibulum, metus tellus vehicula sem, tincidunt luctus nisl sem et orci.</p></div>
            </a>

        </li>
    </ul>
</div>
<div class="gallery">
    <ul>
        <li> <a href="#" title="">
               <img src="http://th08.deviantart.net/fs71/200H/i/2012/190/b/7/bastique_graffiti_art_car__02__golf_mkv_r32_by_bastiqueart-d56k7iu.jpg" width="300" height="169" />
               <div class="info"><h3 class="heading">Lorem ipsum</h3>
        <p>dolor sit amet, consectetur adipiscing elit. Nam vel ultricies sem. Praesent posuere, augue quis aliquet vestibulum, metus tellus vehicula sem, tincidunt luctus nisl sem et orci.</p></div>
            </a>

        </li>
    </ul>
</div>
<div class="gallery">
    <ul>
        <li> <a href="#" title="">
               <img src="http://th08.deviantart.net/fs71/200H/i/2012/190/b/7/bastique_graffiti_art_car__02__golf_mkv_r32_by_bastiqueart-d56k7iu.jpg" width="300" height="169" />
               <div class="info"><h3 class="heading">Lorem ipsum</h3>
        <p>dolor sit amet, consectetur adipiscing elit. Nam vel ultricies sem. Praesent posuere, augue quis aliquet vestibulum, metus tellus vehicula sem, tincidunt luctus nisl sem et orci.</p></div>
            </a>

        </li>
    </ul>
</div>
<div class="gallery">
    <ul>
        <li> <a href="#" title="">
               <img...

CSS

#gallery-container{
	width:600px;
	height:338px;
	background-color:#09C;
  position: relative;
    float: left;
	}
#gallery-container .heading {
    font-family:'Roboto', sans-serif;
    font-size: 16px;
    color:#333;
    padding-left:20px;
    padding-right:20px;
    padding-top:20px;
}
#gallery-container p {
    font-family:'Roboto', sans-serif;
    font-size: 12px;
    color:#333;
    padding-left:20px;
    padding-right:20px;
}
.gallery {
    width: 100%;
    height: auto;
}
.gallery li {
    width: 300px;
    height: 169px;
    position: relative;
    float: left;
    overflow: hidden;
    background-color:#ccc;
}
.transform {
    /* mouseleave */
    -moz-transition: all 200ms cubic-bezier(0.19, 1, 0.22, 1) 0s;
    -webkit-transition: all 200ms cubic-bezier(0.19, 1, 0.22, 1) 0s;
    -o-transition: all 200ms cubic-bezier(0.19, 1, 0.22, 1) 0s;
    transition: all 200ms cubic-bezier(0.19, 1, 0.22, 1) 0s;
}
li:hover .transform {
    /* mouseenter */
    -moz-transition-duration: 600ms;
    -webkit-transition-duration: 600ms;
    -o-transition-duration: 600ms;
    transition-duration: 600ms;
}
.transform-img {
    /* mouseleave */
    -webkit-transition: all 200ms cubic-bezier(0.19, 1, 0.22, 1) 0s;
    -moz-transition: all 200ms cubic-bezier(0.19, 1, 0.22, 1) 0s;
    -o-transition: all 200ms cubic-bezier(0.19, 1, 0.22, 1) 0s;
    transition: all 200ms cubic-bezier(0.19, 1, 0.22, 1) 0s;
}
li:hover .transform-img {
    /* mouseenter */
    -webkit-transition: all 700ms cubic-bezier(0.19, 1, 0.22, 1) 0s;
    -moz-transition: all 700ms cubic-bezier(0.19, 1, 0.22, 1) 0s;
    -o-transition: all 700ms cubic-bezier(0.19, 1, 0.22, 1) 0s;
    transition: all 700ms cubic-bezier(0.19, 1, 0.22, 1) 0s;
}
.gallery a {
    width: 100%;
    height: 100%;
    display: block;
}
.gallery img {
    position: relative;
}
.gallery .info {
    width: 100%;
    height: 100%;
    position: absolute;
    z-index: 10;
    opacity:1;
    background: #ccc;
    -webkit-transform:...

JavaScript

$(".gallery li").on("mouseenter mouseleave", function (e) {

      var w = $(this).width();
      var h = $(this).height();

      var x = (e.pageX - $(this).offset().left - (w / 2)) * (w > h ? (h / w) : 1);
      var y = (e.pageY - $(this).offset().top - (h / 2)) * (h > w ? (w / h) : 1);

      var direction = Math.round((((Math.atan2(y, x) * (180 / Math.PI)) + 180) / 90) + 3) % 4;

      /** check for direction **/
      switch (direction) {
          case 0:
              // direction top
              var slideFrom = {
                  "top": "-100%",
                      "right": "0"
              };
              var slideTo = {
                  "top": 0
              };
              var imgSlide = "0, 100";

              break;
          case 1:
              // direction right
              var slideFrom = {
                  "top": "0",
                      "right": "-100%"
              };
              var slideTo = {
                  "right": 0
              };
              var imgSlide = "-100, 0";

              break;
          case 2:
              // direction bottom
              var slideFrom = {
                  "top": "100%",
                      "right": "0"
              };
              var slideTo = {
                  "top": 0
              };
              var imgSlide = "0, -100";

              break;
          case 3:
              // direction left
              var slideFrom = {
                  "top": "0",
                      "right": "100%"
              };
              var slideTo = {
                  "right": 0
              };
              var imgSlide = "100, 0";

              break;
      }

      if (e.type === 'mouseenter') {
          var element = $(this);

          element.find(".info").removeClass("transform").css(slideFrom);
          element.find("img").addClass("transform-img").css("transform", "matrix(1, 0, 0, 1," + imgSlide + ")");

          setTimeout(function () {
             ...