• Stars
    star
    447
  • Rank 93,927 (Top 2 %)
  • Language
    JavaScript
  • License
    Apache License 2.0
  • Created about 8 years ago
  • Updated over 7 years ago

Reviews

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

Repository Details

Apple Live Photo support on the web, courtesy of Tumblr

Laphs: Live Photos on the Web

Add support for Apple's Live Photos in web browsers.

Installation

Using npm

Install the library:

npm install --save laphs

Include it into your module:

var LivePhotos = require('laphs');

The old-fashioned way

Copy dist/laphs.min.js into your project and include it in a <script> tag on your page. This will make the LivePhotos global variable available.

Usage

Full documentation

The easiest way to use this library is by using special data-attributes on your Live Photo <img> tags.

<img src="http://40.media.tumblr.com/3613923b93c21e78bc9e8935220c186a/tumblr_o63c4ekE1X1twn7m0o1_1280.jpg" data-live-photo="http://53.media.tumblr.com/3613923b93c21e78bc9e8935220c186a/tumblr_o63c4ekE1X1twn7m0o1.mov" data-live-photo-still-image-time="1.71"/>
  • src is the URL of the keyframe image
  • data-live-photo is the URL of the Live Photo video file
  • data-live-photo-still-image-time is the time (in seconds) corresponding to where they keyframe was pulled from the video

Include this JavaScript to find and convert all such images that it finds on the page:

LivePhotos.initialize();

You can also pass elements or custom selectors manually, if you prefer:

LivePhotos.initialize(el);
// or...
LivePhotos.initialize([el1, el2, el3]);
// or...
LivePhotos.initialize('.my-live-photos');

The LivePhotos function returns an array of LivePhoto objects, which are described in more detail below.

By default, this library injects styles to make your Live Photos look nice. If you prefer, you can disable this behavior before you scan for Live Photos:

LivePhotos.noStyles();
// Subsequent calls will not inject the styles

The LivePhoto Object

Live Photos created using this library are wrapped in a LivePhoto object that has an API for playback

The following methods are available on Live Photos:

  • load triggers loading the video assets for the Live Photo
  • play activates Live Photo playback, stopping on the last frmae
  • stop deactivates Live Photo playback, transitioning back to the keyframe
  • preview plays a short clip of the video just before the keyframe, which mimicking the behavior of Live Photos viewed in the Photos App on an iOS device

If you like, you can create a LivePhoto object directly by passing an element with src, data-live-photo, and data-live-photo-still-image-time attributes:

var livePhoto = new LivePhotos.LivePhoto(el, options);

You may also pass the keyframe and video URLs and the keyframe time directly:

var livePhoto = new LivePhotos.LivePhoto(keyframeUrl, videoUrl, stillImageTime, options);

Contributing

Pull Requests

  1. Fork the repo and create your branch from master.
  2. If you've added code that should be tested, add tests.
  3. If you've changed APIs, update the documentation.
  4. Ensure the test suite passes.
  5. If you haven't already, complete the Contributor License Agreement ("CLA").

Contributor License Agreement ("CLA")

In order to accept your pull request, we need you to submit a CLA.

Complete the CLA here.

Copyright and license

Copyright 2016 Tumblr, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with the License. You may obtain a copy of the License in the LICENSE file, or at:

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations.

More Repositories

1

Backboard

A motion-driven animation framework for Android.
Java
1,690
star
2

Graywater

An Android library for decomposing RecyclerView layouts to improve scroll performance.
Java
1,207
star
3

colossus

I/O and Microservice library for Scala
Scala
1,143
star
4

jetpants

MySQL toolkit for managing billions of rows and hundreds of database machines
Ruby
1,134
star
5

pytumblr

A Python Tumblr API v2 Client
Python
718
star
6

tumblr.js

JavaScript client for the Tumblr API
JavaScript
633
star
7

collins

groovy kind of love
Scala
571
star
8

Bookends

A UI widget for adding headers and footers to RecyclerView
Java
538
star
9

Remember

A preferences-backed key-value store
Java
522
star
10

policy

Tumblr policies and guidelines
453
star
11

TMTumblrSDK

Unopinionated and flexible library for easily integrating Tumblr data into your iOS or OS X application.
Objective-C
429
star
12

tumblr.php

Tumblr API v2 PHP Client
PHP
406
star
13

k8s-sidecar-injector

Kubernetes sidecar injection service
Go
340
star
14

kanvas-ios

Kanvas: a creation tool for iOS
Swift
302
star
15

jumblr

Tumblr API v2 Java Client
Java
276
star
16

gocircuit

Go
238
star
17

genesis

A tool for data center automation
Ruby
156
star
18

docker-registry-pruner

Tool to apply retention logic to docker images in a Docker Registry
Go
126
star
19

data-lasso

JavaScript
119
star
20

docs

Tumblr's public platform documentation.
99
star
21

XExtensionItem

Easier sharing of structured data between iOS applications and share extensions
Objective-C
86
star
22

webpack-web-app-manifest-plugin

A webpack plugin that generates a PWA manifest and integrates with the assets JSON.
JavaScript
75
star
23

PermissMe

Java
74
star
24

k8s-secret-projector

Kubernetes Secret generation from secure credential repos
Go
72
star
25

k8s-config-projector

Create Kubernetes ConfigMaps from configuration files
Go
65
star
26

go-collins

Collins API Client in Go - https://tumblr.github.io/collins
Go
41
star
27

tumblrclient.go

This is a concrete implementation of the ClientInterface with additional convenience methods defined right on the client object
Go
41
star
28

tumblr.go

This is a library which provides structs and functions for accessing the Tumblr API
Go
37
star
29

JXHTTP

you know, for networking
Objective-C
26
star
30

Spectacles

A tiny library for parsing JSON podspecs.
Objective-C
23
star
31

gulp-css-hashes

JavaScript
18
star
32

tsd_proxy

Clojure
15
star
33

tumblr-repl

REPL for the Tumblr API, built on tumblr.js
JavaScript
11
star
34

collins_shell

Ruby
3
star
35

consolr

Ruby
1
star
36

chorus-timekeeper

DI with timekeeping.
PHP
1
star
37

collins_client

Ruby
1
star
38

collins_notify

Ruby
1
star
39

collins_auth

Ruby
1
star
40

slackr_archiver

Ruby
1
star