Được TopGit lập chỉ mục từ metadata GitHub: ftlabs/fastclick có 18.5k sao, viết chủ yếu bằng HTML. Polyfill to remove click delays on browsers with touch UIs
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
FastClick is a simple, easy-to-use library for eliminating the 300ms delay between a physical tap and the firing of a click event on mobile browsers. The aim is to make your application feel less laggy and more responsive while avoiding any interference with your current logic.
FastClick is developed by FT Labs, part of the Financial Times.
Note: As of late 2015 most mobile browsers - notably Chrome and Safari - no longer have a 300ms touch delay, so fastclick offers no benefit on newer browsers, and risks introducing bugs into your application. Consider carefully whether you really need to use it.
Explication en français.
日本語で説明。
Why does the delay exist?
According to Google:
...mobile browsers will wait approximately 300ms from the time that you tap the button to fire the click event. The reason for this is that the browser is waiting to see if you are actually performing a double tap.
Compatibility
The library has been deployed as part of the FT Web App and is tried and tested on the following mobile browsers:
Mobile Safari on iOS 3 and upwards
Chrome on iOS 5 and upwards
Chrome on Android (ICS)
Opera Mobile 11.5 and upwards
Android Browser since Android 2
PlayBook OS 1 and upwards
When it isn't needed
FastClick doesn't attach any listeners on desktop browsers.
Chrome 32+ on Android with width=device-width in the viewport meta tag doesn't have a 300ms delay, therefore listeners aren't attached.
Same goes for Chrome on Android (all versions) with user-scalable=no in the viewport meta tag. But be aware that user-scalable=no also disables pinch zooming, which may be an accessibility concern.
For IE11+, you can use touch-action: manipulation; to disable double-tap-to-zoom on certain elements (like links and buttons). For IE10 use -ms-touch-action: manipulation.
Usage
Include fastclick.js in your JavaScript bundle or add it to your HTML page like this:
If you're using Browserify or another CommonJS-style module system, the FastClick.attach function will be returned when you call require('fastclick'). As a result, the easiest way to use FastClick with these loaders is as follows:
var attachFastClick = require('fastclick');
attachFastClick(document.body);
Minified
Run make to build a minified version of FastClick using the Closure Compiler REST API. The minified file is saved to build/fastclick.min.js or you can download a pre-minified version.
Note: the pre-minified version is built using our build service which exposes the FastClick object through Origami.fastclick and will have the Browserify/CommonJS API (see above).
var attachFastClick = Origami.fastclick;
attachFastClick(document.body);
AMD
FastClick has AMD (Asynchronous Module Definition) support. This allows it to be lazy-loaded with an AMD loader, such as RequireJS. Note that when using the AMD style require, the full FastClick object will be returned, notFastClick.attach
var FastClick = require('fastclick');
FastClick.attach(document.body, options);
Package managers
You can install FastClick using Component, npm or Bower.
For Ruby, there's a third-party gem called fastclick-rails. For .NET there's a NuGet package.
Advanced
Ignore certain elements with needsclick
Sometimes you need FastClick to ignore certain elements. You can do this easily by adding the needsclick class.
<a class="needsclick">Ignored by FastClick</a>
Use case 1: non-synthetic click required
Internally, FastClick uses document.createEvent to fire a synthetic click event as soon as touchend is fired by the browser. It then suppresses the additional click event created by the browser after that. In some cases, the non-synthetic click event created by the browser is required, as described in the triggering focus example.
This is where the needsclick class comes in. Add the class to any element that requires a non-synthetic click.
Use case 2: Twitter Bootstrap 2.2.2 dropdowns
Another example of when to use the needsclick class is with dropdowns in Twitter Bootstrap 2.2.2. Bootstrap add its own touchstart listener for dropdowns, so you want to tell FastClick to ignore those. If you don't, touch devices will automatically close the dropdown as soon as it is clicked, because both FastClick and Bootstrap execute the synthetic click, one opens the dropdown, the second closes it immediately after.
FastClick is designed to cope with many different browser oddities. Here are some examples to illustrate this:
basic use showing the increase in perceived responsiveness
triggering focus on an input element from a click handler
input element which never receives clicks but gets fast focus
Tests
There are no automated tests. The files in tests/ are manual reduced test cases. We've had a think about how best to test these cases, but they tend to be very browser/device specific and sometimes subjective which means it's not so trivial to test.
Credits and collaboration
FastClick is maintained by Rowan Beentje, Matthew Caruana Galizia and Matthew Andrews at FT Labs. 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.
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/ftlabs/fastclick là nguồn chính thức.
ftlabs/fastclick có phải mã nguồn mở không?
Có — ftlabs/fastclick phát hành theo license MIT, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/ftlabs/fastclick.
ftlabs/fastclick có tag gì không?
Bản đồng bộ chưa ghi nhận topic GitHub nào cho ftlabs/fastclick. GitHub topics hiển thị ở thanh bên phải trang repo — đó là nơi đáng kiểm tra nhất.
ftlabs/fastclick có website riêng không?
TopGit chưa ghi nhận URL trang chủ cho ftlabs/fastclick. Phần README ở tab phía trên thường có link demo, hoặc xem mô tả GitHub của repo.
ftlabs/fastclick còn đang phát triển không?
Commit gần nhất trên ftlabs/fastclick là 5.3 năm trước (theo timestamp GitHub). Repo có 3.1k fork — một chỉ báo về mức độ quan tâm của cộng đồng.
ftlabs/fastclick dùng license gì?
ftlabs/fastclick phát hành theo license MIT. Nên mở file LICENSE trên GitHub để xác nhận — license metadata đôi khi lệch với thực tế dự án.
Đọc đầy đủ README ở tab phía trên.
Vẫn đang phân vân về fastclick?
Một cú bấm sẽ gửi câu hỏi kèm trang này cho AI — xem AI nói gì về fastclick.