Giter Site home page Giter Site logo

tvler / thathalfdropimagegridfromtheroyaltenenbaums.js Goto Github PK

View Code? Open in Web Editor NEW
9.0 3.0 0.0 2.16 MB

Repeat an HTML element's background image in a centered half-drop pattern, like that thing from that movie

Home Page: http://tylerdeitz.co/ThatHalfDropImageGridFromTheRoyalTenenbaums.js

License: MIT License

JavaScript 61.25% CSS 18.84% HTML 19.90%
wes-anderson half-drop

thathalfdropimagegridfromtheroyaltenenbaums.js's Introduction

That Half-Drop Image Grid From
The Royal Tenenbaums
. JavaScript

###Download (minified)

offset grid example

A brand-new JavaScript file for repeating an HTML element's background image in a centered half-drop pattern, like that thing (1, 2, 3) from that movie. Each pattern is customizable through JSON data attributes, with properties based off CSS naming standards.

3 Ways To Use

1. HTML + inline URL
<figure
  data-halfdrop = 'wes1.jpg'
></figure>
2. HTML + CSS URL
figure {
  background: url('wes1.jpg')
}
<figure
  data-halfdrop
></figure>
3. HTML + JSON
<figure
  data-halfdrop = '{
    "src"      : "wes1.jpg",
    "width"    : "20%",
    "maxWidth" : 200
  }'
></figure>

Default values

_halfdrop.defaultValues = {
  "src"       : "",
  // String of the image's URL
  // (If not given, CSS URL will be used)

  "snap"      : false,
  // Changes width of image to create a whole number of columns, only respecting one min/max property

  "minWidth"  : 0,
  "maxWidth"  : "100%",
  "width"     : 0,
  "minHeight" : 0,
  "maxHeight" : "100%",
  "height"    : 0
  // Can be a number or string ending in 'px' or '%'
}

##2 Steps To Run

1. Link the javascript file
<script src="ThatHalfDropImageGridFromTheRoyalTenenbaums.js"></script>

This creates the object _halfdrop

2. Set an event to update the background
_halfdrop.update()
// When a data-halfdrop element resizes, it's background needs to update

Example hook

window.onresize =
  _halfdrop.update;

##Settings

1. Add or remove data-halfdrop elements
_halfdrop.init()
// Run this function after an element is added or removed
2. Change default values
_halfdrop.defaultValues
// The exposed object's properties can be modified, which may reduce overall markup in some situations
// If it's modified after DOMContentLoaded, run _halfdrop.init()

thathalfdropimagegridfromtheroyaltenenbaums.js's People

Contributors

tvler avatar

Stargazers

Anton avatar Lawrence Dark avatar massi avatar Stephen LaPorte avatar Arturo Escartin avatar Betul  avatar Sergi Miral avatar Jonathan Haggard avatar ⚠️ DO NOT USE! ⛔️ avatar

Watchers

James Cloos avatar  avatar  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.