javascript
javascript
javascript
  • Lấy vị trí người dùng với javascript
  • [Problem] Lấy key đầu tiên tìm thấy chứa giá trị cần tìm (ok)
  • 🥸Đoạn mã JavaScript để thêm ký tự đặc biệt vào đầu mỗi dòng trong văn bản nhiều dòng (ok)
  • 😍Tạo ra font in đậm và copy đến website để sử dụng (ok)
  • Hiệu ứng mở sách cực đẹp
  • 🤩JS: Scroll Animation using Intersection Observer API 🤩 (ok)
  • 😅Draw svg on scroll Full (ok)
  • 😄Install Linguise on any domain dịch tự động (ok)
  • 😅Sử dụng ajax tạo popup cho các bài viết wordrpess mattervn.com (ok)
  • 😆PWA - beforeinstallprompt toplusgames.com (ok)
  • How to Use the HTML5 Full-Screen API (Again) (ok)
  • [ERROR GAME] fix lỗi không load iframe gamedistribution.com for toplusgames.com (ok)
  • 😅jQuery Plugin To Create Animated Placeholders - placeholderTypewriter (ok)
  • 😍Làm chức năng thông báo khách hàng đăng ký namkhoahanoi.vn (ok)
  • Tencent Captcha Demo (ok)
  • 😉Send Mail same javascript elasticemail (ok)
  • 🥳Các tool phong thuỷ (ok)
  • 😇Nice Select A lightweight Vanilla JavaScript plugin (ok)
  • Merge objects with the same id but sum values of the objects (ok)
  • 😅Page: DOMContentLoaded, load, beforeunload, unload phần 1 (ok)
  • 😍Scripts: async, defer phần 2(ok)
  • 😂Javascript Array chunkArrayInGroups(arr, size)
  • Sequentially Resolve Promises Works, Giải quyết tuần tự các lời hứa hoạt động (ok)
  • Using Async / Await with the Array Reduce Method API (ok)
  • Flatten an array of arrays,merge, làm phẳng một mảng các mảng (ok)
  • 😌Dependent Dropdown Full (ok)
  • 🥳Select Box Change Dependent Options dynamically (JavaScript Object)
  • 🤩Add elements dynamically full (ok)
  • 😅👌Multiple versions jquery (ok)
  • 😍Cách sử dụng jQuery trong sweetAlert2 là chúng ta phải sử dụng didOpen full (ok)
  • 😁😁 mdbgo.io, mdbootstrap.com full (ok)
  • 🤪Chú ý nếu lỗi cảnh báo từ khóa new nếu dùng trong js thường chúng ta sẽ sử dụng trong mudule (ok)
  • 😝reCAPTCHA javascript (ok)
  • Firework Simulator v2 Phao Hoa (ok)
  • Active scroll center (ok)
  • 🤪Sort array of objects by string property value (ok)
  • 😏findIndex, find index in Array object (ok)
  • 😂Sử dụng nhiều toán tử 3, multiple Ternary Operators (ok)
  • 😅A simple and easy to use library that creates fullscreen scrolling websites fullPage.js (ok)
  • Xây dựng ứng dụng CRUD sử dụng Vue.js trong Laravel (ok)
  • [Chart] Morris.js Line & Area Charts,Bar Charts, Donut Charts, graph (ok)
  • [Chart] Chart.js
  • Multi select checkbox table bootstrap (ok)
  • 😀jquery new, jquery old, jquery migrate (ok)
  • Popup slide up from the bottom overflowing other div blocks (ok)
  • ASYNC JavaScript (CALLBACK, PROMISES, ASYNC AWAIT) video (ok)
  • === START jQuery Mobile ===
  • Data Attributes full (ok)
  • Viết một ứng dụng Restaurant Picke sử dụng "back menu" (ok)
  • Viết một ứng dụng thời tiết, Weather sử dụng panel (ok)
  • jQuery Mobile Tutorial w3schools.com (ok)
  • jQuery Mobile
  • jQuery Mobile - Events (ok)
  • Back button in jquery mobile (ok)
  • === END jQuery Mobile ===
  • removeDuplicates, Remove duplicate values from JS array, remove all duplicates an array object (ok)
  • Sử dụng thư viện jquery.hoverdir.js để làm hiệu ứng hover tuyệt đẹp (ok)
  • Modernizr là gì ? Sử dụng nó cho những trình duyệt cũ ra sao? (ok)
  • Nhận biết tính năng CSS: Modernizr hay Feature Queries? (ok)
  • [SALESFORCE] Remote Action function in Visualforce Page (ok)
  • ScrollIt.js menu (ok)
  • Cách sử dụng scrollTo vanilla cực chất 😘 (ok)
  • Một bài toán xử lý bất đồng bộ trong kintone để lấy số requet quá giới hạn (OK)
  • hexagon thư viện tạo avatar Canvas (ok)
  • 😅Sử dụng Object.assign và để copy dữ liệu, edit, input, form (ok)
  • Một cách đặt và gán giá trị trong mảng, object cự ngắn gọn (ok)
  • [LAZY] jQuery.Lazy và tạo background-loading cực chất (ok)
  • Ví dụ Sử dụng sẵn thư viện masonry của wordpres (ok)
  • Ảnh base64 dùng làm src, placeholder (ok)
  • Kiểm tra hình ảnh đã được tải với thư viện imagesLoaded (ok)
  • Check if Function Exists before Calling? (ok)
  • Async/Await Javascript Full Example (ok)
  • Thenables in JavaScript phục vụ cho bài viết trên (ok)
  • Script distance, khoảng cách (ok)
  • Time, Date full (ok)
  • Function getAllDatesOfMonth (ok)
  • How do I make a placeholder for a 'select' box? (ok)
  • Library choise (ok)
  • jQuery - Redirect with post, Get data php (ok)
  • How to pass data from one page to another page html (ok)
  • how to send data onClick() to another php for processing using post or get?
  • draw grid, vẽ grid (ok)
  • Fullscreen Horizontal Page Slider with jQuery and CSS3 - HSlider scroll template html (ok)
  • _.template, UnderscoreJS Templates Full (ok)
  • Character limit on tag type input number (ok)
  • How to set maximum length in input type=number (ok)
  • ========= START JEST =======
  • Getting Started (ok)
  • Using Matchers (ok)
  • Testing Asynchronous Code
  • Setup and Teardown (ok)
  • Mock Functions
  • Jest Platform
  • Jest tutorial
  • Testing trong Javascript với Jest (Phần 1) (ok)
  • Testing trong Javascript với Jest (Phần 2)
  • Giới thiệu về Jest (Delightful JavaScript Testing)
  • Thử nghiệm phát triển theo hướng phản ứng với Jest và Enzyme
  • Cách kiểm tra các thành phần phản ứng với Jest và Enzyme, Phần 1
  • Cách kiểm tra thành phần phản ứng với Jest và Enzyme, Phần 2
  • Jest js mock jquey and lib
  • Unit testing Các thành phần React với Enzyme và Jest
  • Hướng dẫn viết unit test React với Jest và Enzyme (P1)
  • Tôi đã test các React component như thế nào? (phần 2)
  • Test component trong React với Jest
  • Test Component với Jest và Emzyme
  • Tổng quan về unit test cho dự án react redux saga với Jest Part 1
  • ========= END JEST =======
  • ======= START GULP TUTORIAL ======
  • [GULP] Tìm hiểu về Gulp.js
  • [GULP] Gulp Tutorial
  • [GULP] Gulp - Developing An Application (ok)
  • [GULP] Gulp - Combining Tasks (ok)
  • [GULP] Gulp - Watch (ok)
  • [GULP] Gulp - Live Reload
  • [GULP] Gulp - Optimizing CSS and JavaScript
  • [GULP] Gulp - Optimizing Images
  • [GULP] Gulp - Useful Plugins
  • [GULP] Gulp - Cleaning Unwanted Files
  • Đọc thêm những tài liệu trang khác
  • ======= END GULP TUTORIAL ======
  • Prevent form submission on Enter key press, keyCode (ok)
  • Lấy kích thước ảnh gốc image (ok)
  • 😆How to Center Carousel Slider (ok)
  • Putting Dots onto Owl Carousel Instead of below specialtouchgifts.com.au (ok)
  • Cách xây dựng một Full Screen Carousel với Owl.js
  • Lazy load với owl.carousel.js (ok)
  • Show half of the other item on Owl Carousel vinmec.com items: 1.5 (ok)
  • Show half of the other item on Owl Carousel vinmec.com stagePadding (ok)
  • ------------ Start Fetch -----------
  • Using Fetch Full
  • 😅Javascript Fetch JSON PHP Complete FormData phần 1(ok)
  • Một ví dụ quá đỉnh lấy dữ liệu của form submit trong js bằng đối tượng new FormData + php phần 2(ok)
  • Có một sự thật sử dụng async đồng nghĩa với trả về kết quả là PROMISE (ok)
  • 😅Promise.all full (ok)
  • All you need to know about Promise.all
  • [PROMISE] Promise.all()
  • [PROMISE] Tìm hiểu về promise trong ES6
  • [PROMISE] Introduction to Promises
  • jQuery off() Method (ok)
  • How to make HTTP requests with Axios
  • Axios vs Fetch - 2020 nên sử dụng thằng nào với những tính năng mới trong javascript
  • Get and Post method using Fetch API (ok)
  • Sử dụng JavaScript Fetch API với Async/Await (ok)
  • Xử lý lỗi cho fetch trong trường hợp không có kết nối hoặc kết nối lâu (ok)
  • ------------ End Fetch -----------
  • BigDataCloud Free Reverse Geocoding Javascript API Client (ok)
  • Vietmap API
  • 🥰Sử dụng API Giao hàng Nhanh để tính giá cước vận chuyển (ok)
  • photonsearch as you type with OpenStreetMap map (ok)
  • Leaflet - Một thư viện JS mã nguồn mở cho việc xây dụng ứng dụng bản đồ map (ok)
  • Xây dựng popup lấy vị trí map áp dụng pointfinder (ok)
  • Reverse Geocoding Convert Lat Long to Address map (ok)
  • Free Reverse Geocoding Javascript API map (ok)
  • [YAML] In Action Tutorial Series - General - Hướng dẫn sử dụng file YML YAML cơ bản
  • ----------------- Start Notification -----------------
  • Đối tượng caches object caches (ok)
  • Notification (ok)
  • Sử dụng indexedDB (ok)
  • Using the Notifications API (ok)
  • NotificationEvent (chưa có ví dụ :((
  • ServiceWorkerGlobalScope.onnotificationclick (ok)
  • ServiceWorkerRegistration.getNotifications(ok)
  • ServiceWorkerRegistration.showNotification(ok)
  • Giao tiếp giữa các cửa sổ với Window.postMessage API (ok)
  • Window open() Method (ok)
  • ----------------- End Notification -----------------
  • Example Cookie full (ok)
  • Thay đổi class active javascript bằng cách viết hàm (P1)
  • Thay đổi class active javascript bằng cách viết hàm (P2)
  • jQuery Mockjax Plugin (chưa học cách sử dụng)
  • jQuery Ajax X-editable bootstrap plugin (chưa học cách sử dụng)
  • Lọc theo điều kiện (filter) (ok)
  • Các ví dụ về filter
  • jQuery | grep() Method (ok)
  • Hai bài toán so sánh kinh điển trong javascript
  • Function random :)
  • Một cách sử dụng tab trong theme newspaper
  • Hiệu ứng scroll + animation + menu trượt mượt
  • Trigger a CSS animation on scroll xuongkhopbacninh.vn (ok)
  • App Css Loaded (scroll create link) (ok)
  • Hiệu tứng scroll cực chất (ok)
  • App Js Loaded (ok)
  • Sử dụng async và defer full (Oke)
  • Cách sử dụng Thuộc tính async và defer trong JavaScript hay
  • ReferenceError: Can't find variable: requestAnimationFrame
  • Đoạn code check lỗi PHP trong Ajax
  • [SELECT2] Sử dụng Select2 để thay thế select boxes
  • Một cách sử dụng lazyload khi addclass thật khó khăn...
  • Hiệu ứng croll chuột và % cực đẹp :_
  • Tạo chức năng tự động hoàn tất nhập liệu với thư viện jQuery UI Autocomplete (Phần 1)
  • Tạo chức năng tự động hoàn tất nhập liệu với thư viện jQuery UI Autocomplete (Phần 2)
  • JavaScript String split() Method (OK)
  • Sử dụng thư viện displace để làm menu kéo thả (ok):)))
  • Menu cực chất :)))
  • Sử dụng thư viện slick (ok)
  • vertical scroll, Vertical carousel (ok)
  • Google-like Thanos disintegration (ok)
  • Dùng thư viện jspdf
  • Công thức Toán học cho website
  • Fix lỗi tự động làm thay đổi độ cao :( vieclam123.vn :(
  • Sử dụng window.addEventListener để resize và responsive <3
  • Javascript create, read, and delete cookies (ok)
  • Tự động submit bằng javscript :))) (ok)
  • avoid form warning if user clicks refresh (ok)
  • Một cách truy cập phần tử bằng js thông qua id lạ :)))
  • Meta Refresh
  • Truyền dữ liệu từ javascript sang php
    • Sử dụng form để truyền sang php (ok)
    • Truyền giá trị theo file bằng đường dẫn (ok)
    • Dùng json để truyền sang php
  • auto-refresh page once only after first load – Using JavaScript / JQuery
    • auto-refresh page once only after first load – Using JavaScript / JQuery (ok)
  • Sticky Scroller
    • Sticky Scroller phần 1 (ok)
    • Sticky Scroller phần 2 (ok)
    • owl carousel with dotsContainer (Dots + Text) (ok)
    • Owl Carousel 2 Thumbnails plugin (ok)
  • easy_background Background Slideshow (ok) dev.vieclam123.vn
  • scroll cực chất timviec365.vn, vieclam123.vn (ok)
  • Thư viện lightslider-master gần giống với Owl Carousel
  • Thư viện lightGallery để làm những bộ Sưu tập Gallery
  • Tự viết click slide (ok)
  • Draggable & Touch-friendly Slider Carousel In Pure JS (ok)
  • Slider owl được viết dưới dạng Thumnail (0k)
  • jquery.js:5092 [Violation] Added non-passive event listener to a scroll-blocking 'touchstart' (ok)
  • Added non-passive event listener to a scroll-blocking 'touchstart' event (ok)
  • sticky-mobile-menu-burger-menu (ok)
  • How can I add class to the first and last item among the visible items of Owl Carousel 2? (ok)
  • Owl-carousel2 DEMO - items in 2 rows (oke)
  • How can I create a carousel slick with multiple rows? (ok)
  • Một cách sử dụng create <style> để thêm style (ok)
  • Two Rows Olw Carousel (ok) vieclam123.vn
  • Chức năng tự gọi Javascript (ok) tự động auto
  • Click Next Javascript Base (ok)
  • Slider owl được viết dưới dạng Thumnail viết trên jsfiddle (0k)
  • 😆Creating a Countdown Timer, dakhoathienhoa.com.vn (oK)
  • 🥸NumScroller, Counter From Zero To Value - Javascript Animation (ok)
  • Click Button background-hover white (ok)
  • CodePen HomeLazy Loading Images (Ok)
  • Custom Date Javasript (job247.vn)
  • Tooltip
  • button thay đổi thẻ tags button và span trong Owl Carousel thành thẻ khác :)) (ok)
  • Thêm class vào navigation Owl Carousel (ok)
  • Click lần đầu sử event.preventDefault(); lầu sau not event.preventDefault();
  • landscape && landscape (ok)
  • Landscape && Portrait (ok) job247.vn
  • Hammer thư viện JavaScript chạm cho màn hình cảm ứng
  • jQuery Plugin To Add CSS3 Scrolling Effects On Your Web Page - Smoove menu (ok)
  • 😃Auto Expanding Table Of Contents Plugin - Dynamic Content menu (ok)
  • Tornis - watch and respond
  • scroll-manager
  • Xem thêm
  • Hướng dẫn nấu món "Lazy loading image" theo chuẩn 5 sao Google
  • Welcome to jquery-confirm!
    • jQuery Message Box Plugin Demo Page
  • Magnific-Popup Popup img
  • Slider Swiper Slider-Swiper dùng viết slider giống app
  • Magnific Popup Documentation
  • filter search (ok)
  • Is it possible to convert a select menu to buttons? (ok)
  • Changing selected option on button click select (ok) homef.vn hoặc inop.vyanh.net
  • scrooll animation (job247.vn) (ok)
  • Select2 tutorial
    • Single select boxes (ok)
  • [SELECT2] Disabling a Select2 control (ok)
  • Disabling options (ok)
  • placeholder (ok)
  • Hiển thị nút xóa các giá trị đã chọn + allowClear (ok)
  • Đọc dữ liệu từ một mảng, Data sources (ok)
  • Sử dụng database + php (ok)
  • [SELECT2] Sử dụng form + select2 + ajax + get value (ok)
  • Đọc dữ liệu từ nguồn khác sử dụng AJAX (ok)
  • Thiết lập giá trị mặc định ban đầu trên HTML như bình thường (ok)
  • Sử dụng Ajax để tải dữ liệu từ một nguồn khác (ok)
  • change form
Powered by GitBook
On this page
  • Hover 1
  • Hover 2

Was this helpful?

Sử dụng thư viện jquery.hoverdir.js để làm hiệu ứng hover tuyệt đẹp (ok)

https://github.com/webmandesign/jquery.hoverdir

PreviousremoveDuplicates, Remove duplicate values from JS array, remove all duplicates an array object (ok)NextModernizr là gì ? Sử dụng nó cho những trình duyệt cũ ra sao? (ok)

Last updated 1 year ago

Was this helpful?

Một ví dụ thực hành :)

C:\Users\Administrator\OneDrive\Desktop\web\test.html

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <script src="js/jquery.min.js"></script>
  <!-- <script src="js/modernizr.js"></script> -->
  <script type="text/javascript" src="js/jquery.hoverdir.js"></script>
  <title>Document</title>
  <style type="text/css">
  .da-thumbs {
    list-style: none;
    width: 984px;
    height: 600px;
    position: relative;
    margin: 20px auto;
    padding: 0;
  }
  .da-thumbs li {
    float: left;
    margin: 0.4%;
    background: #EFEFEF;
    padding: 8px;
    position: relative;
    box-shadow: 0 1px 3px rgb(231 231 231 / 43%);
    width: 32.4%;
  }
  .da-thumbs li a {
    overflow: hidden;
  }
  .da-thumbs li a,
  .da-thumbs li a img {
    display: block;
    position: relative;
  }
  .da-thumbs li a div {
    position: absolute;
    background: #333;
    background: rgba(75, 75, 75, 0.7);
    width: 100%;
    height: 100%;
  }
  .da-thumbs li a div h5 {
    color: #FFF;
    font-size: 1.5em;
    margin: 3.5em 0 0 0;
    font-family: 'Audiowide-Regular';
    text-align: center;
  }
  .da-thumbs li a div span {
    display: block;
    padding: 10px 0;
    margin: 11px 20px 20px 20px;
    font-weight: normal;
    text-transform: capitalize;
    color: rgba(255, 255, 255, 0.9);
    text-align: center;
    font-size: 14px;
    font-family: 'Raleway-Regular';
  }
  </style>
</head>
<body>
  <section>
    <ul id="da-thumbs" class="da-thumbs">
      <li>
        <a href="images/g-1.jpg" rel="title" class="b-link-stripe b-animate-go  thickbox">
          <img src="images/g-1.jpg" alt="" />
          <div>
            <h5>Coffee</h5>
            <span>non suscipit leo fringilla non suscipit leo fringilla molestie</span>
          </div>
        </a>
      </li>
      <li>
        <a href="images/g-2.jpg" rel="title" class="b-link-stripe b-animate-go  thickbox">
          <img src="images/g-2.jpg" alt="" />
          <div>
            <h5>Coffee</h5>
            <span>non suscipit leo fringilla non suscipit leo fringilla molestie</span>
          </div>
        </a>
      </li>
      <li>
        <a href="images/g-3.jpg" rel="title" class="b-link-stripe b-animate-go  thickbox">
          <img src="images/g-3.jpg" alt="" />
          <div>
            <h5>Coffee</h5>
            <span>non suscipit leo fringilla non suscipit leo fringilla molestie</span>
          </div>
        </a>
      </li>
      <li>
        <a href="images/g-4.jpg" rel="title" class="b-link-stripe b-animate-go  thickbox">
          <img src="images/g-4.jpg" alt="" />
          <div>
            <h5>Coffee</h5>
            <span>non suscipit leo fringilla non suscipit leo fringilla molestie</span>
          </div>
        </a>
      </li>
      <li>
        <a href="images/g-5.jpg" rel="title" class="b-link-stripe b-animate-go  thickbox">
          <img src="images/g-5.jpg" alt="" />
          <div>
            <h5>Coffee</h5>
            <span>non suscipit leo fringilla non suscipit leo fringilla molestie</span>
          </div>
        </a>
      </li>
      <li>
        <a href="images/g-6.jpg" rel="title" class="b-link-stripe b-animate-go  thickbox">
          <img src="images/g-6.jpg" alt="" />
          <div>
            <h5>Coffee</h5>
            <span>non suscipit leo fringilla non suscipit leo fringilla molestie</span>
          </div>
        </a>
      </li>
      <li>
        <a href="images/g-7.jpg" rel="title" class="b-link-stripe b-animate-go  thickbox">
          <img src="images/g-7.jpg" alt="" />
          <div>
            <h5>Coffee</h5>
            <span>non suscipit leo fringilla non suscipit leo fringilla molestie</span>
          </div>
        </a>
      </li>
      <li>
        <a href="images/g-8.jpg" rel="title" class="b-link-stripe b-animate-go  thickbox">
          <img src="images/g-8.jpg" alt="" />
          <div>
            <h5>Coffee</h5>
            <span>non suscipit leo fringilla non suscipit leo fringilla molestie</span>
          </div>
        </a>
      </li>
      <li>
        <a href="images/g-9.jpg" rel="title" class="b-link-stripe b-animate-go  thickbox">
          <img src="images/g-9.jpg" alt="" />
          <div>
            <h5>Coffee</h5>
            <span>non suscipit leo fringilla non suscipit leo fringilla molestie</span>
          </div>
        </a>
      </li>
      <div class="clearfix"> </div>
    </ul>
  </section>
  <script type="text/javascript">
  $(function() {
    $(' #da-thumbs > li ').each(function() { $(this).hoverdir(); });
  });
  </script>
