From 1253177ae49a6114fd43a7647d7138b66c890aa1 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Tue, 4 Nov 2014 09:44:55 +0100 Subject: [PATCH] Add FastClick in mobile-full-screen example --- build.py | 1 + config/examples-all.json | 1 + examples/mobile-full-screen.html | 1 + examples/mobile-full-screen.js | 8 ++++++++ externs/fastclick.js | 25 +++++++++++++++++++++++++ 5 files changed, 36 insertions(+) create mode 100644 externs/fastclick.js diff --git a/build.py b/build.py index 3c3aa7cb5b..f3bdd9b16a 100755 --- a/build.py +++ b/build.py @@ -290,6 +290,7 @@ def examples_star_json(name, match): "externs/bootstrap.js", "externs/closure-compiler.js", "externs/example.js", + "externs/fastclick.js", "externs/geojson.js", "externs/jquery-1.9.js", "externs/proj4js.js", diff --git a/config/examples-all.json b/config/examples-all.json index 12e017f984..29e51fb47e 100644 --- a/config/examples-all.json +++ b/config/examples-all.json @@ -15,6 +15,7 @@ "externs/bootstrap.js", "externs/closure-compiler.js", "externs/example.js", + "externs/fastclick.js", "externs/geojson.js", "externs/jquery-1.9.js", "externs/proj4js.js", diff --git a/examples/mobile-full-screen.html b/examples/mobile-full-screen.html index e249c4dce5..1afd9087f0 100644 --- a/examples/mobile-full-screen.html +++ b/examples/mobile-full-screen.html @@ -18,6 +18,7 @@
+
diff --git a/examples/mobile-full-screen.js b/examples/mobile-full-screen.js index 986bb92572..22967b7bb6 100644 --- a/examples/mobile-full-screen.js +++ b/examples/mobile-full-screen.js @@ -32,3 +32,11 @@ geolocation.once('change:position', function() { view.setCenter(geolocation.getPosition()); view.setResolution(2.388657133911758); }); + +// Use FastClick to eliminate the 300ms delay between a physical tap +// and the firing of a click event on mobile browsers. +// See http://updates.html5rocks.com/2013/12/300ms-tap-delay-gone-away +// for more information. +$(function() { + FastClick.attach(document.body); +}); diff --git a/externs/fastclick.js b/externs/fastclick.js new file mode 100644 index 0000000000..676200f2b8 --- /dev/null +++ b/externs/fastclick.js @@ -0,0 +1,25 @@ +/** + * @fileoverview Externs for FastClick 1.0.3 + * @see https://github.com/ftlabs/fastclick + * @externs + */ + +/** + * @type {Object} + * @const + */ +var FastClick = {}; + +/** + * @typedef {{ + * touchBoundary: (number|undefined), + * tapDelay: (number|undefined) + * }} + */ +FastClick.AttachOptions; + +/** + * @param {Element} layer + * @param {FastClick.AttachOptions=} opt_options + */ +FastClick.attach = function(layer, opt_options) {};