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

zoom.ts

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zoom.ts

A lightweight TypeScript library for image and video zooming, as seen on Medium.

  • 2.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
14
decreased by-41.67%
Maintainers
1
Weekly downloads
 
Created
Source

zoom.ts

A lightweight TypeScript library for image and video zooming, as seen on Medium.

npm version dependencies status devDependencies status peerDependencies status

zoom.ts easily plugs into your application with minimal overhead by including no third-party dependencies and requiring just 8kB of bandwidth when optimized. Once marked as zoomable, clicking an image or video will smoothly expand it to fit the browser's entire viewport. The zoomed element will then await dismissal from the user, either by clicking or scrolling away.

Demo

A running demonstration can be found here.

Holding either the or Ctrl key whilst clicking the element will open the image in a new tab.

Zoomed elements can be dismissed either by clicking the element, scrolling away, or pressing Esc.

Installation

Library

The TypeScript library can be imported and instantiated:

import { Zoom } from 'zoom.ts/lib/Zoom';

new Zoom().listen();

Or the JavaScript distribution can be linked, which will register zoom as a global which can be accessed by the browser:

<script type="text/javascript" src="dist/zoom.js"></script>
<script type="text/javascript">
  new window.zoom.Zoom().listen();
</script>

A minified version of the JavaScript distribution is available at ./dist/zoom.min.js.

Stylesheet

The SCSS file can be imported:

@import '~zoom.ts/style/zoom';

Or the CSS distribution can be linked:

<link rel="stylesheet" type="text/css" href="dist/zoom.css" />

A minified version of the CSS distribution is aviailable at ./dist/zoom.min.css.

Usage

Add the data-zoom="zoom-in" attribute to an <img> or <video> to have it zoom in when clicked.

The loading of a large resource can be deferred by specifying a data-zoom-src attribute, where the value assigned contains the resource to load once the user expands the element. The resource specified in the attribute is also the resource that will be loaded if the user opens the image by clicking with either or Ctrl held.

Example

In the example snippet below an image of a forest will be displayed. Once the user clicks to zoom in the image their browser will request the larger forest-full.jpg file and replace the original <img> with the full-resolution version.

<!DOCTYPE html>
<html>
  <head>
    <link rel="stylesheet" type="text/css" href="zoom.min.css" />
  </head>

  <body>
    <main>
      <img src="forest.jpg" data-zoom="zoom-in" data-zoom-src="forest-full.jpg">
    </main>

    <script type="text/javascript" src="dist/zoom.min.js"></script>
    <script type="text/javascript">
      new window.zoom.Zoom().listen();
    </script>
  </body>
</html>

Documentation

Documentation is generated in the ./docs directory by TypeDoc and can be viewed online here.

Building

Node.js is used to build the distribution.

The following commands can be ran in the project:

  • npm run build
    • Lint, compile, minify, and optimize the stylesheets and scripts.
  • npm run watch
    • Watch the file-system for changes, triggering rebuild of the stylesheets or scripts if a change to the source of either is detected.
  • npm run clean
    • Removes the output files under the ./dist directory.

Credits

Contributing

Bug reports and pull requests are welcome on GitHub.

License

This project is available under the terms of the MIT license. See the LICENSE file for the copyright information and licensing terms.

Keywords

FAQs

Package last updated on 20 Aug 2016

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