Giter Site home page Giter Site logo

1c7 / bigpicture Goto Github PK

View Code? Open in Web Editor NEW

This project forked from henrygd/bigpicture

0.0 3.0 0.0 6.05 MB

Lightweight JavaScript image / video viewer. Supports Youtube and Vimeo.

Home Page: https://henrygd.me/bigpicture

License: MIT License

Shell 1.02% CSS 22.79% HTML 13.99% JavaScript 62.21%

bigpicture's Introduction

logo BigPicture.js

Example page screenshot

Lightweight (just over 4 KB minified, 2 KB gzip) and framework independent JavaScript image / video viewer.

Supports Youtube, Vimeo, and direct video links.

Doesn't sit on the DOM when inactive.

Instructions

Install via npm or add a script from the dist directory to your page.

npm install bigpicture
var BigPicture = require('bigpicture');

Or with a script tag:

<script src="BigPicture.js"></script>

The script is all that's needed -- no additional CSS file.

When you want to open something, pass an object to BigPicture containing the element from which you want the animation to start and an optional second parameter depending on what you want to do. Examples below use this to refer to the trigger element being interacted with in the context of an event handler. You can use a different element if you want (for example, different buttons could be set up to open videos from the same central showcase element).

Remote image example
BigPicture({
  el: this,
  imgSrc: 'http://yourimage.jpg'
});
Remote video
BigPicture({
  el: this,
  vidSrc: 'http://yourvideo.mp4'
});
Youtube

Pass in the video ID from the url. For example, the ID for https://www.youtube.com/watch?v=z_PeaHVcohg would be z_PeaHVcohg (The v parameter in the address).

BigPicture({
  el: this,
  ytSrc: 'z_PeaHVcohg'
});
Vimeo

Like Youtube, pass in the video ID from the url. The ID for https://vimeo.com/119287310 would be 119287310.

BigPicture({
  el: this,
  vimeoSrc: '119287310'
});
Local images & background images

If your trigger element is an image or an element with a background image, you can open it directly by passing it alone.

BigPicture({
  el: this
});

Captions

To display a caption, add a caption attribute with the desired text (or HTML) to the trigger element itself.

<img src="yourimage.jpg" caption="Example of an optional caption."/>

Optional callbacks

To execute specified functions at the start or end of the opening animation, pass them in as animationStart or animationEnd. animationStart will run even if there's an error, so it's okay to use if you want to hide your own custom loader.

BigPicture({
  el: this,
  // executed immediately before open animation starts
  animationStart: function() {
    console.log('it is opening');
  },
  // executed immediately after open animation finishes
  animationEnd: function() {
    console.log('it has opened');
  }
});

Hide default loading icon

If you're loading remote images or videos and don't want the default loading icon displayed, set noLoader to true.

BigPicture({
  el: this,
  vimeoSrc: '119287310',
  noLoader: true
});

Troubleshooting

If the media or loading icon fails to display, it's probably a z-index issue. The media container has a default z-index of 9999, and the loading icon has a z-index of 9 relative to the trigger element's parent container.


License: MIT

bigpicture's People

Contributors

henrygd avatar

Watchers

 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.