Giter VIP home page Giter VIP logo

selfie.js's Introduction

Selfie.js

Selfie with Java Script

Install

bower

$ bower install selfie.js

npm

$ bower install selfie.js

How to use

<!-- add selfie.js -->
<script src="path/to/selfie.min.js"></script>
const s = selfie.init(options);
s.takePhoto(); // method to take photo.
s.removePhoto(); // method to remove photo.

Options (Everything is optional. Not necessary)

  • option - (Object)
    • target - (Object) It shoud be 'Node Element'. Its default value is document.body.
    • fileName - (String) Set file's name. Default is 'selfie' and file extension is png.
    • downloadLinkText - (String) Set download link's text. Default is 'DOWNLOAD'.
    • camera - (Object) It is 'Video Element' for displaying camera.
      • id - (String) If you want to add ID to this node element, Specify it.
      • class - (String) If you want to add class to this node element, Specify it.
      • activeClass - (String) If you want to add class to node element when it is activated, Specify it.
      • unactiveClass - (String) If you want to add class to node element when it is unactivated, Specify it.
    • store - (Object) It is 'Canvas Element' for save selfie temporarily.
      • id - (String) If you want to add ID to this node element, Specify it.
      • class - (String) If you want to add class to this node element, Specify it.
      • activeClass - (String) If you want to add class to node element when it is activated, Specify it.
      • unactiveClass - (String) If you want to add class to node element when it is unactivated, Specify it.
    • photo - (Object) It is 'Image Element' for displaying selfie taken.
      • id - (String) If you want to add ID to this node element, Specify it.
      • class - (String) If you want to add class to this node element, Specify it.
      • activeClass - (String) If you want to add class to node element when it is activated, Specify it.
      • unactiveClass - (String) If you want to add class to node element when it is unactivated, Specify it.
    • download - (Object) It is 'Anchor Element' for download selfie. It has 'download' attributes.
      • id - (String) If you want to add ID to this node element, Specify it.
      • class - (String) If you want to add class to this node element, Specify it.
      • activeClass - (String) If you want to add class to node element when it is activated, Specify it.
      • unactiveClass - (String) If you want to add class to node element when it is unactivated, Specify it.

Example

// Set options. It is not necessary.
const options = {
  target: document.getElementById('selfie-wrapper'),
  fileName: 'selfie',
  downloadLinkText: 'Click',
  camera: {
    id: 'selfie-camera',
    activeClass: 'active',
    unactiveClass: 'none',
    class: 'selfie-camera'
  },
  store: {
    id: 'selfie-store',
    activeClass: 'active',
    unactiveClass: 'none',
    class: 'selfie-store'
  },
  photo: {
    id: 'selfie-image',
    activeClass: 'active',
    unactiveClass: 'none',
    class: 'selfie-image'
  },
  download: {
    id: 'selfie-download',
    activeClass: 'active',
    unactiveClass: 'none',
    class: 'selfie-download'
  }
};

// Initialize
const s = selfie.init(options);

// take photo
document.querySelector('SELFIE_SHUTTER_BUTTON').onclick = s.takePhoto;

// remove photo
document.querySelector('REMOVE_SELFIE').onclick = s.removePhoto;

Licence

MIT

selfie.js's People

Contributors

wonism avatar devhyunjae avatar

Stargazers

wolrdedit avatar  avatar  avatar

Watchers

James Cloos avatar Tornike avatar  avatar

Forkers

tedfordmedia

selfie.js's Issues

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.