Created
April 28, 2015 11:01
-
-
Save willcalderbank/b997568b61662853ce71 to your computer and use it in GitHub Desktop.
switchSrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
switchSrc: function(overlayId, src, duration) { | |
var $original = $('#' + overlayId); | |
$newElement = $original.clone(); | |
$newElement.removeAttr('id'); | |
$newElement.css({opacity: 0, background: 'url(' + src + ')'}); | |
$original.after($newElement); | |
if (duration === undefined) { | |
duration = 200; | |
} | |
$newElement.velocity({opacity: 1}, {duration: duration, complete: function() { | |
$original.css('background', 'url(' + src + ')'); | |
$newElement.remove(); | |
}}); | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Switches divs background with a smooth transition