Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* globals jQuery, Modernizr */
- 'use strict'
- jQuery(function ($) {
- var productImageHover = function () {
- if (!Modernizr.touchevents) {
- // Using mouseenter / mouserleave incase of ajaxy stuff
- $(document).on('mouseenter mouseleave', '.c-image img', function () {
- var swapImg = this.getAttribute('data-swap-src')
- var img = this.getAttribute('src')
- $(this).attr('src', swapImg)
- $(this).attr('data-swap-src', img)
- }, function () {
- var swapImg = this.getAttribute('data-swap-src')
- var img = this.getAttribute('src')
- $(this).attr('src', swapImg)
- $(this).attr('data-swap-src', img)
- })
- }
- }
- // Call on resize
- $(window).resize(function () {
- productImageHover()
- })
- // Call on ready
- productImageHover()
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement