Giter Club home page Giter Club logo

theharq / jquery-anystretch Goto Github PK

View Code? Open in Web Editor NEW

This project forked from danmillar/jquery-anystretch

0.0 2.0 0.0 1.63 MB

Anystretch is a jQuery plugin that allows you to add a dynamically-resized background image to any page or block level element. The image will stretch to fit the page/element, and will automatically resize as the window size changes.

Home Page: http://static.elliotjaystocks.com/responsive-background-images/examples/solution.html

License: GNU General Public License v2.0

jquery-anystretch's Introduction

jQuery Anystretch

Anystretch is a jQuery plugin that allows you to add a dynamically-resized background image to any page or block level element.
The image will stretch to fit the page/element, and will automatically resize as the window size changes.

Demo

An example is provided within this package. To see it in action go to: http://wearyoubelong.com

Options

positionX

This parameter controls how we position the image on the X axis. (type=String, options=left|center|right, default=center)

positionY

This parameter controls how we position the image on the Y axis. (type=String, options=top|center|bottom, default=center)

speed

This is the speed at which the image will fade in, after downloading is complete. Integers are accepted, as well as standard jQuery speed strings (slow, normal, fast). (type=Integer, default=0)

elPosition (only when not used on the body)

This is the css position given to the containing element when used on anything except the body. (type=String, default=relative)

Setup

Include the jQuery library and Anystretch plugin files in your webpage (preferably at the bottom of the page, before the closing BODY tag):

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="/jquery.anystretch.min.js"></script>

Note: The example above uses the Google hosted version of jQuery; there is also a jQuery source file included with this distribution, if you would like to host it yourself.

<script type="text/javascript">
  $.anystretch("/path/to/image.jpg", {speed: 150});
</script>

Want to change the image after Anystretch has been loaded? No problem, just call it again!

<script type="text/javascript">
  $.anystretch("/path/to/image.jpg", {speed: 150});
  
  // Perhaps you'd like to change the image on a button click
  $(".button").click(function() {
      $.anystretch("/path/to/next_image.jpg");
  });
</script>

If you require Anystretch to work on one or more elements inside the page, rather than the page itself, simply call it on the element:

<script type="text/javascript">
  $('#myDiv').anystretch("/path/to/image.jpg", {speed: 150});
</script>

Changelog

Version 1.1

  • Changed options from centeredX/centeredY to positionX/positionY to allow for greater control

Version 1.0

  • This was forked from Backstretch (version 1.2)

jquery-anystretch's People

Contributors

srobbin avatar danmillar avatar mattcrest avatar vondruska avatar

Watchers

James Cloos avatar Hildebrando Rueda avatar

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.