Zdravím, robím pre jeden web animované menu kde sa posúva ukazovateľ podla položky nad ktorou je myš alebo aktívnu keď zase prejde používate+ mimo oblasť položky menu. No nastal mi problém pri IE9 (v iných IE verziách som zatiaľ neskúšal) , že každú animáciu začína od nuly a nie aktívneho umiestnenia elementu (pri ostatných prehliadačoch to funguje dobre).
Kód:
function change_selector_position(element){
$("#menu_selector").clearQueue();
$("#menu_selector").stop();
style = window.getComputedStyle(element);
width = parseInt(style.getPropertyValue('width'));
element_offset = parseInt(element.offsetLeft);
wrapper_offset = parseInt(document.getElementById('menu_wrapper').offsetLeft);
//Predchádzajúce hodnoty
var position_x = ((element_offset - wrapper_offset) - 371) + ((width / 2) - 8);
var now = $("#menu_selector").css('background-position');
now = now.split(' ');
nowX = parseInt(now[0]);
$('#menu_selector').animate({
'background-position-x': position_x+'px',
},{
step: function(nowX, fx){
$(fx.elem).css('background-position', nowX+"px 13px");
}
}, {
duration: 500
}
);
$('#top_menu2').append("Pozícia x: "+position_x+"px, now: "+nowX);
}
function selector_activ_element(){
$("#menu_selector").clearQueue();
var now = $("#menu_selector").css('background-position');
now = now.split(' ');
nowX = parseInt(now[0]);
$('#menu_selector').animate({
'background-position-x': x+'px',
},{
step: function(nowX, fx){
$(fx.elem).css('background-position', nowX+"px 13px");
}
}, {
duration: 500
}
);
}
function select_activ_element(){
$("#menu_selector").clearQueue();
width = parseFloat($('.activ').css('width'));
element_offset = parseInt($('.activ').offset().left);
wrapper_offset = parseInt($('#menu_wrapper').offset().left);
position_x2 = ((element_offset - wrapper_offset) - 371) + ((width / 2) - 8);
x = position_x2;
var now = $("#menu_selector").css('background-position');
now = now.split(' ');
nowX = parseInt(now[0]);
$('#menu_selector').animate({
'background-position-x': position_x2+'px',
},{
step: function(nowX, fx){
$(fx.elem).css('background-position', nowX+"px 13px");
}
}, {
duration: 500
}
);
}