Socket
Socket
Sign inDemoInstall

fastclick

Package Overview
Dependencies
0
Maintainers
2
Versions
28
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.6.12 to 1.0.0

LICENSE

2

bower.json
{
"name": "fastclick",
"version": "0.6.12",
"version": "1.0.0",
"main": "lib/fastclick.js",

@@ -5,0 +5,0 @@ "ignore": [

/**
* @preserve FastClick: polyfill to remove click delays on browsers with touch UIs.
*
* @version 0.6.12
* @version 1.0.0
* @codingstandard ftlabs-jsv2

@@ -22,3 +22,3 @@ * @copyright The Financial Times Limited [All Rights Reserved]

'use strict';
var oldOnClick, self = this;
var oldOnClick;

@@ -89,24 +89,2 @@

if (!layer || !layer.nodeType) {
throw new TypeError('Layer must be a document node');
}
/** @type function() */
this.onClick = function() { return FastClick.prototype.onClick.apply(self, arguments); };
/** @type function() */
this.onMouse = function() { return FastClick.prototype.onMouse.apply(self, arguments); };
/** @type function() */
this.onTouchStart = function() { return FastClick.prototype.onTouchStart.apply(self, arguments); };
/** @type function() */
this.onTouchMove = function() { return FastClick.prototype.onTouchMove.apply(self, arguments); };
/** @type function() */
this.onTouchEnd = function() { return FastClick.prototype.onTouchEnd.apply(self, arguments); };
/** @type function() */
this.onTouchCancel = function() { return FastClick.prototype.onTouchCancel.apply(self, arguments); };
if (FastClick.notNeeded(layer)) {

@@ -116,14 +94,19 @@ return;

// Some old versions of Android don't have Function.prototype.bind
function bind(method, context) {
return function() { return method.apply(context, arguments); };
}
// Set up event handlers as required
if (this.deviceIsAndroid) {
layer.addEventListener('mouseover', this.onMouse, true);
layer.addEventListener('mousedown', this.onMouse, true);
layer.addEventListener('mouseup', this.onMouse, true);
if (deviceIsAndroid) {
layer.addEventListener('mouseover', bind(this.onMouse, this), true);
layer.addEventListener('mousedown', bind(this.onMouse, this), true);
layer.addEventListener('mouseup', bind(this.onMouse, this), true);
}
layer.addEventListener('click', this.onClick, true);
layer.addEventListener('touchstart', this.onTouchStart, false);
layer.addEventListener('touchmove', this.onTouchMove, false);
layer.addEventListener('touchend', this.onTouchEnd, false);
layer.addEventListener('touchcancel', this.onTouchCancel, false);
layer.addEventListener('click', bind(this.onClick, this), true);
layer.addEventListener('touchstart', bind(this.onTouchStart, this), false);
layer.addEventListener('touchmove', bind(this.onTouchMove, this), false);
layer.addEventListener('touchend', bind(this.onTouchEnd, this), false);
layer.addEventListener('touchcancel', bind(this.onTouchCancel, this), false);

@@ -178,3 +161,3 @@ // Hack is required for browsers that don't support Event#stopImmediatePropagation (e.g. Android 2)

*/
FastClick.prototype.deviceIsAndroid = navigator.userAgent.indexOf('Android') > 0;
var deviceIsAndroid = navigator.userAgent.indexOf('Android') > 0;

@@ -187,3 +170,3 @@

*/
FastClick.prototype.deviceIsIOS = /iP(ad|hone|od)/.test(navigator.userAgent);
var deviceIsIOS = /iP(ad|hone|od)/.test(navigator.userAgent);

@@ -196,3 +179,3 @@

*/
FastClick.prototype.deviceIsIOS4 = FastClick.prototype.deviceIsIOS && (/OS 4_\d(_\d)?/).test(navigator.userAgent);
var deviceIsIOS4 = deviceIsIOS && (/OS 4_\d(_\d)?/).test(navigator.userAgent);

@@ -205,3 +188,3 @@

*/
FastClick.prototype.deviceIsIOSWithBadTarget = FastClick.prototype.deviceIsIOS && (/OS ([6-9]|\d{2})_\d/).test(navigator.userAgent);
var deviceIsIOSWithBadTarget = deviceIsIOS && (/OS ([6-9]|\d{2})_\d/).test(navigator.userAgent);

@@ -231,3 +214,3 @@

// File inputs need real clicks on iOS 6 due to a browser bug (issue #68)
if ((this.deviceIsIOS && target.type === 'file') || target.disabled) {
if ((deviceIsIOS && target.type === 'file') || target.disabled) {
return true;

@@ -258,3 +241,3 @@ }

case 'select':
return !this.deviceIsAndroid;
return !deviceIsAndroid;
case 'input':

@@ -307,3 +290,3 @@ switch (target.type) {

//Issue #159: Android Chrome Select Box does not open with a synthetic click event
if (this.deviceIsAndroid && targetElement.tagName.toLowerCase() === 'select') {
if (deviceIsAndroid && targetElement.tagName.toLowerCase() === 'select') {
return 'mousedown';

@@ -324,3 +307,3 @@ }

// Issue #160: on iOS 7, some input elements (e.g. date datetime) throw a vague TypeError on setSelectionRange. These elements don't have an integer value for the selectionStart and selectionEnd properties, but unfortunately that can't be used for detection because accessing the properties also throws a TypeError. Just check the type instead. Filed as Apple bug #15122724.
if (this.deviceIsIOS && targetElement.setSelectionRange && targetElement.type.indexOf('date') !== 0 && targetElement.type !== 'time') {
if (deviceIsIOS && targetElement.setSelectionRange && targetElement.type.indexOf('date') !== 0 && targetElement.type !== 'time') {
length = targetElement.value.length;

@@ -401,3 +384,3 @@ targetElement.setSelectionRange(length, length);

if (this.deviceIsIOS) {
if (deviceIsIOS) {

@@ -410,3 +393,3 @@ // Only trusted events will deselect text on iOS (issue #49)

if (!this.deviceIsIOS4) {
if (!deviceIsIOS4) {

@@ -549,3 +532,3 @@ // Weird things happen on iOS when an alert or confirm dialog is opened from a click event callback (issue #23):

// See issue #57; also filed as rdar://13048589 .
if (this.deviceIsIOSWithBadTarget) {
if (deviceIsIOSWithBadTarget) {
touch = event.changedTouches[0];

@@ -563,3 +546,3 @@

this.focus(targetElement);
if (this.deviceIsAndroid) {
if (deviceIsAndroid) {
return false;

@@ -574,3 +557,3 @@ }

// Case 2: Without this exception for input elements tapped when the document is contained in an iframe, then any inputted text won't be visible even though the value attribute is updated as the user types (issue #37).
if ((event.timeStamp - trackingClickStart) > 100 || (this.deviceIsIOS && window.top !== window && targetTagName === 'input')) {
if ((event.timeStamp - trackingClickStart) > 100 || (deviceIsIOS && window.top !== window && targetTagName === 'input')) {
this.targetElement = null;

@@ -584,3 +567,3 @@ return false;

// Select elements need the event to go through on iOS 4, otherwise the selector menu won't open.
if (!this.deviceIsIOS4 || targetTagName !== 'select') {
if (!deviceIsIOS4 || targetTagName !== 'select') {
this.targetElement = null;

@@ -593,3 +576,3 @@ event.preventDefault();

if (this.deviceIsIOS && !this.deviceIsIOS4) {
if (deviceIsIOS && !deviceIsIOS4) {

@@ -721,3 +704,3 @@ // Don't send a synthetic click event if the target element is contained within a parent layer that was scrolled

if (this.deviceIsAndroid) {
if (deviceIsAndroid) {
layer.removeEventListener('mouseover', this.onMouse, true);

@@ -756,5 +739,5 @@ layer.removeEventListener('mousedown', this.onMouse, true);

if (FastClick.prototype.deviceIsAndroid) {
if (deviceIsAndroid) {
metaViewport = document.querySelector('meta[name=viewport]');
if (metaViewport) {

@@ -761,0 +744,0 @@ // Chrome on Android with user-scalable="no" doesn't need FastClick (issue #89)

{
"name": "fastclick",
"version": "0.6.12",
"version": "1.0.0",
"description": "Polyfill to remove click delays on browsers with touch UIs.",

@@ -5,0 +5,0 @@ "maintainers": [

@@ -136,2 +136,2 @@ # FastClick #

The lead developer of FastClick is [Rowan Beentje](http://twitter.com/rowanbeentje) at FT Labs. This fork is currently maintained by [Matthew Caruana Galizia](http://twitter.com/mcaruanagalizia). All open source code released by FT Labs is licenced under the MIT licence. We welcome comments, feedback and suggestions. Please feel free to raise an issue or pull request. Enjoy.
FastClick is maintained by [Rowan Beentje](http://twitter.com/rowanbeentje), [Matthew Caruana Galizia](http://twitter.com/mcaruanagalizia) and [Matthew Andrews](http://twitter.com/andrewsmatt) at [FT Labs](http://labs.ft.com). All open source code released by FT Labs is licenced under the MIT licence. We welcome comments, feedback and suggestions. Please feel free to raise an issue or pull request.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc