日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 前端技术 > HTML >内容正文

HTML

咖啡html代码,HTML5咖啡生成代码动画

發(fā)布時(shí)間:2025/3/12 HTML 17 豆豆
生活随笔 收集整理的這篇文章主要介紹了 咖啡html代码,HTML5咖啡生成代码动画 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

JavaScript

語言:

JaveScriptBabelCoffeeScript

確定

! function($) {

"use strict";

var Typed = function(el, options) {

// chosen element to manipulate text

this.el = $(el);

// options

this.options = $.extend({}, $.fn.typed.defaults, options);

// text content of element

this.text = this.el.text();

// typing speed

this.typeSpeed = this.options.typeSpeed;

// amount of time to wait before backspacing

this.backDelay = this.options.backDelay;

// input strings of text

this.strings = this.options.strings;

// character number position of current string

this.strPos = 0;

// current array position

this.arrayPos = 0;

// current string based on current values[] array position

this.string = this.strings[this.arrayPos];

// number to stop backspacing on.

// default 0, can change depending on how many chars

// you want to remove at the time

this.stopNum = 0;

// Looping logic

this.loop = this.options.loop;

this.loopCount = this.options.loopCount;

this.curLoop = 1;

if (this.loop === false) {

// number in which to stop going through array

// set to strings[] array (length - 1) to stop deleting after last string is typed

this.stopArray = this.strings.length - 1;

} else {

this.stopArray = this.strings.length;

}

// All systems go!

this.init();

this.build();

}

Typed.prototype = {

constructor: Typed

,

init: function() {

// begin the loop w/ first current string (global self.string)

// current string will be passed as an argument each time after this

this.typewrite(this.string, this.strPos);

}

,

build: function() {

//this.el.after("|");

}

// pass current string state to each function

,

typewrite: function(curString, curStrPos) {

// varying values for setTimeout during typing

// can't be global since number changes each time loop is executed

var humanize = Math.round(Math.random() * (100 - 30)) + this.typeSpeed;

var self = this;

// ------------- optional ------------- //

// backpaces a certain string faster

// ------------------------------------ //

// if (self.arrayPos == 1){

// self.backDelay = 50;

// }

// else{ self.backDelay = 500; }

// containg entire typing function in a timeout

setTimeout(function() {

// make sure array position is less than array length

if (self.arrayPos < self.strings.length) {

// start typing each new char into existing string

// curString is function arg

self.el.text(self.text + curString.substr(0, curStrPos));

// check if current character number is the string's length

// and if the current array position is less than the stopping point

// if so, backspace after backDelay setting

if (curStrPos > curString.length && self.arrayPos < self.stopArray) {

clearTimeout(clear);

var clear = setTimeout(function() {

self.backspace(curString, curStrPos);

}, self.backDelay);

}

// else, keep typing

else {

// add characters one by one

curStrPos++;

// loop the function

self.typewrite(curString, curStrPos);

// if the array position is at the stopping position

// finish code, on to next task

if (self.loop === false) {

if (self.arrayPos === self.stopArray && curStrPos === curString.length) {

// animation that occurs on the last typed string

// fires callback function

var clear = self.options.callback();

clearTimeout(clear);

}

}

}

}

// if the array position is greater than array length

// and looping is active, reset array pos and start over.

else if (self.loop === true && self.loopCount === false) {

self.arrayPos = 0;

self.init();

} else if (self.loopCount !== false && self.curLoop < self.loopCount) {

self.arrayPos = 0;

self.curLoop = self.curLoop + 1;

self.init();

}

// humanized value for typing

}, humanize);

}

,

backspace: function(curString, curStrPos) {

// varying values for setTimeout during typing

// can't be global since number changes each time loop is executed

var humanize = Math.round(Math.random() * (100 - 30)) + this.typeSpeed;

var self = this;

setTimeout(function() {

// ----- this part is optional ----- //

// check string array position

// on the first string, only delete one word

// the stopNum actually represents the amount of chars to

// keep in the current string. In my case it's 14.

// if (self.arrayPos == 1){

//self.stopNum = 14;

// }

//every other time, delete the whole typed string

// else{

//self.stopNum = 0;

// }

// ----- continue important stuff ----- //

// replace text with current text + typed characters

self.el.text(self.text + curString.substr(0, curStrPos));

// if the number (id of character in current string) is

// less than the stop number, keep going

if (curStrPos > self.stopNum) {

// subtract characters one by one

curStrPos--;

// loop the function

self.backspace(curString, curStrPos);

}

// if the stop number has been reached, increase

// array position to next string

else if (curStrPos <= self.stopNum) {

clearTimeout(clear);

var clear = self.arrayPos = self.arrayPos + 1;

// must pass new array position in this instance

// instead of using global arrayPos

self.typewrite(self.strings[self.arrayPos], curStrPos);

}

// humanized value for typing

}, humanize);

}

}

$.fn.typed = function(option) {

return this.each(function() {

var $this = $(this),

data = $this.data('typed'),

options = typeof option == 'object' && option

if (!data) $this.data('typed', (data = new Typed(this, options)))

if (typeof option == 'string') data[option]()

});

}

$.fn.typed.defaults = {

strings: ["These are the default values...", "You know what you should do?", "Use your own!", "Have a great day!"],

// typing and backspacing speed

typeSpeed: 0,

// time before backspacing

backDelay: 500,

// loop

loop: false,

// false = infinite

loopCount: false,

// ending callback function

callback: function() {

null

}

}

}(window.jQuery);

$(function() {

$(".element").typed({

strings: [" More coffee, more coffee ", " Coffee makes great code!", "html> More coffee, more coffee

總結(jié)

以上是生活随笔為你收集整理的咖啡html代码,HTML5咖啡生成代码动画的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。