react-type-animation
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -1,384 +0,2 @@ | ||
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var React = require('react'); | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var React__default = /*#__PURE__*/_interopDefaultLegacy(React); | ||
/****************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
function __awaiter(thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
} | ||
function __generator(thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
} | ||
function __values(o) { | ||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; | ||
if (m) return m.call(o); | ||
if (o && typeof o.length === "number") return { | ||
next: function () { | ||
if (o && i >= o.length) o = void 0; | ||
return { value: o && o[i++], done: !o }; | ||
} | ||
}; | ||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); | ||
} | ||
function __read(o, n) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator]; | ||
if (!m) return o; | ||
var i = m.call(o), r, ar = [], e; | ||
try { | ||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); | ||
} | ||
catch (error) { e = { error: error }; } | ||
finally { | ||
try { | ||
if (r && !r.done && (m = i["return"])) m.call(i); | ||
} | ||
finally { if (e) throw e.error; } | ||
} | ||
return ar; | ||
} | ||
function __spreadArray(to, from, pack) { | ||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { | ||
if (ar || !(i in from)) { | ||
if (!ar) ar = Array.prototype.slice.call(from, 0, i); | ||
ar[i] = from[i]; | ||
} | ||
} | ||
return to.concat(ar || Array.prototype.slice.call(from)); | ||
} | ||
function type(node, speed) { | ||
var args = []; | ||
for (var _i = 2; _i < arguments.length; _i++) { | ||
args[_i - 2] = arguments[_i]; | ||
} | ||
return __awaiter(this, void 0, void 0, function () { | ||
var args_1, args_1_1, arg, _a, e_1_1; | ||
var e_1, _b; | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
case 0: | ||
_c.trys.push([0, 12, 13, 14]); | ||
args_1 = __values(args), args_1_1 = args_1.next(); | ||
_c.label = 1; | ||
case 1: | ||
if (!!args_1_1.done) return [3 /*break*/, 11]; | ||
arg = args_1_1.value; | ||
_a = typeof arg; | ||
switch (_a) { | ||
case 'string': return [3 /*break*/, 2]; | ||
case 'number': return [3 /*break*/, 4]; | ||
case 'function': return [3 /*break*/, 6]; | ||
} | ||
return [3 /*break*/, 8]; | ||
case 2: return [4 /*yield*/, edit(node, arg, speed)]; | ||
case 3: | ||
_c.sent(); | ||
return [3 /*break*/, 10]; | ||
case 4: return [4 /*yield*/, wait(arg)]; | ||
case 5: | ||
_c.sent(); | ||
return [3 /*break*/, 10]; | ||
case 6: return [4 /*yield*/, arg.apply(void 0, __spreadArray([node, speed], __read(args), false))]; | ||
case 7: | ||
_c.sent(); | ||
return [3 /*break*/, 10]; | ||
case 8: return [4 /*yield*/, arg]; | ||
case 9: | ||
_c.sent(); | ||
_c.label = 10; | ||
case 10: | ||
args_1_1 = args_1.next(); | ||
return [3 /*break*/, 1]; | ||
case 11: return [3 /*break*/, 14]; | ||
case 12: | ||
e_1_1 = _c.sent(); | ||
e_1 = { error: e_1_1 }; | ||
return [3 /*break*/, 14]; | ||
case 13: | ||
try { | ||
if (args_1_1 && !args_1_1.done && (_b = args_1.return)) _b.call(args_1); | ||
} | ||
finally { if (e_1) throw e_1.error; } | ||
return [7 /*endfinally*/]; | ||
case 14: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
} | ||
function edit(node, text, speed) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var overlap; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
overlap = getOverlap(node.textContent, text); | ||
return [4 /*yield*/, perform(node, __spreadArray(__spreadArray([], __read(deleter(node.textContent, overlap)), false), __read(writer(text, overlap)), false), speed)]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
} | ||
function wait(ms) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, ms); })]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
} | ||
function perform(node, edits, speed) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var _a, _b, op, e_2_1; | ||
var e_2, _c; | ||
return __generator(this, function (_d) { | ||
switch (_d.label) { | ||
case 0: | ||
_d.trys.push([0, 5, 6, 7]); | ||
_a = __values(editor(edits)), _b = _a.next(); | ||
_d.label = 1; | ||
case 1: | ||
if (!!_b.done) return [3 /*break*/, 4]; | ||
op = _b.value; | ||
op(node); | ||
return [4 /*yield*/, wait(speed + speed * (Math.random() - 0.5))]; | ||
case 2: | ||
_d.sent(); | ||
_d.label = 3; | ||
case 3: | ||
_b = _a.next(); | ||
return [3 /*break*/, 1]; | ||
case 4: return [3 /*break*/, 7]; | ||
case 5: | ||
e_2_1 = _d.sent(); | ||
e_2 = { error: e_2_1 }; | ||
return [3 /*break*/, 7]; | ||
case 6: | ||
try { | ||
if (_b && !_b.done && (_c = _a.return)) _c.call(_a); | ||
} | ||
finally { if (e_2) throw e_2.error; } | ||
return [7 /*endfinally*/]; | ||
case 7: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
} | ||
function editor(edits) { | ||
var _loop_1, edits_1, edits_1_1, edit_1, e_3_1; | ||
var e_3, _a; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
_loop_1 = function (edit_1) { | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
case 0: return [4 /*yield*/, function (node) { return requestAnimationFrame(function () { return (node.textContent = edit_1); }); }]; | ||
case 1: | ||
_c.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}; | ||
_b.label = 1; | ||
case 1: | ||
_b.trys.push([1, 6, 7, 8]); | ||
edits_1 = __values(edits), edits_1_1 = edits_1.next(); | ||
_b.label = 2; | ||
case 2: | ||
if (!!edits_1_1.done) return [3 /*break*/, 5]; | ||
edit_1 = edits_1_1.value; | ||
return [5 /*yield**/, _loop_1(edit_1)]; | ||
case 3: | ||
_b.sent(); | ||
_b.label = 4; | ||
case 4: | ||
edits_1_1 = edits_1.next(); | ||
return [3 /*break*/, 2]; | ||
case 5: return [3 /*break*/, 8]; | ||
case 6: | ||
e_3_1 = _b.sent(); | ||
e_3 = { error: e_3_1 }; | ||
return [3 /*break*/, 8]; | ||
case 7: | ||
try { | ||
if (edits_1_1 && !edits_1_1.done && (_a = edits_1.return)) _a.call(edits_1); | ||
} | ||
finally { if (e_3) throw e_3.error; } | ||
return [7 /*endfinally*/]; | ||
case 8: return [2 /*return*/]; | ||
} | ||
}); | ||
} | ||
function writer(_a, startIndex, endIndex) { | ||
var _b = __read(_a), text = _b.slice(0); | ||
if (startIndex === void 0) { startIndex = 0; } | ||
if (endIndex === void 0) { endIndex = text.length; } | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
case 0: | ||
if (!(startIndex < endIndex)) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, text.slice(0, ++startIndex).join('')]; | ||
case 1: | ||
_c.sent(); | ||
return [3 /*break*/, 0]; | ||
case 2: return [2 /*return*/]; | ||
} | ||
}); | ||
} | ||
function deleter(_a, startIndex, endIndex) { | ||
var _b = __read(_a), text = _b.slice(0); | ||
if (startIndex === void 0) { startIndex = 0; } | ||
if (endIndex === void 0) { endIndex = text.length; } | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
case 0: | ||
if (!(endIndex > startIndex)) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, text.slice(0, --endIndex).join('')]; | ||
case 1: | ||
_c.sent(); | ||
return [3 /*break*/, 0]; | ||
case 2: return [2 /*return*/]; | ||
} | ||
}); | ||
} | ||
function getOverlap(start, _a) { | ||
var _b = __read(_a), end = _b.slice(0); | ||
return __spreadArray(__spreadArray([], __read(start), false), [NaN], false).findIndex(function (char, i) { return end[i] !== char; }); | ||
} | ||
function styleInject(css, ref) { | ||
if ( ref === void 0 ) ref = {}; | ||
var insertAt = ref.insertAt; | ||
if (!css || typeof document === 'undefined') { return; } | ||
var head = document.head || document.getElementsByTagName('head')[0]; | ||
var style = document.createElement('style'); | ||
style.type = 'text/css'; | ||
if (insertAt === 'top') { | ||
if (head.firstChild) { | ||
head.insertBefore(style, head.firstChild); | ||
} else { | ||
head.appendChild(style); | ||
} | ||
} else { | ||
head.appendChild(style); | ||
} | ||
if (style.styleSheet) { | ||
style.styleSheet.cssText = css; | ||
} else { | ||
style.appendChild(document.createTextNode(css)); | ||
} | ||
} | ||
var css = ".index-module_type__1pV_J::after {\n content: '|';\n animation: index-module_cursor__1t4b- 1.1s infinite step-start;\n}\n\n@keyframes index-module_cursor__1t4b- {\n 50% {\n opacity: 0;\n }\n}\n"; | ||
var styles = {"type":"index-module_type__1pV_J","cursor":"index-module_cursor__1t4b-"}; | ||
styleInject(css); | ||
var TypeAnimation = function (_a) { | ||
var sequence = _a.sequence, repeat = _a.repeat, className = _a.className, _b = _a.speed, speed = _b === void 0 ? 40 : _b, _c = _a.wrapper, wrapper = _c === void 0 ? 'div' : _c, _d = _a.cursor, cursor = _d === void 0 ? true : _d, style = _a.style; | ||
speed = Math.abs(speed - 100); | ||
var typeRef = React.useRef(null); | ||
var baseStyle = styles.type; | ||
var finalClassName; | ||
if (className && className.length > 0) { | ||
if (!cursor) { | ||
finalClassName = className; | ||
} | ||
else { | ||
finalClassName = "".concat(baseStyle, " ").concat(className); | ||
} | ||
} | ||
else { | ||
if (!cursor) { | ||
finalClassName = ''; | ||
} | ||
else { | ||
finalClassName = baseStyle; | ||
} | ||
} | ||
React.useEffect(function () { | ||
if (repeat === Infinity) { | ||
type.apply(void 0, __spreadArray(__spreadArray([typeRef.current, speed], __read(sequence), false), [type], false)); | ||
} | ||
else if (typeof repeat === 'number') { | ||
type.apply(void 0, __spreadArray([typeRef.current, | ||
speed], __read(Array(repeat) | ||
.fill(sequence) | ||
.flat()), false)); | ||
} | ||
else { | ||
type.apply(void 0, __spreadArray([typeRef.current, speed], __read(sequence), false)); | ||
} | ||
}); | ||
var Wrapper = wrapper; | ||
return React__default["default"].createElement(Wrapper, { style: style, className: finalClassName, ref: typeRef }); | ||
}; | ||
var index = React.memo(TypeAnimation, function (_, __) { | ||
return true; // IMMUTABLE! | ||
}); | ||
exports.TypeAnimation = index; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=t(e);function r(e,t,n,r){return new(n||(n=Promise))((function(a,o){function u(e){try{c(r.next(e))}catch(e){o(e)}}function i(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(u,i)}c((r=r.apply(e,t||[])).next())}))}function a(e,t){var n,r,a,o,u={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function i(o){return function(i){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(a=2&o[0]?r.return:o[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,o[1])).done)return a;switch(r=0,a&&(o=[2&o[0],a.value]),o[0]){case 0:case 1:a=o;break;case 4:return u.label++,{value:o[1],done:!1};case 5:u.label++,r=o[1],o=[0];continue;case 7:o=u.ops.pop(),u.trys.pop();continue;default:if(!(a=u.trys,(a=a.length>0&&a[a.length-1])||6!==o[0]&&2!==o[0])){u=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]<a[3])){u.label=o[1];break}if(6===o[0]&&u.label<a[1]){u.label=a[1],a=o;break}if(a&&u.label<a[2]){u.label=a[2],u.ops.push(o);break}a[2]&&u.ops.pop(),u.trys.pop();continue}o=t.call(e,u)}catch(e){o=[6,e],r=0}finally{n=a=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,i])}}}function o(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function u(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,a,o=n.call(e),u=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)u.push(r.value)}catch(e){a={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(a)throw a.error}}return u}function i(e,t,n){if(n||2===arguments.length)for(var r,a=0,o=t.length;a<o;a++)!r&&a in t||(r||(r=Array.prototype.slice.call(t,0,a)),r[a]=t[a]);return e.concat(r||Array.prototype.slice.call(t))}function c(e,t){for(var n=[],c=2;c<arguments.length;c++)n[c-2]=arguments[c];return r(this,void 0,void 0,(function(){var r,c,f,d,h,y;return a(this,(function(a){switch(a.label){case 0:a.trys.push([0,12,13,14]),r=o(n),c=r.next(),a.label=1;case 1:if(c.done)return[3,11];switch(f=c.value,typeof f){case"string":return[3,2];case"number":return[3,4];case"function":return[3,6]}return[3,8];case 2:return[4,s(e,f,t)];case 3:return a.sent(),[3,10];case 4:return[4,l(f)];case 5:return a.sent(),[3,10];case 6:return[4,f.apply(void 0,i([e,t],u(n),!1))];case 7:return a.sent(),[3,10];case 8:return[4,f];case 9:a.sent(),a.label=10;case 10:return c=r.next(),[3,1];case 11:return[3,14];case 12:return d=a.sent(),h={error:d},[3,14];case 13:try{c&&!c.done&&(y=r.return)&&y.call(r)}finally{if(h)throw h.error}return[7];case 14:return[2]}}))}))}function s(e,t,n){return r(this,void 0,void 0,(function(){var r;return a(this,(function(a){switch(a.label){case 0:return r=function(e,t){var n=u(t).slice(0);return i(i([],u(e),!1),[NaN],!1).findIndex((function(e,t){return n[t]!==e}))}(e.textContent,t),[4,f(e,i(i([],u(h(e.textContent,r)),!1),u(d(t,r)),!1),n)];case 1:return a.sent(),[2]}}))}))}function l(e){return r(this,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,new Promise((function(t){return setTimeout(t,e)}))];case 1:return t.sent(),[2]}}))}))}function f(e,t,n){return r(this,void 0,void 0,(function(){var r,u,i,c,s;return a(this,(function(f){switch(f.label){case 0:f.trys.push([0,5,6,7]),r=o(function(e){var t,n,r,u,i,c,s;return a(this,(function(l){switch(l.label){case 0:t=function(e){return a(this,(function(t){switch(t.label){case 0:return[4,function(t){return requestAnimationFrame((function(){return t.textContent=e}))}];case 1:return t.sent(),[2]}}))},l.label=1;case 1:l.trys.push([1,6,7,8]),n=o(e),r=n.next(),l.label=2;case 2:return r.done?[3,5]:(u=r.value,[5,t(u)]);case 3:l.sent(),l.label=4;case 4:return r=n.next(),[3,2];case 5:return[3,8];case 6:return i=l.sent(),c={error:i},[3,8];case 7:try{r&&!r.done&&(s=n.return)&&s.call(n)}finally{if(c)throw c.error}return[7];case 8:return[2]}}))}(t)),u=r.next(),f.label=1;case 1:return u.done?[3,4]:((0,u.value)(e),[4,l(n+n*(Math.random()-.5))]);case 2:f.sent(),f.label=3;case 3:return u=r.next(),[3,1];case 4:return[3,7];case 5:return i=f.sent(),c={error:i},[3,7];case 6:try{u&&!u.done&&(s=r.return)&&s.call(r)}finally{if(c)throw c.error}return[7];case 7:return[2]}}))}))}function d(e,t,n){var r=u(e).slice(0);return void 0===t&&(t=0),void 0===n&&(n=r.length),a(this,(function(e){switch(e.label){case 0:return t<n?[4,r.slice(0,++t).join("")]:[3,2];case 1:return e.sent(),[3,0];case 2:return[2]}}))}function h(e,t,n){var r=u(e).slice(0);return void 0===t&&(t=0),void 0===n&&(n=r.length),a(this,(function(e){switch(e.label){case 0:return n>t?[4,r.slice(0,--n).join("")]:[3,2];case 1:return e.sent(),[3,0];case 2:return[2]}}))}var y="index-module_type__1pV_J";!function(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css","top"===n&&r.firstChild?r.insertBefore(a,r.firstChild):r.appendChild(a),a.styleSheet?a.styleSheet.cssText=e:a.appendChild(document.createTextNode(e))}}(".index-module_type__1pV_J::after {\n content: '|';\n animation: index-module_cursor__1t4b- 1.1s infinite step-start;\n}\n\n@keyframes index-module_cursor__1t4b- {\n 50% {\n opacity: 0;\n }\n}\n");var p=e.memo((function(t){var r=t.sequence,a=t.repeat,o=t.className,s=t.speed,l=void 0===s?40:s,f=t.wrapper,d=void 0===f?"div":f,h=t.cursor,p=void 0===h||h,v=t.style;l=Math.abs(l-100);var b,m=e.useRef(null),w=y;b=o&&o.length>0?p?"".concat(w," ").concat(o):o:p?w:"",e.useEffect((function(){a===1/0?c.apply(void 0,i(i([m.current,l],u(r),!1),[c],!1)):"number"==typeof a?c.apply(void 0,i([m.current,l],u(Array(a).fill(r).flat()),!1)):c.apply(void 0,i([m.current,l],u(r),!1))}));var x=d;return n.default.createElement(x,{style:v,className:b,ref:m})}),(function(e,t){return!0}));exports.TypeAnimation=p; | ||
//# sourceMappingURL=index.js.map |
@@ -1,376 +0,2 @@ | ||
import React, { memo, useRef, useEffect } from 'react'; | ||
/****************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
function __awaiter(thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
} | ||
function __generator(thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
} | ||
function __values(o) { | ||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; | ||
if (m) return m.call(o); | ||
if (o && typeof o.length === "number") return { | ||
next: function () { | ||
if (o && i >= o.length) o = void 0; | ||
return { value: o && o[i++], done: !o }; | ||
} | ||
}; | ||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); | ||
} | ||
function __read(o, n) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator]; | ||
if (!m) return o; | ||
var i = m.call(o), r, ar = [], e; | ||
try { | ||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); | ||
} | ||
catch (error) { e = { error: error }; } | ||
finally { | ||
try { | ||
if (r && !r.done && (m = i["return"])) m.call(i); | ||
} | ||
finally { if (e) throw e.error; } | ||
} | ||
return ar; | ||
} | ||
function __spreadArray(to, from, pack) { | ||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { | ||
if (ar || !(i in from)) { | ||
if (!ar) ar = Array.prototype.slice.call(from, 0, i); | ||
ar[i] = from[i]; | ||
} | ||
} | ||
return to.concat(ar || Array.prototype.slice.call(from)); | ||
} | ||
function type(node, speed) { | ||
var args = []; | ||
for (var _i = 2; _i < arguments.length; _i++) { | ||
args[_i - 2] = arguments[_i]; | ||
} | ||
return __awaiter(this, void 0, void 0, function () { | ||
var args_1, args_1_1, arg, _a, e_1_1; | ||
var e_1, _b; | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
case 0: | ||
_c.trys.push([0, 12, 13, 14]); | ||
args_1 = __values(args), args_1_1 = args_1.next(); | ||
_c.label = 1; | ||
case 1: | ||
if (!!args_1_1.done) return [3 /*break*/, 11]; | ||
arg = args_1_1.value; | ||
_a = typeof arg; | ||
switch (_a) { | ||
case 'string': return [3 /*break*/, 2]; | ||
case 'number': return [3 /*break*/, 4]; | ||
case 'function': return [3 /*break*/, 6]; | ||
} | ||
return [3 /*break*/, 8]; | ||
case 2: return [4 /*yield*/, edit(node, arg, speed)]; | ||
case 3: | ||
_c.sent(); | ||
return [3 /*break*/, 10]; | ||
case 4: return [4 /*yield*/, wait(arg)]; | ||
case 5: | ||
_c.sent(); | ||
return [3 /*break*/, 10]; | ||
case 6: return [4 /*yield*/, arg.apply(void 0, __spreadArray([node, speed], __read(args), false))]; | ||
case 7: | ||
_c.sent(); | ||
return [3 /*break*/, 10]; | ||
case 8: return [4 /*yield*/, arg]; | ||
case 9: | ||
_c.sent(); | ||
_c.label = 10; | ||
case 10: | ||
args_1_1 = args_1.next(); | ||
return [3 /*break*/, 1]; | ||
case 11: return [3 /*break*/, 14]; | ||
case 12: | ||
e_1_1 = _c.sent(); | ||
e_1 = { error: e_1_1 }; | ||
return [3 /*break*/, 14]; | ||
case 13: | ||
try { | ||
if (args_1_1 && !args_1_1.done && (_b = args_1.return)) _b.call(args_1); | ||
} | ||
finally { if (e_1) throw e_1.error; } | ||
return [7 /*endfinally*/]; | ||
case 14: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
} | ||
function edit(node, text, speed) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var overlap; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
overlap = getOverlap(node.textContent, text); | ||
return [4 /*yield*/, perform(node, __spreadArray(__spreadArray([], __read(deleter(node.textContent, overlap)), false), __read(writer(text, overlap)), false), speed)]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
} | ||
function wait(ms) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, ms); })]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
} | ||
function perform(node, edits, speed) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var _a, _b, op, e_2_1; | ||
var e_2, _c; | ||
return __generator(this, function (_d) { | ||
switch (_d.label) { | ||
case 0: | ||
_d.trys.push([0, 5, 6, 7]); | ||
_a = __values(editor(edits)), _b = _a.next(); | ||
_d.label = 1; | ||
case 1: | ||
if (!!_b.done) return [3 /*break*/, 4]; | ||
op = _b.value; | ||
op(node); | ||
return [4 /*yield*/, wait(speed + speed * (Math.random() - 0.5))]; | ||
case 2: | ||
_d.sent(); | ||
_d.label = 3; | ||
case 3: | ||
_b = _a.next(); | ||
return [3 /*break*/, 1]; | ||
case 4: return [3 /*break*/, 7]; | ||
case 5: | ||
e_2_1 = _d.sent(); | ||
e_2 = { error: e_2_1 }; | ||
return [3 /*break*/, 7]; | ||
case 6: | ||
try { | ||
if (_b && !_b.done && (_c = _a.return)) _c.call(_a); | ||
} | ||
finally { if (e_2) throw e_2.error; } | ||
return [7 /*endfinally*/]; | ||
case 7: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
} | ||
function editor(edits) { | ||
var _loop_1, edits_1, edits_1_1, edit_1, e_3_1; | ||
var e_3, _a; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
_loop_1 = function (edit_1) { | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
case 0: return [4 /*yield*/, function (node) { return requestAnimationFrame(function () { return (node.textContent = edit_1); }); }]; | ||
case 1: | ||
_c.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}; | ||
_b.label = 1; | ||
case 1: | ||
_b.trys.push([1, 6, 7, 8]); | ||
edits_1 = __values(edits), edits_1_1 = edits_1.next(); | ||
_b.label = 2; | ||
case 2: | ||
if (!!edits_1_1.done) return [3 /*break*/, 5]; | ||
edit_1 = edits_1_1.value; | ||
return [5 /*yield**/, _loop_1(edit_1)]; | ||
case 3: | ||
_b.sent(); | ||
_b.label = 4; | ||
case 4: | ||
edits_1_1 = edits_1.next(); | ||
return [3 /*break*/, 2]; | ||
case 5: return [3 /*break*/, 8]; | ||
case 6: | ||
e_3_1 = _b.sent(); | ||
e_3 = { error: e_3_1 }; | ||
return [3 /*break*/, 8]; | ||
case 7: | ||
try { | ||
if (edits_1_1 && !edits_1_1.done && (_a = edits_1.return)) _a.call(edits_1); | ||
} | ||
finally { if (e_3) throw e_3.error; } | ||
return [7 /*endfinally*/]; | ||
case 8: return [2 /*return*/]; | ||
} | ||
}); | ||
} | ||
function writer(_a, startIndex, endIndex) { | ||
var _b = __read(_a), text = _b.slice(0); | ||
if (startIndex === void 0) { startIndex = 0; } | ||
if (endIndex === void 0) { endIndex = text.length; } | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
case 0: | ||
if (!(startIndex < endIndex)) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, text.slice(0, ++startIndex).join('')]; | ||
case 1: | ||
_c.sent(); | ||
return [3 /*break*/, 0]; | ||
case 2: return [2 /*return*/]; | ||
} | ||
}); | ||
} | ||
function deleter(_a, startIndex, endIndex) { | ||
var _b = __read(_a), text = _b.slice(0); | ||
if (startIndex === void 0) { startIndex = 0; } | ||
if (endIndex === void 0) { endIndex = text.length; } | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
case 0: | ||
if (!(endIndex > startIndex)) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, text.slice(0, --endIndex).join('')]; | ||
case 1: | ||
_c.sent(); | ||
return [3 /*break*/, 0]; | ||
case 2: return [2 /*return*/]; | ||
} | ||
}); | ||
} | ||
function getOverlap(start, _a) { | ||
var _b = __read(_a), end = _b.slice(0); | ||
return __spreadArray(__spreadArray([], __read(start), false), [NaN], false).findIndex(function (char, i) { return end[i] !== char; }); | ||
} | ||
function styleInject(css, ref) { | ||
if ( ref === void 0 ) ref = {}; | ||
var insertAt = ref.insertAt; | ||
if (!css || typeof document === 'undefined') { return; } | ||
var head = document.head || document.getElementsByTagName('head')[0]; | ||
var style = document.createElement('style'); | ||
style.type = 'text/css'; | ||
if (insertAt === 'top') { | ||
if (head.firstChild) { | ||
head.insertBefore(style, head.firstChild); | ||
} else { | ||
head.appendChild(style); | ||
} | ||
} else { | ||
head.appendChild(style); | ||
} | ||
if (style.styleSheet) { | ||
style.styleSheet.cssText = css; | ||
} else { | ||
style.appendChild(document.createTextNode(css)); | ||
} | ||
} | ||
var css = ".index-module_type__1pV_J::after {\n content: '|';\n animation: index-module_cursor__1t4b- 1.1s infinite step-start;\n}\n\n@keyframes index-module_cursor__1t4b- {\n 50% {\n opacity: 0;\n }\n}\n"; | ||
var styles = {"type":"index-module_type__1pV_J","cursor":"index-module_cursor__1t4b-"}; | ||
styleInject(css); | ||
var TypeAnimation = function (_a) { | ||
var sequence = _a.sequence, repeat = _a.repeat, className = _a.className, _b = _a.speed, speed = _b === void 0 ? 40 : _b, _c = _a.wrapper, wrapper = _c === void 0 ? 'div' : _c, _d = _a.cursor, cursor = _d === void 0 ? true : _d, style = _a.style; | ||
speed = Math.abs(speed - 100); | ||
var typeRef = useRef(null); | ||
var baseStyle = styles.type; | ||
var finalClassName; | ||
if (className && className.length > 0) { | ||
if (!cursor) { | ||
finalClassName = className; | ||
} | ||
else { | ||
finalClassName = "".concat(baseStyle, " ").concat(className); | ||
} | ||
} | ||
else { | ||
if (!cursor) { | ||
finalClassName = ''; | ||
} | ||
else { | ||
finalClassName = baseStyle; | ||
} | ||
} | ||
useEffect(function () { | ||
if (repeat === Infinity) { | ||
type.apply(void 0, __spreadArray(__spreadArray([typeRef.current, speed], __read(sequence), false), [type], false)); | ||
} | ||
else if (typeof repeat === 'number') { | ||
type.apply(void 0, __spreadArray([typeRef.current, | ||
speed], __read(Array(repeat) | ||
.fill(sequence) | ||
.flat()), false)); | ||
} | ||
else { | ||
type.apply(void 0, __spreadArray([typeRef.current, speed], __read(sequence), false)); | ||
} | ||
}); | ||
var Wrapper = wrapper; | ||
return React.createElement(Wrapper, { style: style, className: finalClassName, ref: typeRef }); | ||
}; | ||
var index = memo(TypeAnimation, function (_, __) { | ||
return true; // IMMUTABLE! | ||
}); | ||
export { index as TypeAnimation }; | ||
import e,{memo as t,useRef as n,useEffect as r}from"react";function a(e,t,n,r){return new(n||(n=Promise))((function(a,o){function i(e){try{c(r.next(e))}catch(e){o(e)}}function u(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,u)}c((r=r.apply(e,t||[])).next())}))}function o(e,t){var n,r,a,o,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(o){return function(u){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(a=2&o[0]?r.return:o[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,o[1])).done)return a;switch(r=0,a&&(o=[2&o[0],a.value]),o[0]){case 0:case 1:a=o;break;case 4:return i.label++,{value:o[1],done:!1};case 5:i.label++,r=o[1],o=[0];continue;case 7:o=i.ops.pop(),i.trys.pop();continue;default:if(!(a=i.trys,(a=a.length>0&&a[a.length-1])||6!==o[0]&&2!==o[0])){i=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]<a[3])){i.label=o[1];break}if(6===o[0]&&i.label<a[1]){i.label=a[1],a=o;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(o);break}a[2]&&i.ops.pop(),i.trys.pop();continue}o=t.call(e,i)}catch(e){o=[6,e],r=0}finally{n=a=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,u])}}}function i(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function u(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,a,o=n.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)i.push(r.value)}catch(e){a={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(a)throw a.error}}return i}function c(e,t,n){if(n||2===arguments.length)for(var r,a=0,o=t.length;a<o;a++)!r&&a in t||(r||(r=Array.prototype.slice.call(t,0,a)),r[a]=t[a]);return e.concat(r||Array.prototype.slice.call(t))}function s(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return a(this,void 0,void 0,(function(){var r,a,s,d,h,y;return o(this,(function(o){switch(o.label){case 0:o.trys.push([0,12,13,14]),r=i(n),a=r.next(),o.label=1;case 1:if(a.done)return[3,11];switch(s=a.value,typeof s){case"string":return[3,2];case"number":return[3,4];case"function":return[3,6]}return[3,8];case 2:return[4,l(e,s,t)];case 3:return o.sent(),[3,10];case 4:return[4,f(s)];case 5:return o.sent(),[3,10];case 6:return[4,s.apply(void 0,c([e,t],u(n),!1))];case 7:return o.sent(),[3,10];case 8:return[4,s];case 9:o.sent(),o.label=10;case 10:return a=r.next(),[3,1];case 11:return[3,14];case 12:return d=o.sent(),h={error:d},[3,14];case 13:try{a&&!a.done&&(y=r.return)&&y.call(r)}finally{if(h)throw h.error}return[7];case 14:return[2]}}))}))}function l(e,t,n){return a(this,void 0,void 0,(function(){var r;return o(this,(function(a){switch(a.label){case 0:return r=function(e,t){var n=u(t).slice(0);return c(c([],u(e),!1),[NaN],!1).findIndex((function(e,t){return n[t]!==e}))}(e.textContent,t),[4,d(e,c(c([],u(y(e.textContent,r)),!1),u(h(t,r)),!1),n)];case 1:return a.sent(),[2]}}))}))}function f(e){return a(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return[4,new Promise((function(t){return setTimeout(t,e)}))];case 1:return t.sent(),[2]}}))}))}function d(e,t,n){return a(this,void 0,void 0,(function(){var r,a,u,c,s;return o(this,(function(l){switch(l.label){case 0:l.trys.push([0,5,6,7]),r=i(function(e){var t,n,r,a,u,c,s;return o(this,(function(l){switch(l.label){case 0:t=function(e){return o(this,(function(t){switch(t.label){case 0:return[4,function(t){return requestAnimationFrame((function(){return t.textContent=e}))}];case 1:return t.sent(),[2]}}))},l.label=1;case 1:l.trys.push([1,6,7,8]),n=i(e),r=n.next(),l.label=2;case 2:return r.done?[3,5]:(a=r.value,[5,t(a)]);case 3:l.sent(),l.label=4;case 4:return r=n.next(),[3,2];case 5:return[3,8];case 6:return u=l.sent(),c={error:u},[3,8];case 7:try{r&&!r.done&&(s=n.return)&&s.call(n)}finally{if(c)throw c.error}return[7];case 8:return[2]}}))}(t)),a=r.next(),l.label=1;case 1:return a.done?[3,4]:((0,a.value)(e),[4,f(n+n*(Math.random()-.5))]);case 2:l.sent(),l.label=3;case 3:return a=r.next(),[3,1];case 4:return[3,7];case 5:return u=l.sent(),c={error:u},[3,7];case 6:try{a&&!a.done&&(s=r.return)&&s.call(r)}finally{if(c)throw c.error}return[7];case 7:return[2]}}))}))}function h(e,t,n){var r=u(e).slice(0);return void 0===t&&(t=0),void 0===n&&(n=r.length),o(this,(function(e){switch(e.label){case 0:return t<n?[4,r.slice(0,++t).join("")]:[3,2];case 1:return e.sent(),[3,0];case 2:return[2]}}))}function y(e,t,n){var r=u(e).slice(0);return void 0===t&&(t=0),void 0===n&&(n=r.length),o(this,(function(e){switch(e.label){case 0:return n>t?[4,r.slice(0,--n).join("")]:[3,2];case 1:return e.sent(),[3,0];case 2:return[2]}}))}var p="index-module_type__1pV_J";!function(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css","top"===n&&r.firstChild?r.insertBefore(a,r.firstChild):r.appendChild(a),a.styleSheet?a.styleSheet.cssText=e:a.appendChild(document.createTextNode(e))}}(".index-module_type__1pV_J::after {\n content: '|';\n animation: index-module_cursor__1t4b- 1.1s infinite step-start;\n}\n\n@keyframes index-module_cursor__1t4b- {\n 50% {\n opacity: 0;\n }\n}\n");var v=t((function(t){var a=t.sequence,o=t.repeat,i=t.className,l=t.speed,f=void 0===l?40:l,d=t.wrapper,h=void 0===d?"div":d,y=t.cursor,v=void 0===y||y,b=t.style;f=Math.abs(f-100);var m,w=n(null),x=p;m=i&&i.length>0?v?"".concat(x," ").concat(i):i:v?x:"",r((function(){o===1/0?s.apply(void 0,c(c([w.current,f],u(a),!1),[s],!1)):"number"==typeof o?s.apply(void 0,c([w.current,f],u(Array(o).fill(a).flat()),!1)):s.apply(void 0,c([w.current,f],u(a),!1))}));var g=h;return e.createElement(g,{style:b,className:m,ref:w})}),(function(e,t){return!0}));export{v as TypeAnimation}; | ||
//# sourceMappingURL=index.es.js.map |
{ | ||
"name": "react-type-animation", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "React typing animation based on typical.", | ||
@@ -5,0 +5,0 @@ "author": "max37", |
@@ -27,5 +27,5 @@ # react-type-animation | ||
sequence={[ | ||
'One', 1000, 'Two', 2000, 'Three', | ||
() => { | ||
console.log('Done typing!'); | ||
'One', 1000, 'Two', 2000, 'Two Three', // Types 'One', waits 1s, Deletes 'One' and types 'Two', waits 2s, writes 'Three' without deleiting 'Two' | ||
() => { | ||
console.log('Done typing!'); // Place optional callbacks anywhere in the array | ||
} | ||
@@ -75,3 +75,3 @@ ]} | ||
| `wrapper` | no | string | `p`,`h2`,`div`, `strong` | HTML element tag that wraps the Animation | `div` | | ||
| `speed` | no | number | `55`, `65` | Speed Of Animation: The lower the slower | `65` | | ||
| `speed` | no | number | `55`, `65` | Speed Of Animation: The lower the slower | `60` | | ||
| `repeat` | no | number | `3`, `0`, `Infinity` | Amount of animation repetitions | `0` | | ||
@@ -78,0 +78,0 @@ | `cursor` | no | boolean | `false`, `true` | Display default blinking cursor css-animation | `true` | |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
65914
93
2
1