Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. /* globals jQuery, Modernizr */
  2. 'use strict'
  3.  
  4. jQuery(function ($) {
  5. var productImageHover = function () {
  6. if (!Modernizr.touchevents) {
  7. // Using mouseenter / mouserleave incase of ajaxy stuff
  8. $(document).on('mouseenter mouseleave', '.c-image img', function () {
  9. var swapImg = this.getAttribute('data-swap-src')
  10. var img = this.getAttribute('src')
  11. $(this).attr('src', swapImg)
  12. $(this).attr('data-swap-src', img)
  13. }, function () {
  14. var swapImg = this.getAttribute('data-swap-src')
  15. var img = this.getAttribute('src')
  16. $(this).attr('src', swapImg)
  17. $(this).attr('data-swap-src', img)
  18. })
  19. }
  20. }
  21.  
  22. // Call on resize
  23. $(window).resize(function () {
  24. productImageHover()
  25. })
  26. // Call on ready
  27. productImageHover()
  28.  
  29. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement