Skip to content

Instantly share code, notes, and snippets.

@r-isayev-parc
Created May 23, 2012 11:44
Show Gist options
  • Save r-isayev-parc/2774755 to your computer and use it in GitHub Desktop.
Save r-isayev-parc/2774755 to your computer and use it in GitHub Desktop.
avatarCreateCash: function() {
var items = $('.js-feed-item').find('.js-feed-item-icon-content');
this.iconAvatarCash = [];
for (var i=0, len = items.length; i < len; i++) {
this.iconAvatarCash.push(items.eq(i));
}
},
// Обработчик наведения курсора мыши на аватарку (плавное смещение фона при движении курсора мыши над аватаркой)
avatarHoverEvent: function(e) {
var $this = $(e.currentTarget),
offset = $this.offset(),
side = this.avatarsSide,
x = e.pageX - Math.floor(offset.left),
y = e.pageY - Math.floor(offset.top),
percentX = Math.round(x / side * 100),
percentY = Math.round(y / side * 100),
dataType = $this.attr('data-type'),
index = $this.index();
if (dataType != 'total') {
$(this.iconAvatarCash[intex]).css('background-position', percentX + '% ' + percentY + '%');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment