From 5aed8c3842bac8bf034b85b1b3075250161b26fc Mon Sep 17 00:00:00 2001 From: Tom Doan Date: Wed, 24 Feb 2016 14:24:58 +0800 Subject: [PATCH] Add 'timeout' option for touch devices --- README.md | 13 +++++++------ bower.json | 2 +- dist/js/jquery.magnify.js | 10 +++++++++- package.json | 2 +- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 0b1527e..fb9b7c0 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/bower.json b/bower.json index b557150..48e12ef 100644 --- a/bower.json +++ b/bower.json @@ -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" diff --git a/dist/js/jquery.magnify.js b/dist/js/jquery.magnify.js index e1b125f..764a2a7 100644 --- a/dist/js/jquery.magnify.js +++ b/dist/js/jquery.magnify.js @@ -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. @@ -14,6 +14,7 @@ /* Default options */ debug: false, speed: 100, + timeout: -1, onload: function(){} }, oOptions), $anchor, @@ -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 diff --git a/package.json b/package.json index 9e5b87a..86a60f9 100644 --- a/package.json +++ b/package.json @@ -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",