Git Product home page Git Product logo

backgroundpos's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

backgroundpos's Issues

Resize browser issue

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?

passing position as variable

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!

Major bugfix -

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;

}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.