码迷,mamicode.com
首页 > 移动开发 > 详细

移动端兼容 - faskclick.js

时间:2018-10-14 16:38:18      阅读:242      评论:0      收藏:0      [点我收藏+]

标签:src   family   hub   bsp   alt   document   解决   als   false   

fasckclick为解决移动端300ms延迟而生

github地址为:https://github.com/ftlabs/fastclick

 

技术分享图片

 

 

使用方法:

 

1. 原生使用(window.onload或其它方式皆可->一切都是在文档流加载完毕)

1 if (‘addEventListener‘ in document) {
2             document.addEventListener(‘DOMContentLoaded‘, function () {
3                 FastClick.attach(document.body);
4             }, false);
5         }

 

2. 基于jq使用

1 $(function() {
2     FastClick.attach(document.body);
3 });

 

3. 基于模块化使用(Vue\Angular或其它基于CommonJS样式的模块系统)使用

1 var attachFastClick = require(‘fastclick‘);
2 attachFastClick(document.body);

 

4. 基于require.js(AMD)使用

1 var FastClick = require(‘fastclick‘);
2 FastClick.attach(document.body, options);

 

5. 基于Mui使用

1 var FastClick = require(‘./core/fastclick‘);
2 
3 window.addEventListener(‘load‘, function() {
4     FastClick.attach(document.body);
5 }, false);

 

移动端兼容 - faskclick.js

标签:src   family   hub   bsp   alt   document   解决   als   false   

原文地址:https://www.cnblogs.com/cisum/p/9786009.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!