kbwood / backgroundpos Goto Github PK
View Code? Open in Web Editor NEWjQuery Background Position Plugin
jQuery Background Position Plugin
Hello,
When I resize the browser part of the image gets cut off. Is this a bug or is this something that can't be fix?
Hey there. I'm trying to pass the background position from a variable. Here is the basic idea of what I am trying to do:
background1 = " '-362px 0' ";
background2 = " '-678px 0' ";
$('#bg1').parent().stop().animate({backgroundPosition:background1},200);
$('#bg2').parent().stop().animate({backgroundPosition:background2},300);
I receive the following error "Cannot read property '1' of null ." It seems like the variable is not being parsed by the pluggin.
To my knowledge this is the syntax to use variables with the default jQuery animate function. Any insight into this would be fantastic!
function parseBackgroundPosition(value) {
var bgPos = (value || '').split(/ /);
// Start of major bugfix
if (bgPos.length === 4) {
bgPos.splice(0, 1);
bgPos.splice(1, 1);
}
// End of major bugfix
var presets = {center: '50%', left: '0%', right: '100%', top: '0%', bottom: '100%'};
var decodePos = function(index) {
var pos = (presets[bgPos[index]] || bgPos[index] || '50%').
match(/^([+-]=)?([+-]?\d+(\.\d*)?)(.*)$/);
bgPos[index] = [pos[1], parseFloat(pos[2]), pos[4] || 'px'];
};
if (bgPos.length == 1 && $.inArray(bgPos[0], ['top', 'bottom']) > -1) {
bgPos[1] = bgPos[0];
bgPos[0] = '50%';
}
decodePos(0);
decodePos(1);
return bgPos;
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.