jquery占位符动画插件Placeholdem代码

版权:原创 更新时间:1年以上
[该文章底部包含文件资源,可根据自己情况,决定是否下载资源使用,时间>金钱,如有需要,立即查看资源]

以下是 jquery占位符动画插件Placeholdem代码 的示例演示效果:

当前平台(PC电脑)
  • 平台:

部分效果截图:

jquery占位符动画插件Placeholdem代码

HTML代码(index.html):

<!doctype html>
<html>
	<head>
		<meta charset="gb2312" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
		<link href="assets/css/style.min.css" rel="stylesheet" />
		<title>jquery占位符动画插件Placeholdem</title>
	</head>
	<body>
		<div class="container">
			<h3 class="fade">Try It</h3>
			<form>
				<label class="fade">
					<input name="field1" placeholder="Triggered on Focus/Blur" />
					<div class="arrow"></div>
				</label>
				<label class="fade">
					<textarea name="field2" placeholder="Inputs or Textareas"></textarea>
					<div class="arrow"></div>
				</label>
			</form>
		</div>
		<script src="placeholdem.min.js"></script>
		<script>
			Placeholdem( document.querySelectorAll( '[placeholder]' ) );

			var fadeElems = document.body.querySelectorAll( '.fade' ),
				fadeElemsLength = fadeElems.length,
				i = 0,
				interval = 50;

				function incFade() {
					if( i < fadeElemsLength ) {
						fadeElems[ i ].className += ' fade-load';
						i++;
						setTimeout( incFade, interval );
					}
				}

				setTimeout( incFade, interval );
		</script>
</body>
</html>







JS代码(gulpfile.js):

