博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
js文字跳动效果
阅读量:7251 次
发布时间:2019-06-29

本文共 2294 字,大约阅读时间需要 7 分钟。

/*! * chaffle v1.0.0 *  * Licensed under MIT * Copyright 2013-2014 blivesta * http://blivesta.com */(function($){var namespace="chaffle";var methods={init:function(options){options=$.extend({speed:20,time:140},options);return this.each(function(){var _this=this;var $this=$(this);var data=$this.data(namespace);if(!data){options=$.extend({},options);$this.data(namespace,{options:options})}var $text=$this.text();var substitution;var shuffle_timer;var shuffle_timer_delay;var shuffle=function(){$this.text(substitution);if($text.length-substitution.length>0){for(i=0;i<$text.length-substitution.length;i++){var shuffleStr=random_text.call();$this.append(shuffleStr)}}else{clearInterval(shuffle_timer)}};var shuffle_delay=function(){if(substitution.length<$text.length){substitution=$text.substr(0,substitution.length+1)}else{clearInterval(shuffle_timer_delay)}};var random_text=function(){var str;var lang=$this.data("lang");switch(lang){case"en":str=String.fromCharCode(33+Math.round(Math.random()*99));break;case"zh":str=String.fromCharCode(19968+Math.round(Math.random()*80));break;case"ja-hiragana":str=String.fromCharCode(12352+Math.round(Math.random()*50));break;case"ja-katakana":str=String.fromCharCode(12448+Math.round(Math.random()*84));break}return str};var start=function(){substitution="";clearInterval(shuffle_timer);clearInterval(shuffle_timer_delay);shuffle_timer=setInterval(function(){shuffle.call(_this)},options.speed);shuffle_timer_delay=setInterval(function(){shuffle_delay.call(this)},options.time)};$this.unbind("mouseover."+namespace).bind("mouseover."+namespace,function(){start.call(_this)})})},destroy:function(){return this.each(function(){var $this=$(this);$(window).unbind("."+namespace);$this.removeData(namespace)})}};$.fn.chaffle=function(method){if(methods[method]){return methods[method].apply(this,Array.prototype.slice.call(arguments,1))}else if(typeof method==="object"||!method){return methods.init.apply(this,arguments)}else{$.error("Method "+method+" does not exist on jQuery."+namespace)}}})(jQuery);

 

以上 是 chaffle.min.js

 a.html

  https://github.com/blivesta/chaffle 插件地址 

转载地址:http://gchbm.baihongyu.com/

你可能感兴趣的文章
[POI2000]病毒
查看>>
item字母问题
查看>>
建立私有仓库
查看>>
ios页面保存至桌面logo大小
查看>>
ios开发之--给WebView加载进度条
查看>>
截断表
查看>>
jq返回顶部多种实现方法
查看>>
Hadoop_HDFS文件读写代码流程解析和副本存放机制
查看>>
Linux cat
查看>>
HDU 6052 To my boyfriend(容斥+单调栈)
查看>>
jQuery鼠标拖曳改变div大小(模拟textarea右下角拖曳)
查看>>
数据仓库建模对比: 比较表格和多维解决方案 (Comparing tabular and multidimensional solutions)...
查看>>
2.mongoDB 介绍(特点、优点、原理)
查看>>
JSON的三种解析方式
查看>>
1.JSONObject与JSONArray的使用
查看>>
web前端面试题:
查看>>
让linux下的eclipse支持GBK编码
查看>>
Codeforces Round #295 D. Cubes [贪心 set map]
查看>>
leetcode 326. Power of Three
查看>>
Django timezone问题
查看>>