0.1.0 • Published 7 years ago
jquery-hs-unsplash v0.1.0
jquery-HS-unsplash
jQuery plugin to change a full background image from Unsplash
Installation
npm install jquery-HS-unsplashLoad
<script src="/node_modules/jquery/dist/jquery.js"></script>
<script src="/node_modules/jquery-HS-unsplash/dist/index.js"></script>Usage
Create a container where you want to set a full background image(div, section, article, etc.)
<div id="full-bg-random"></div>Before using the Unsplash API, you need to register as a developer. You must put the CLIENT_ID in order to be enable to get photos from Unsplash API.
window.hsUnsplash.setup(clientId);Call the plugin:
$(document).ready(function(){
window.hsUnsplash.setup(clientId);
// get random photo
$('#full-bg-random').hsUnsplash({
backgroundcolor: 'red';
});
});Options
By default the plugin use some values:
{
height: '100vh',
width: '100%',
minHeight: '800px',
backgroundSize: 'cover',
backgroundPosition: 'center',
backgroundColor: 'black'
}You can override them:
$('#full-bg-random').hsUnsplash({
minHeight: '900px',
backgroundSize: 'contain'
});In case that endpoint of Unsplash responses with errors, you can set an image(this only is visible when Unsplash endpoint fails):
$('#full-bg-random').hsUnsplash({
backgroundImage: 'path/image.jpg'
});Testing
This will build scripts, run tests and generate a code coverage report. Anything less than 100% coverage will throw an error.
npm testContributing
- ⇄ Pull requests and ★ Stars are always welcome.
- For bugs and feature requests, please create an issue.
- Pull requests must be accompanied by passing automated tests (
npm test).
0.1.0
7 years ago