• Stars
    star
    905
  • Rank 50,477 (Top 1.0 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

SmartPhoto

npm version CircleCI npm download GitHub license

The most easy to use responsive image viewer 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-smartphoto");
});

jquery-smartphoto.js

$(function(){
    $(".js-smartphoto").SmartPhoto();
});

Basic Standalone Usage

<a href="./assets/large-bear.jpg" class="js-smartphoto" data-caption="bear" data-id="bear" data-group="0">
  <img src="./assets/bear.jpg" width="360"/>
</a>
<a href="./assets/large-camel.jpg" class="js-smartphoto" data-caption="camel" data-id="camel" data-group="0">
  <img src="./assets/camel.jpg" width="360"/>
</a>
<a href="./assets/large-rhinoceros.jpg" class="js-smartphoto" data-caption="rhinoceros" data-id="sai" data-group="0">
  <img src="./assets/rhinoceros.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-smartphoto");
});
</script>

Option

variable description default
arrows prev/next arrows true
nav navigation images at the bottom true
useOrientationApi use accelerometer to move images true
resizeStyle resize images to fill/fit on the screen 'fill'
animationSpeed animation speed when switching images 300
forceInterval frequency to apply force to images 10

Hide parts

document.addEventListener('DOMContentLoaded',function(){
    new SmartPhoto(".js-smartphoto",{
        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-smartphoto",{
      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

variable description default
$animation-speed animation speed when switching images .3s
$backdrop-color backdrop color when viewing images rgba(0, 0, 0, 1)
$header-color header color rgba(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.

More Repositories

1

scroll-hint

A JS library to suggest that the elements are scrollable horizontally, with the pointer icon.
JavaScript
338
star
2

smartblock

intuitive block based wysiwyg editor built with React and ProseMirror
TypeScript
307
star
3

lookforward

A small library that helps you to create smooth transitions between pages with the easiest way
JavaScript
303
star
4

modal-video

JavaScript
267
star
5

react-modal-video

Accessible React Modal Video Component
JavaScript
178
star
6

lite-editor

A Modern WYSIWYG Editor especially for inline elements
JavaScript
176
star
7

form-storage

A JavaScript library stores the form-data to the localstorage so you don't have to fill the form again.
JavaScript
163
star
8

pretty-scroll

A modern JS library to make an element follow you as you scroll
JavaScript
145
star
9

a-table.js

Simple Table UI for generating table html
JavaScript
83
star
10

hiraku

jQuery Offcanvas Menu Plugin
JavaScript
76
star
11

hiraku2

Vanilla JavaScript library to make drawer menus
JavaScript
69
star
12

document-outliner

HTML5 outliner
TypeScript
20
star
13

yahoo-map-cluster

Yahoo! Map Cluster
TypeScript
19
star
14

multi-menu

JavaScript for multi level menu
TypeScript
19
star
15

backpax

Simple JavaScript Library to add parallax image to background-image
TypeScript
16
star
16

responsive-auto-height

JavaScript library to equalize elements's height
JavaScript
11
star
17

acms-utsuwa

HTML
10
star
18

a-template.js

Simple Template Engine
JavaScript
9
star
19

a-starter-kit

アップルップルの受託案件用スターターキット
HTML
8
star
20

appleple.github.io

HTML
6
star
21

nice-spy

A library used to update classnames of links based on scroll position
JavaScript
5
star
22

acms-slack

Slack app for a-blog cms
PHP
5
star
23

guideline

アップルップルのガイドライン
5
star
24

acms-zoho

a-blog cmsのフォームと連携することによってお客様が入力した情報をZoho CRM 上に蓄積することができます。
PHP
5
star
25

wp-smartphoto

SmartPhoto plugin for WordPress
PHP
4
star
26

acms-recaptcha

a-blog cms の 拡張アプリ「reCAPTCHA for a-blog cms」を使うと、GoogleのreCAPTCHAを使用してボットからの フォームアクセスを防御することが出来るようになります。
PHP
4
star
27

geo-picker

JavaScript
4
star
28

react-device-mode

TypeScript
4
star
29

ui-expand

Just a simple UI helper to expand elements to full screen
HTML
4
star
30

custom-field-maker

JavaScript
4
star
31

assign-holiday

Simple library for adding class attributes to holiday elements in a calendar
JavaScript
3
star
32

acms-google-translate

Google Translation for a-blog cms
PHP
3
star
33

acms-easy-setup

より簡単に、ご利用の環境に合わせて a-blog cms をインストール、アップデートできるパッケージです。
PHP
3
star
34

scroll-up

This library is for a fixed scroll to top button.
JavaScript
3
star
35

acms-google-sheets

Google Sheets API と連携し、お問い合わせフォームなどで送信された内容を任意のGoogle スプレッドシートの最後の行に追記することができます。
PHP
3
star
36

a-dispatcher

Just a simple url-dispatcher you can use with regex
JavaScript
3
star
37

yahoo-map-loader

Just a simple yahoo map loader for Webpack/Browserify
JavaScript
3
star
38

lite-editor-emoji-picker-plugin

Emoji Picker plugin for Lite Editor
CSS
3
star
39

acms-base

HTML
2
star
40

ablogcms-docker

Shell
2
star
41

acms-chatwork

a-blog cms のフォームからの送信データをchatworkで通知します
PHP
2
star
42

react-ui-expand

Just a simple UI helper to expand elements
HTML
2
star
43

acms-image-placeholder

Image placeholder for a-blog cms.
PHP
2
star
44

PhotoCollage

HTML
2
star
45

ScrollScale

JavaScript
1
star
46

react-icon-picker

Just a simple icon picker for React
TypeScript
1
star
47

fold-menu

TypeScript
1
star
48

acms-tiny-png

PHP
1
star
49

lang-select

JavaScript
1
star
50

cfg-csv

JavaScript
1
star
51

dom-content-loaded

JavaScript
1
star
52

react-hiragana-picker

React Component to pick Japanese Character (Hiragana)
TypeScript
1
star
53

lazy-hover

delay appear effect and leave effect when mousein mouseout
CSS
1
star
54

react-car-number-picker

TypeScript
1
star
55

acms-google-calendar

Google Calendar API と連携し、お問い合わせフォームなどで送信された内容を任意のGoogleカレンダーに登録できます。
PHP
1
star