</body>
</html>
<div class="da-thumbs">
  
  <div>
    <a href="#">
      <img src="https://cdn.shopify.com/s/files/1/1047/8278/products/electric-toy-car-bmw-x5_large.png?v=1449651980" />
      <div>hover image 1</div>
    </a>
  </div>
  
  <div>
    <a href="#">
      <img src="https://cdn.shopify.com/s/files/1/1047/8278/products/electric-toy-car-bmw-x5_large.png?v=1449651980" />
      <div>hover image 2</div>
    </a>
  </div>
  
  <div>
    <a href="#">
      <img src="https://cdn.shopify.com/s/files/1/1047/8278/products/electric-toy-car-bmw-x5_large.png?v=1449651980" />
      <div>hover image 3</div>
    </a>
  </div>

  <div>
    <a href="#">
      <img src="https://cdn.shopify.com/s/files/1/1047/8278/products/electric-toy-car-bmw-x5_large.png?v=1449651980" />
      <div>hover image 4</div>
    </a>
  </div>
  
  <div>
    <a href="#">
      <img src="https://cdn.shopify.com/s/files/1/1047/8278/products/electric-toy-car-bmw-x5_large.png?v=1449651980" />
      <div>hover image 5</div>
    </a>
  </div>
  
  <div>
    <a href="#">
      <img src="https://cdn.shopify.com/s/files/1/1047/8278/products/electric-toy-car-bmw-x5_large.png?v=1449651980" />
      <div>hover image 6</div>
    </a>
  </div>
  
</div>
.da-thumbs {
	position: relative;
  width: 800px;
	margin: 20px auto;
	padding: 0;
}
.da-thumbs > div {
  float: left;
  background-color: #eee;
  margin: 5px;
  padding: 3px;
	position: relative;
}
.da-thumbs > div a,
.da-thumbs > div a img {
	display: block;
	position: relative;
}
.da-thumbs > div a {
	overflow: hidden;
}
.da-thumbs > div a img {
	height: 200px;
}
.da-thumbs > div a div {
	position: absolute;
	width: 100%;
	height: 100%;
	background: rgba(60, 60, 60, 0.7);
  color: #fff;
  display: flex;
  justify-content: center;
  align-items: center
}
$(function () {
  $('.da-thumbs > div').hoverdir();
});

// external js file

(function (factory) {
  'use strict';
  if (typeof define === 'function' && define.amd) {
    define(['jquery'], factory);
  } else if (typeof exports !== 'undefined') {
    module.exports = factory(require('jquery'));
  } else {
    factory(jQuery);
  }
})(function ($) {
  'use strict';

  function Hoverdir(element, options) {
    this.$el = $(element);
    // set options
    this.options = $.extend(true, {}, this.defaults, options);
    // initialize visibility to false for show and hide method
    this.isVisible = false;
    // get the hover for this element
    this.$hoverElem = this.$el.find(this.options.hoverElem);
    // transition properties
    this.transitionProp = 'all ' + this.options.speed + 'ms ' + this.options.easing;
    // support for CSS transitions
    this.support = this._supportsTransitions();
    // load the events
    this._loadEvents();
  }

  Hoverdir.prototype = {
    defaults: {
      speed: 300,
      easing: 'ease',
      hoverDelay: 0,
      inverse: false,
      hoverElem: 'div'
    },
    constructor: Hoverdir,
    /**
         * Detect if CSS transitions are supported
         *
         * @return {Boolean}
         */
    _supportsTransitions: function () {
      if (typeof Modernizr !== 'undefined') {
        return Modernizr.csstransitions;
      } else {
        var b = document.body || document.documentElement,
            s = b.style,
            p = 'transition';

        if (typeof s[p] === 'string') {
          return true;
        }

        // Tests for vendor specific prop
        var v = ['Moz', 'webkit', 'Webkit', 'Khtml', 'O', 'ms'];
        p = p.charAt(0).toUpperCase() + p.substr(1);

        for (var i = 0; i < v.length; i++) {
          if (typeof s[v[i] + p] === 'string') {
            return true;
          }
        }

        return false;
      }
    },
    /**
         * Bind the events to the element
         */
    _loadEvents: function () {
      this.$el.on('mouseenter.hoverdir mouseleave.hoverdir', $.proxy(function (event) {
        this.direction = this._getDir({x: event.pageX, y: event.pageY});

        if (event.type === 'mouseenter') {
          this._showHover();
        }
        else {
          this._hideHover();
        }
      }, this));
    },
    /**
         * Show the hover of the element
         */
    _showHover: function () {
      var styleCSS = this._getStyle(this.direction);

      if (this.support) {
        this.$hoverElem.css('transition', '');
      }

      this.$hoverElem.hide().css(styleCSS.from);
      clearTimeout(this.tmhover);

      this.tmhover = setTimeout($.proxy(function () {
        this.$hoverElem.show(0, $.proxy(function () {
          if (this.support) {
            this.$hoverElem.css('transition', this.transitionProp);
          }
          this._applyAnimation(styleCSS.to);

        }, this));
      }, this), this.options.hoverDelay);

      this.isVisible = true;
    },
    /**
         * Hide the hover to the element
         */
    _hideHover: function () {
      var styleCSS = this._getStyle(this.direction);
      if (this.support) {
        this.$hoverElem.css('transition', this.transitionProp);
      }
      clearTimeout(this.tmhover);
      this._applyAnimation(styleCSS.from);
      this.isVisible = false;
    },
    /**
         * get the direction when the event is triggered
         * credits : http://stackoverflow.com/a/3647634
         *
         * @param {Object} coordinates
         * @returns {Interger}
         */
    _getDir: function (coordinates) {
      // the width and height of the current div
      var w = this.$el.width(),
          h = this.$el.height(),
          // calculate the x and y to get an angle to the center of the div from that x and y.
          // gets the x value relative to the center of the DIV and "normalize" it
          x = (coordinates.x - this.$el.offset().left - (w / 2)) * (w > h ? (h / w) : 1),
          y = (coordinates.y - this.$el.offset().top - (h / 2)) * (h > w ? (w / h) : 1),
          // the angle and the direction from where the mouse came in/went out clockwise (TRBL=0123);
          // first calculate the angle of the point,
          // add 180 deg to get rid of the negative values
          // divide by 90 to get the quadrant
          // add 3 and do a modulo by 4 to shift the quadrants to a proper clockwise TRBL (top/right/bottom/left) **/
          direction = Math.round((((Math.atan2(y, x) * (180 / Math.PI)) + 180) / 90) + 3) % 4;
      return direction;
    },
    /**
         * get the style when the event is triggered
         *
         * @param {(Interger|String)} direction
         * @returns {Object}
         */
    _getStyle: function (direction) {
      var fromStyle, toStyle,
          slideFromTop = {'left': '0', 'top': '-100%'},
          slideFromBottom = {'left': '0', 'top': '100%'},
          slideFromLeft = {'left': '-100%', 'top': '0'},
          slideFromRight = {'left': '100%', 'top': '0'},
          slideTop = {'top': '0'},
          slideLeft = {'left': '0'};

      switch (direction) {
        case 0:
        case 'top':
          // from top
          fromStyle = !this.options.inverse ? slideFromTop : slideFromBottom;
          toStyle = slideTop;
          break;
        case 1:
        case 'right':
          // from right
          fromStyle = !this.options.inverse ? slideFromRight : slideFromLeft;
          toStyle = slideLeft;
          break;
        case 2:
        case 'bottom':
          // from bottom
          fromStyle = !this.options.inverse ? slideFromBottom : slideFromTop;
          toStyle = slideTop;
          break;
        case 3:
        case 'left':
          // from left
          fromStyle = !this.options.inverse ? slideFromLeft : slideFromRight;
          toStyle = slideLeft;
          break;
      }

      return {from: fromStyle, to: toStyle};
    },
    /**
         * Apply a transition or fallback to jquery animate based on Modernizr.csstransitions support
         *
         * @param {Object} styleCSS
         */
    _applyAnimation: function (styleCSS) {
      $.fn.applyStyle = this.support ? $.fn.css : $.fn.animate;
      this.$hoverElem.stop().applyStyle(styleCSS, $.extend(true, [], {duration: this.options.speed}));
    },
    /**
         * Show $hoverElem from the direction in argument
         *
         * @param {String} [direction=top] direction
         */
    show: function (direction) {
      this.$el.off('mouseenter.hoverdir mouseleave.hoverdir');
      if (!this.isVisible) {
        this.direction = direction || 'top';
        this._showHover();
      }
    },
    /**
         * Hide $hoverElem from the direction in argument
         *
         * @param {String} [direction=bottom] direction
         */
    hide: function (direction) {
      this.rebuild();
      if (this.isVisible) {
        this.direction = direction || 'bottom';
        this._hideHover();
      }
    },
    setOptions: function (options) {
      this.options = $.extend(true, {}, this.defaults, this.options, options);
    },
    /**
         * Unbinds the plugin.
         */
    destroy: function () {
      this.$el.off('mouseenter.hoverdir mouseleave.hoverdir');
      this.$el.data('hoverdir', null);
    },
    /**
         * Bind the plugin.
         */
    rebuild: function (options) {
      if (typeof options === 'object') {
        this.setOptions(options);
      }
      this._loadEvents();
    }
  };

  $.fn.hoverdir = function (option, parameter) {
    return this.each(function () {
      var data = $(this).data('hoverdir');
      var options = typeof option === 'object' && option;

      // Initialize hoverdir.
      if (!data) {
        data = new Hoverdir(this, options);
        $(this).data('hoverdir', data);
      }

      // Call hoverdir method.
      if (typeof option === 'string') {
        data[option](parameter);

        if (option === 'destroy') {
          $(this).data('hoverdir', false);
        }
      }
    });
  };

  $.fn.hoverdir.Constructor = Hoverdir;
});

Hover 2
Hover 1
5KB
jquery.hoverdir.js