Skip to content
based on jQuery
CoffeeScript CSS JavaScript
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
test
.travis.yml
LICENSE license & travis-ci
README.md
background.coffee
background.js
background.min.js
bower.json

README.md

Background JS

Build Status

Introduction

this is an awesome plugin that makes your website background move when scrolling, that's hard to describe, you can visit these websites to see the effect:

and you can assgin multiple background images by json and it will change automatically by time!

Requirements

  • jQuery ~> 1.7

Installation

Bower

bower install background.js

Gem

gem install rails-assets-background.js --source https://rails-assets.org

Demonstration Effect

Please visit

Without Background.js
before
With Background.js
after

Usage

Example

first, load jQuery and the plugin, Zepto.js can also support this plugin.

<script src="http://code.jquery.com/jquery-1.11.0.min.js" type="text/javascript"></script>
<script src="http://fr0m.github.io/background.js/background.min.js" type="text/javascript"></script>

just do this.

body { background-image: url("http://i1.ihaveu.net/image/auction/picture/000/053/564/path/16dd7c4e.jpg"); }
$(function(){
  Background.tick();
});

or an image url can be used.

$(function(){
  Background.tick({imageUrl:"http://i1.ihaveu.net/image/auction/picture/000/053/564/path/16dd7c4e.jpg"});
});

string in format of json is also acceptable.

$(function(){
  var json = {
    "backgrounds" : [
      {
        "started_at":"00:00:00",
        "ended_at":"24:00:00",
        "image":"http://i1.ihaveu.net/image/auction/picture/000/053/564/path/16dd7c4e.jpg",
        "color":"#fff"
      }
    ] 
  };
});
Background.tick({json:json});

an url return in format of json is acceptable as well.

$(function(){
  Background.tick({jsonString:"http://fr0m.github.io/background.js/test/test.json"});
});

and a callback function is supported

$(function(){
  Background.tick({jsonString:"http://fr0m.github.io/background.js/test/test.json"},function(){
    alert("done!");
  });  
});

Documentation

Credits

License

Copyright © 2014 He Liu gilbert.fr0m@gmail.com under The MIT License.

Something went wrong with that request. Please try again.