// Load pluginsvar gulp = require('gulp'),sass = require('gulp-ruby-sass'),autoprefixer = require('gulp-autoprefixer'),minifycss = require('gulp-minify-css'),jshint = require('gulp-jshint'),uglify = require('gulp-uglify'),rename = require('gulp-rename'),watch = require('gulp-watch');
	plumber = require('gulp-plumber');
	header = require('gulp-header');
	gulp.task('default',function(){
	var pkg = require('./package.json');
	var banner = ['/**',' * <%= pkg.name %> - <%= pkg.description %>',' * v<%= pkg.version %> - <%= pkg.license %> License',' * <%= pkg.homepage %> - <%= pkg.repository.url %>',' * by <%= pkg.author.name %> - @jackrugile',' */
','',''].join('\n');
	gulp.src('assets/scss/style.scss').pipe(watch()).pipe(plumber()).pipe(sass({
	style:'expanded',lineNumbers:true}
)).pipe(autoprefixer('last 2 version','safari 5','ie 8','ie 9','opera 12.1','ios 6','android 4')).pipe(gulp.dest('assets/css')).pipe(rename({
	suffix:'.min'}
)).pipe(minifycss()).pipe(gulp.dest('assets/css'))gulp.src('placeholdem.js').pipe(watch()).pipe(plumber()).pipe(jshint()).pipe(jshint.reporter('default')).pipe(rename({
	suffix:'.min'}
)).pipe(uglify()).pipe(header(banner,{
	pkg:pkg}
)).pipe(gulp.dest(''))}
);
	

JS代码(placeholdem.min.js):

/** * Placeholdem - Placeholder Caret Animation * v1.0.1 - MIT License * http://placeholdem.jackrugile.com - git://github.com/jackrugile/placeholdem.git * by Jack Rugile - @jackrugile */
function Placeholdem(e){
	"use strict";
	!function(){
	for(var e=0,n=["ms","moz","webkit","o"],a=0;
	a<n.length&&!window.requestAnimationFrame;
	++a)window.requestAnimationFrame=window[n[a]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[n[a]+"CancelAnimationFrame"]||window[n[a]+"CancelRequestAnimationFrame"];
	window.requestAnimationFrame||(window.requestAnimationFrame=function(n){
	var a=(new Date).getTime(),i=Math.max(0,16-(a-e)),l=window.setTimeout(function(){
	n(a+i)}
,i);
	return e=a+i,l}
),window.cancelAnimationFrame||(window.cancelAnimationFrame=function(e){
	clearTimeout(e)}
)}
();
	var n={
}
;
	return n.init=function(){
	if(n.elems=[],e&&e.length)for(var a=0;
	a<e.length;
	a++)n.hasPlaceholder(e[a])&&n.elems.push(new n.PlaceholdemElem(e[a]));
	else e&&n.hasPlaceholder(e)&&n.elems.push(new n.PlaceholdemElem(e))}
,n.hasPlaceholder=function(e){
	return"function"==typeof e.hasAttribute&&e.hasAttribute("placeholder")}
,n.PlaceholdemElem=function(e){
	var n=this;
	n.init=function(){
	n.elem=e,n.placeholder=n.elem.getAttribute("placeholder"),n.elem.removeAttribute("placeholder"),n.rAF=null,n.animating=0,n.elem.value||(n.elem.value=n.placeholder),n.on(n.elem,"focus",n.onFocus),n.on(n.elem,"blur",n.onBlur),n.on(n.elem,"keydown",n.onKeydown)}
,n.on=function(e,n,a){
	e.addEventListener?e.addEventListener(n,a):e.attachEvent("on"+n,a)}
,n.onFocus=function(){
	(n.animating||n.elem.value===n.placeholder)&&(n.animating=1,window.cancelAnimationFrame(n.rAF),n.deletePlaceholder())}
,n.onBlur=function(){
	(n.animating||""===n.elem.value)&&(n.animating=1,window.cancelAnimationFrame(n.rAF),n.restorePlaceholder())}
,n.onKeydown=function(){
	n.animating&&(n.animating=0,window.cancelAnimationFrame(n.rAF),n.elem.value="")}
,n.deletePlaceholder=function(){
	n.elem.value.length>0?(n.elem.value=n.elem.value.slice(0,-1),n.rAF=window.requestAnimationFrame(n.deletePlaceholder)):n.animating=0}
,n.restorePlaceholder=function(){
	n.elem.value.length<n.placeholder.length?(n.elem.value+=n.placeholder[n.elem.value.length],n.rAF=window.requestAnimationFrame(n.restorePlaceholder)):n.animating=0}
,n.init()}
,n.init(),n}
附件:下载该文件资源,减少时间成本(增值服务)
留言
该资源可下载
File Source
.rar
12.68 KB
Html 动画效果2
最新结算
jquery虚拟键盘中文打字效果js代码
类型: .rar 金额: CNY 2.31¥ 状态: 待结算 详细>
jquery虚拟键盘中文打字效果js代码
类型: .rar 金额: CNY 0.29¥ 状态: 待结算 详细>
HTML5实现CSS滤镜图片切换特效代码
类型: .rar 金额: CNY 2.31¥ 状态: 待结算 详细>
jQuery头像裁剪插件cropbox js代码
类型: .rar 金额: CNY 0.29¥ 状态: 待结算 详细>
jQuery头像裁剪插件cropbox js代码
类型: .rar 金额: CNY 2.31¥ 状态: 待结算 详细>
CSS3制作3D图片立方体旋转特效
类型: .rar 金额: CNY 2.31¥ 状态: 待结算 详细>
CSS3制作3D图片立方体旋转特效
类型: .rar 金额: CNY 0.29¥ 状态: 待结算 详细>
CSS3制作3D图片立方体旋转特效
类型: .rar 金额: CNY 2.31¥ 状态: 待结算 详细>
CSS3制作3D图片立方体旋转特效
类型: .rar 金额: CNY 0.29¥ 状态: 待结算 详细>
jQuery+css3实现信封效果
类型: .rar 金额: CNY 0.29¥ 状态: 待结算 详细>
我们力求给您提供有用的文章,再此基础上,会附加营收资源,不做任何广告,让平台可以更好发展 若您发现您的权利被侵害,或使用了您的版权,请发邮件联系 sunlifel@foxmail.com ggbig觉得 : 不提供源码的文章不是好文章
合作伙伴
联系我们
  • QQ:21499807
  • 邮箱:sunlifel@foxmail.com
  • QQ扫一扫加QQ
    QQ扫一扫
Copyright 2023-2024 ggbig.com·皖ICP备2023004211号-1
打赏文章