Skip to content

Commit

Permalink
Add 'timeout' option for touch devices
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Doan committed Feb 24, 2016
1 parent c159a79 commit 5aed8c3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,13 @@ $(document).ready(function() {

Options can be set using data attributes or passed in an `options` JavaScript object when calling `.magnify()`. For data attributes, append the option name to "data-magnify-" (e.g., `data-magnify-src="..."`).

Name | Type | Default | Description
-------- | -------- | ------- | -----------
`debug` | boolean | false | Toggle activity logging in the console.
`speed` | number | 100 | The fade-in/out animation speed in ms when the lens moves on/off the image.
`src` | string | '' | The URI of the large image that will be shown in the magnifying lens.
`onload` | function | | Callback function to execute after magnification is loaded.
Name | Type | Default | Description
--------- | -------- | ------- | -----------
`debug` | boolean | false | Toggle activity logging in the console.
`speed` | number | 100 | The fade-in/out animation speed in ms when the lens moves on/off the image.
`src` | string | '' | The URI of the large image that will be shown in the magnifying lens.
`timeout` | number | -1 | The wait period in ms before hiding the magnifying lens on touch devices. Set to `-1` to disable.
`onload` | function | | Callback function to execute after magnification is loaded.

## Installation

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "magnify",
"description": "A simple, lightweight jQuery magnifying glass zoom plugin.",
"version": "1.4.0",
"version": "1.5.0",
"main": [
"dist/css/magnify.css",
"dist/js/jquery.magnify.js"
Expand Down
10 changes: 9 additions & 1 deletion dist/js/jquery.magnify.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* jQuery Magnify Plugin v1.4.0 by Tom Doan (http://thdoan.github.io/magnify/)
* jQuery Magnify Plugin v1.5.0 by Tom Doan (http://thdoan.github.io/magnify/)
* Based on http://thecodeplayer.com/walkthrough/magnifying-glass-for-images-using-jquery-and-css3
*
* jQuery Magnify by Tom Doan is licensed under the MIT License.
Expand All @@ -14,6 +14,7 @@
/* Default options */
debug: false,
speed: 100,
timeout: -1,
onload: function(){}
}, oOptions),
$anchor,
Expand Down Expand Up @@ -119,6 +120,13 @@
$container.mouseleave(function() {
if ($lens.is(':visible')) $lens.fadeOut(oSettings.speed);
});
if (oSettings.timeout>=0) {
$container.on('touchend', function() {
setTimeout(function() {
if ($lens.is(':visible')) $lens.fadeOut(oSettings.speed);
}, oSettings.timeout);
});
}

if ($anchor.length) {
// Make parent anchor inline-block to have correct dimensions
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "magnify",
"version": "1.4.0",
"version": "1.5.0",
"description": "A simple, lightweight jQuery magnifying glass zoom plugin.",
"keywords": [
"jquery-plugin",
Expand Down

0 comments on commit 5aed8c3

Please sign in to comment.