Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

smartphoto

Package Overview
Dependencies
Maintainers
2
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

smartphoto

smartphoto

  • 0.6.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.9K
decreased by-9.14%
Maintainers
2
Weekly downloads
 
Created
Source

SmartPhoto

npm version CircleCI npm download GitHub license

The most easy to use responsive image viwer especially for mobile devices

See https://appleple.github.io/SmartPhoto/ for complete docs and demos
If you are Japasese, See here https://www.appleple.com/blog/javascript/smartphoto-js.html instead.

Feature

  • Intuitive gestures such as pinch-in/pinch-out/drag/swipe
  • Use Accelerometer to move images
  • Accessible from keyboards and screen-readers
  • Show pictures via URL hash
  • Can make photo groups

Installation

via npm

npm install smartphoto --save

or yarn

yarn add smartphoto

Usage

require

const smartPhoto = require('smartphoto');

smartphoto.js

document.addEventListener('DOMContentLoaded',function(){
    new smartPhoto(".js-img-viwer");
});

jquery-smartphoto.js

$(function(){
    $(".js-img-viwer").smartPhoto();
});

Basic Standalone Usage

<a href="./assets/large-kuma.jpg" class="js-img-viwer" data-caption="くま" data-id="kuma" data-group="0">
  <img src="./assets/kuma.jpg" width="360"/>
</a>
<a href="./assets/large-rakuda.jpg" class="js-img-viwer" data-caption="ラクダ" data-id="rakuda" data-group="0">
  <img src="./assets/rakuda.jpg" width="360"/>
</a>
<a href="./assets/large-sai.jpg" class="js-img-viwer" data-caption="サイ" data-id="sai" data-group="0">
  <img src="./assets/sai.jpg" width="360"/>
</a>
<link rel="stylesheet" href="./css/smartphoto.min.css">
<script src="./js/smartphoto.js"></script>
<script>
document.addEventListener('DOMContentLoaded',function(){
  new smartPhoto(".js-img-viwer");
});
</script>

Option

variabledescriptiondefault
arrowsprev/next arrowstrue
navnavigation images at the bottomtrue
useOrientationApiuse accelerometer to move imagestrue
resizeStyleresize images to fill/fit on the screen'fill'
animationSpeedanimation speed when switching images300
forceIntervalfrequency to apply force to images10
Hide parts
document.addEventListener('DOMContentLoaded',function(){
    new smartPhoto(".js-img-viwer",{
        arrows: false,
        nav: false
    });
});
Fit/Fill Option

You can choose if you want to scale images to fit/fill

document.addEventListener('DOMContentLoaded',function(){
  new smartPhoto(".js-img-viwer",{
      resizeStyle: 'fit'
  });
});

Event

// when the modal opened
photo.on('open',function(){
    console.log('open');
});
// when the modal closed
photo.on('close',function(){
    console.log('close');
});
// when all images are loaded
photo.on('loadall',function(){
    console.log('loadall');
});
// when photo is changed
photo.on('change',function(){
    console.log('change');
});
// when swipe started
photo.on('swipestart',function(){
    console.log('swipestart');
});
// when swipe ended
photo.on('swipeend',function(){
    console.log('swipeend');
});
// when zoomed in
photo.on('zoomin',function(){
    console.log('zoomin');
});
// when zoomed out
photo.on('zoomout',function(){
    console.log('zoomout');
});

SCSS

variabledescriptiondefault
$animation-speedanimation speed when switching images.3s
$backdrop-colorbackdrop color when viewing imagesrgba(0, 0, 0, 1)
$header-colorheader colorrgba(0, 0, 0, .2)

Download

Download ZIP

Github

https://github.com/appleple/SmartPhoto

Contributor

@steelydylan

License

Code and documentation copyright 2017 by appleple, Inc. Code released under the MIT License.

FAQs

Package last updated on 20 Jun 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc