Last active
August 29, 2015 14:06
-
-
Save SomeoneWeird/00e4a94dbe8acff691d0 to your computer and use it in GitHub Desktop.
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
$(document).ready(function() { | |
var directions = { | |
'east': { | |
value: 1, | |
class: 'fromWest' | |
}, | |
'southeast': { | |
value: 4, | |
class: 'fromNorthwest' | |
}, | |
'south': { | |
value: 3, | |
class: 'fromNorth' | |
}, | |
'southwest': { | |
value: 2, | |
class: 'fromNorthEast' | |
}, | |
'west': { | |
value: -1, | |
class: 'fromEast' | |
} | |
} | |
$('.block').each(function() { | |
$(this).removeAttr('direction'); | |
var dirs = $(this).attr('direction').split(' '); | |
var index = $('.block').index(this); | |
for(var i = 0; i < dirs.length; i++) { | |
var dir = dirs[i]; | |
var direction = directions[dir]; | |
if(!dir) { | |
$(this).append('<span class="arrow ' + dir + '"></span>'); | |
} | |
var id = index + direction.value; | |
$('.block:eq(' + id + ')').append('<span class="arrow ' + direction.class + '"></span>');; | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment