🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

picture_zoomer

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

picture_zoomer

1.0
Rubygems
Version published
Maintainers
1
Created
Source

Gem Version

Here's a demo

Simple "zooming lightbox" that doesn't suck.

This is a fairly simple piece of JS code, but also something I've re-written a number of times over the last few years. So here's the "canonical version".

Usage

Include the JavaScript code. For Ruby on Rails, you can use the gem (see below).

All you need to do after that is tell it which images to zoom:

$('img').picture_zoomer()

The larger version is loaded either from the data-large or src attribute:

<img src="smaller_version.jpg" data-large="larger-version.jpg">
<img src="large_version.jpg" style="width: 100px">

or if you also want your image to do something without JS:

<a href="larger-version.jpg">
  <img src="smaller_version.jpg" data-large="larger-version.jpg">
</a>

There's one (optional) argument: the animation speed. The default is 400ms.

// Very fast!
$('img').picture_zoomer(100)

// Just show a large version (don't animate)
$('img').picture_zoomer(0)

That's all there's to it :-)

Ruby on Rails installation

This is packaged as a Ruby gem ready to use in a Rails app.

Add to your Gemfile

gem 'picture_zoomer'

Add to your application.js:

// =require picture_zoomer

FAQs

Package last updated on 01 Sep 2015

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