All Projects β†’ michaelbull β†’ zoom.ts

michaelbull / zoom.ts

Licence: ISC License
A lightweight TypeScript library for image zooming, as seen on Medium.

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
SCSS
7915 projects

Projects that are alternatives of or similar to zoom.ts

Medium Zoom
πŸ”ŽπŸ–Ό A JavaScript library for zooming images like Medium
Stars: ✭ 2,799 (+6261.36%)
Mutual labels:  zooming, medium, zoom
Image Zoom
πŸ”Ž Medium.com style image zoom for React πŸ”
Stars: ✭ 920 (+1990.91%)
Mutual labels:  medium, zoom
FlutterMediumClone
Building a Medium Clone in Flutter.
Stars: ✭ 55 (+25%)
Mutual labels:  medium
vue-inner-image-zoom
laurenashpole.github.io/vue-inner-image-zoom
Stars: ✭ 90 (+104.55%)
Mutual labels:  zoom
react-quick-pinch-zoom
A react component that providing multi-touch gestures for zooming and dragging on any DOM element.
Stars: ✭ 124 (+181.82%)
Mutual labels:  zoom
kuote
Create beautiful Medium-like quotes, perfect for sharing on Twitter or Instagram.
Stars: ✭ 11 (-75%)
Mutual labels:  medium
Neural-Zoom
Infinite Zoom For Style Transfer
Stars: ✭ 34 (-22.73%)
Mutual labels:  zoom
Self-Driving-Car-Steering-Simulator
The aim of this project is to allow a self driving car to steer autonomously in a virtual environment.
Stars: ✭ 15 (-65.91%)
Mutual labels:  medium
medium-to-wordpress-migration
Script to export medium blogs to wordpress rss xml format
Stars: ✭ 15 (-65.91%)
Mutual labels:  medium
React-Medium-Blog
React blog page which consist of last ten medium posts. The blog card is created using shards React and React application.
Stars: ✭ 14 (-68.18%)
Mutual labels:  medium
medium-unlocker
Read Medium content without limit!
Stars: ✭ 127 (+188.64%)
Mutual labels:  medium
zoom-slack-status-updater
Update your Slack status automatically when you join a Zoom meeting.
Stars: ✭ 23 (-47.73%)
Mutual labels:  zoom
artigo-solid-medium
Implementaçáes dos exemplos demonstrados no artigo: https://bit.ly/2o97vY1
Stars: ✭ 28 (-36.36%)
Mutual labels:  medium
read-medium-extension
Chrome extension for reading Medium for free without leaving the page.
Stars: ✭ 55 (+25%)
Mutual labels:  medium
webpack-2.0-from-scratch
Guide on how to setup a Webpack config from scratch.
Stars: ✭ 72 (+63.64%)
Mutual labels:  medium
data-visualization-sample-app
Sample application to visualize basic activity on your Zoom account and can be used as code example to assist new Zoom Developers
Stars: ✭ 18 (-59.09%)
Mutual labels:  zoom
MediumAppFlutter
Flutter recreation of the UI of the Medium android app
Stars: ✭ 62 (+40.91%)
Mutual labels:  medium
jam
πŸ“ Jam is your own open source Clubhouse for mini conferences, friends, communities
Stars: ✭ 1,030 (+2240.91%)
Mutual labels:  zoom
code-medium
Browser extension that simplifies writing code in Medium posts. Quickly create and edit Github Gists without leaving the editor
Stars: ✭ 59 (+34.09%)
Mutual labels:  medium
zoom
Lightweight (8 Kb) ES5 javascript plugin without any dependencies, compatible with desktop and mobile devices.
Stars: ✭ 25 (-43.18%)
Mutual labels:  zoom

zoom.ts

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

Demo

npm version npm downloads
software license build status


example



Installation

Install the package via npm:

npm install --save zoom.ts

Usage

The example directory contains the code used to demonstrate an application with zoom.ts installed.

Static Site

To integrate zoom.ts into a static site, import the UMD module and interface with the library via the global window.zoom. The snippet below demonstrates linking the bundle (dist/zoom.js) and the stylesheet (dist/zoom.css). It then calls the listen function to add an event listener to the document.body when the page is ready.

<!DOCTYPE html>
<html>
  <head>
    <link rel="stylesheet" href="dist/zoom.css">
    <script type="text/javascript" src="dist/zoom.js"></script>
    <script>window.zoom.listen();</script>
  </head>

  <body>
    <img
      class="zoom__image"
      src="tower.jpeg"
      data-width="2048"
      data-height="1366"
      data-src="tower-full.jpeg"
    />
  </body>
</html>

Application

To integrate zoom.ts into a web application, follow the steps outlined below:

  1. Detect and store the Features of the document.body.style
  2. Locate the element you wish to make zoomable
  3. Register a ZoomListener on the target image
  4. In the listener's callback, create and store a Zoom instance
  5. Call expand on the Zoom instance to begin zooming the image
  6. If the user navigates to a different page in the application, call destroy on the Zoom instance

The snippet below demonstrates finding the first element with the zoom__image class and adding a ZoomListener to any click events it fires. When fired, the event listener will create a Zoom instance and store it as a variable named zoom, then immediately expand the image. After 5 seconds have passed, the zoom will be forcefully removed via the call to destroy.

import {
    detectFeatures,
    Zoom,
    ZoomDOM,
    ZoomListener
} from 'zoom.ts';

let features = detectFeatures(document.body.style); // (1)
let image = document.querySelector('.zoom__image'); // (2)

image.addEventListener('click', new ZoomListener(dom => { // (3)
    let zoom = new Zoom(dom, features); // (4)

    zoom.expand(); // (5)

    setTimeout(() => {
        zoom.destroy(); // (6)
    }, 5000);
}));

Contributing

Bug reports and pull requests are welcome on GitHub.

License

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].