Passing variables into jquery css background position -


i trying animate background image whilst scrolling. seems working, exception of actual animation.

$(window).scroll(function() { backgroundpos = $('#home_logging_mining').css('backgroundposition').split(' '); x_pos = parseint(backgroundpos[0]); y_pos = parseint(backgroundpos[1]); pos = $(this).scrolltop(); if(pos>450) {     //$('#scroll_logo').html(pos);     pos2 = pos-450;     if(pos2<=40) {         new_x = x_pos + pos2;         new_y = y_pos + pos2;         $('#scroll_logo').html(new_y + ' ' + new_x);         $('#home_logging_mining').css('background-position', new_x+'px'+new_y+'px');       } }  }); 

i can view variable being passed through, , should be. have tested element different background actual integers rather variables, , works fine. if set variables integers, stops working. suspect in way passing variables css() function incorrectly. there obvious missing?

your new css value needs space in middle; background-position being set (e.g.) "5px10px" instead of "5px 10px".

 $('#home_logging_mining').css('background-position', new_x+'px '+new_y+'px');  

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -