Skip to content

Instantly share code, notes, and snippets.

View ninan1028's full-sized avatar

世间自在法 ninan1028

View GitHub Profile
@ninan1028
ninan1028 / oher.js
Last active November 15, 2019 07:12
移动端页面回退刷新
网址 http://blog.weiqinxue.cn/blogs/index.php/User/articleview/ArticleID/U2A155
if(Q.ua.IOS){
Q.$(window).on("pagehide",function(){
var $body = $(document.body);
$body.children().remove(); // wait for this callback to finish executing and then...
setTimeout(function() {
$body.append("<script type='text/javascript'>window.location.reload(true);</script>");
});
@ninan1028
ninan1028 / meta.txt
Created June 20, 2017 02:33
meta 标签
对手机号码不识别
<meta name="format-detection" content="telephone=no" />
viewport
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
@ninan1028
ninan1028 / des.txt
Created June 20, 2017 02:04
移动端点击穿透 300ms延迟
什么是点击穿透?
假如页面上有两个元素A和B。B元素在A元素之上。我们在B元素的touchstart事件上注册了一个回调函数,该回调函数的作用是隐藏B元素。我们发现,当我们点击B元素,B元素被隐藏了,随后,A元素触发了click事件。
这是因为在移动端浏览器,事件执行的顺序是touchstart > touchend > click。而click事件有300ms的延迟,当touchstart事件把B元素隐藏之后,隔了300ms,浏览器触发了click事件,但是此时B元素不见了,所以该事件被派发到了A元素身上。如果A元素是一个链接,那此时页面就会意外地跳转。
方案二:FastClick
FastClick 是 FT Labs 专门为解决移动端浏览器 300 毫秒点击延迟问题所开发的一个轻量级的库。FastClick的实现原理是在检测到touchend事件的时候,会通过DOM自定义事件立即出发模拟一个click事件,并把浏览器在300ms之后的click事件阻止掉。
http://www.jianshu.com/p/6e2b68a93c88
@ninan1028
ninan1028 / move.js
Created June 14, 2017 03:50
移动函数 移动的方式
/*
* Tween.js
* t: current time(当前时间)
* b: beginning value(初始值)
* c: change in value(变化量)
* d: duration(持续时间)
* 根据 当前 运行 时间 计算 当前 时间 的 运动 位置 返回 的 是 位置
*/
var Tween = {
Linear: function(t, b, c, d) { return c*t/d + b; },
@ninan1028
ninan1028 / descript.text
Created June 13, 2017 09:14
移动端 滚动穿透的解决方案
// 问题描述
在移动端 使用 fixed 进行 弹窗 时会 出现滚动 时 下层 的 元素 也会 滚动
@ninan1028
ninan1028 / char.js
Created June 13, 2017 06:48
得到字符串中出现次数最多的字符及个数
// 使用普通 的方法
var str="assssfdererdsdsgseres";
function method1(){
var str=document.getElementById("J_input").value;
if(str){
var obj={};
var num=0;