Created
May 21, 2015 19:02
-
-
Save dkruchok/813a41adfee0e93cf844 to your computer and use it in GitHub Desktop.
My custom slider for current picture
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
var small = $(".from litle a img"), | |
big = $(".to big img"); | |
small.each(function(i, el) { | |
var next = i + 1 == small.size() ? 0 : i + 1; | |
$(el) | |
.click( | |
function(event) { | |
event.preventDefault(); | |
if (big.data("next") == next) return; | |
big.fadeTo(500, 0.1, function() { | |
big.attr({ | |
"src": $(el) | |
.parent() | |
.attr("href") | |
}) | |
.data({ | |
"next": next | |
}); | |
}); | |
big.fadeTo(800, 1); | |
} | |
) | |
}); | |
big.data({ | |
"next": 1 | |
}) | |
.click(function(event) { | |
small.eq($(this) | |
.data("next")) | |
.click() | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment