Skip to content

Commit 5aed8c3

Browse files
author
Tom Doan
committed
Add 'timeout' option for touch devices
1 parent c159a79 commit 5aed8c3

File tree

4 files changed

+18
-9
lines changed

4 files changed

+18
-9
lines changed

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,13 @@ $(document).ready(function() {
6363

6464
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="..."`).
6565

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

7374
## Installation
7475

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "magnify",
33
"description": "A simple, lightweight jQuery magnifying glass zoom plugin.",
4-
"version": "1.4.0",
4+
"version": "1.5.0",
55
"main": [
66
"dist/css/magnify.css",
77
"dist/js/jquery.magnify.js"

dist/js/jquery.magnify.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* jQuery Magnify Plugin v1.4.0 by Tom Doan (http://thdoan.github.io/magnify/)
2+
* jQuery Magnify Plugin v1.5.0 by Tom Doan (http://thdoan.github.io/magnify/)
33
* Based on http://thecodeplayer.com/walkthrough/magnifying-glass-for-images-using-jquery-and-css3
44
*
55
* jQuery Magnify by Tom Doan is licensed under the MIT License.
@@ -14,6 +14,7 @@
1414
/* Default options */
1515
debug: false,
1616
speed: 100,
17+
timeout: -1,
1718
onload: function(){}
1819
}, oOptions),
1920
$anchor,
@@ -119,6 +120,13 @@
119120
$container.mouseleave(function() {
120121
if ($lens.is(':visible')) $lens.fadeOut(oSettings.speed);
121122
});
123+
if (oSettings.timeout>=0) {
124+
$container.on('touchend', function() {
125+
setTimeout(function() {
126+
if ($lens.is(':visible')) $lens.fadeOut(oSettings.speed);
127+
}, oSettings.timeout);
128+
});
129+
}
122130

123131
if ($anchor.length) {
124132
// Make parent anchor inline-block to have correct dimensions

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "magnify",
3-
"version": "1.4.0",
3+
"version": "1.5.0",
44
"description": "A simple, lightweight jQuery magnifying glass zoom plugin.",
55
"keywords": [
66
"jquery-plugin",

0 commit comments

Comments
 (0)