@arwes/text
Advanced tools
Comparing version 1.0.0-next.7 to 1.0.0-next.24041801
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
tslib_1.__exportStar(require("./types"), exports); | ||
tslib_1.__exportStar(require("./transitionTextSequence/index"), exports); | ||
tslib_1.__exportStar(require("./transitionTextDecipher/index"), exports); | ||
tslib_1.__exportStar(require("./getTransitionTextDuration/index"), exports); | ||
tslib_1.__exportStar(require("./types.js"), exports); | ||
tslib_1.__exportStar(require("./transitionTextSequence/index.js"), exports); | ||
tslib_1.__exportStar(require("./transitionTextDecipher/index.js"), exports); | ||
tslib_1.__exportStar(require("./getTransitionTextDuration/index.js"), exports); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
tslib_1.__exportStar(require("./getTransitionTextDuration"), exports); | ||
tslib_1.__exportStar(require("./getTransitionTextDuration.js"), exports); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
tslib_1.__exportStar(require("./types"), exports); | ||
tslib_1.__exportStar(require("./transitionTextSequence/index"), exports); | ||
tslib_1.__exportStar(require("./transitionTextDecipher/index"), exports); | ||
tslib_1.__exportStar(require("./getTransitionTextDuration/index"), exports); | ||
tslib_1.__exportStar(require("./types.js"), exports); | ||
tslib_1.__exportStar(require("./transitionTextSequence/index.js"), exports); | ||
tslib_1.__exportStar(require("./transitionTextDecipher/index.js"), exports); | ||
tslib_1.__exportStar(require("./getTransitionTextDuration/index.js"), exports); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
tslib_1.__exportStar(require("./setTextNodesContent"), exports); | ||
tslib_1.__exportStar(require("./setTextNodesContent.js"), exports); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
tslib_1.__exportStar(require("./walkTextNodes"), exports); | ||
tslib_1.__exportStar(require("./walkTextNodes.js"), exports); |
@@ -5,3 +5,3 @@ "use strict"; | ||
const walkTextNodes = (node, callback) => { | ||
Array.from(node.childNodes).forEach(child => { | ||
Array.from(node.childNodes).forEach((child) => { | ||
if (child.nodeType === Node.TEXT_NODE) { | ||
@@ -8,0 +8,0 @@ callback(child); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
tslib_1.__exportStar(require("./transitionTextDecipher"), exports); | ||
tslib_1.__exportStar(require("./transitionTextDecipher.js"), exports); |
@@ -6,4 +6,4 @@ "use strict"; | ||
const animated_1 = require("@arwes/animated"); | ||
const index_1 = require("../internal/walkTextNodes/index"); | ||
const index_2 = require("../internal/setTextNodesContent/index"); | ||
const index_js_1 = require("../internal/walkTextNodes/index.js"); | ||
const index_js_2 = require("../internal/setTextNodesContent/index.js"); | ||
const LETTERS = 'abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ>!·$%&/()=?¿≤|@#'; | ||
@@ -31,3 +31,3 @@ const transitionTextDecipher = (props) => { | ||
const textsReal = []; | ||
(0, index_1.walkTextNodes)(cloneElement, child => { | ||
(0, index_js_1.walkTextNodes)(cloneElement, (child) => { | ||
textNodes.push(child); | ||
@@ -38,3 +38,5 @@ textsReal.push(child.textContent || ''); | ||
// A list of all the characters indexes in random positions. | ||
const indexes = (0, tools_1.randomizeList)(Array(length).fill(null).map((_, i) => i)); | ||
const indexes = (0, tools_1.randomizeList)(Array(length) | ||
.fill(null) | ||
.map((_, i) => i)); | ||
// A record of all characters indexes with `true` to know if their character | ||
@@ -49,3 +51,3 @@ // is now deciphered/visible. | ||
direction: isEntering ? 'normal' : 'reverse', | ||
onUpdate: progress => { | ||
onUpdate: (progress) => { | ||
// When entering, the animation decipher characters over time. | ||
@@ -57,3 +59,3 @@ // When exiting, the animation will cipher characters over time. | ||
} | ||
const textsCurrent = textsReal.map(text => text | ||
const textsCurrent = textsReal.map((text) => text | ||
.split('') | ||
@@ -68,8 +70,7 @@ .map((char, index) => { | ||
.join('')); | ||
(0, index_2.setTextNodesContent)(textNodes, textsCurrent, length); | ||
(0, index_js_2.setTextNodesContent)(textNodes, textsCurrent, length); | ||
}, | ||
onComplete: () => { | ||
contentElement.style.visibility = (isEntering && hideOnEntered) || (!isEntering && hideOnExited) | ||
? 'hidden' | ||
: 'visible'; | ||
contentElement.style.visibility = | ||
(isEntering && hideOnEntered) || (!isEntering && hideOnExited) ? 'hidden' : 'visible'; | ||
cloneElement.remove(); | ||
@@ -76,0 +77,0 @@ }, |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
tslib_1.__exportStar(require("./transitionTextSequence"), exports); | ||
tslib_1.__exportStar(require("./transitionTextSequence.js"), exports); |
@@ -6,4 +6,4 @@ "use strict"; | ||
const animated_1 = require("@arwes/animated"); | ||
const index_1 = require("../internal/walkTextNodes/index"); | ||
const index_2 = require("../internal/setTextNodesContent/index"); | ||
const index_js_1 = require("../internal/walkTextNodes/index.js"); | ||
const index_js_2 = require("../internal/setTextNodesContent/index.js"); | ||
const transitionTextSequence = (props) => { | ||
@@ -41,3 +41,3 @@ const { rootElement, contentElement, duration, easing = 'linear', isEntering = true, hideOnExited = true, hideOnEntered } = props; | ||
const texts = []; | ||
(0, index_1.walkTextNodes)(cloneElement, child => { | ||
(0, index_js_1.walkTextNodes)(cloneElement, (child) => { | ||
textNodes.push(child); | ||
@@ -58,10 +58,9 @@ texts.push(child.textContent || ''); | ||
direction: isEntering ? 'normal' : 'reverse', | ||
onUpdate: progress => { | ||
onUpdate: (progress) => { | ||
const newLength = Math.round(progress * length); | ||
(0, index_2.setTextNodesContent)(textNodes, texts, newLength); | ||
(0, index_js_2.setTextNodesContent)(textNodes, texts, newLength); | ||
}, | ||
onComplete: () => { | ||
contentElement.style.visibility = (isEntering && hideOnEntered) || (!isEntering && hideOnExited) | ||
? 'hidden' | ||
: 'visible'; | ||
contentElement.style.visibility = | ||
(isEntering && hideOnEntered) || (!isEntering && hideOnExited) ? 'hidden' : 'visible'; | ||
cloneElement.remove(); | ||
@@ -68,0 +67,0 @@ blinkAnimation.cancel(); |
@@ -1,1 +0,1 @@ | ||
export * from './getTransitionTextDuration'; | ||
export * from './getTransitionTextDuration.js'; |
@@ -1,1 +0,1 @@ | ||
export * from "./getTransitionTextDuration.js"; | ||
export * from './getTransitionTextDuration.js'; |
@@ -1,4 +0,4 @@ | ||
export * from './types'; | ||
export * from './transitionTextSequence/index'; | ||
export * from './transitionTextDecipher/index'; | ||
export * from './getTransitionTextDuration/index'; | ||
export * from './types.js'; | ||
export * from './transitionTextSequence/index.js'; | ||
export * from './transitionTextDecipher/index.js'; | ||
export * from './getTransitionTextDuration/index.js'; |
@@ -1,4 +0,4 @@ | ||
export * from "./types.js"; | ||
export * from "./transitionTextSequence/index.js"; | ||
export * from "./transitionTextDecipher/index.js"; | ||
export * from "./getTransitionTextDuration/index.js"; | ||
export * from './types.js'; | ||
export * from './transitionTextSequence/index.js'; | ||
export * from './transitionTextDecipher/index.js'; | ||
export * from './getTransitionTextDuration/index.js'; |
@@ -1,1 +0,1 @@ | ||
export * from './setTextNodesContent'; | ||
export * from './setTextNodesContent.js'; |
@@ -1,1 +0,1 @@ | ||
export * from "./setTextNodesContent.js"; | ||
export * from './setTextNodesContent.js'; |
@@ -1,1 +0,1 @@ | ||
export * from './walkTextNodes'; | ||
export * from './walkTextNodes.js'; |
@@ -1,1 +0,1 @@ | ||
export * from "./walkTextNodes.js"; | ||
export * from './walkTextNodes.js'; |
const walkTextNodes = (node, callback) => { | ||
Array.from(node.childNodes).forEach(child => { | ||
Array.from(node.childNodes).forEach((child) => { | ||
if (child.nodeType === Node.TEXT_NODE) { | ||
@@ -4,0 +4,0 @@ callback(child); |
@@ -1,1 +0,1 @@ | ||
export * from './transitionTextDecipher'; | ||
export * from './transitionTextDecipher.js'; |
@@ -1,1 +0,1 @@ | ||
export * from "./transitionTextDecipher.js"; | ||
export * from './transitionTextDecipher.js'; |
import { type Animation } from '@arwes/animated'; | ||
import type { TextTransitionProps } from '../types'; | ||
import type { TextTransitionProps } from '../types.js'; | ||
declare const transitionTextDecipher: (props: TextTransitionProps) => Animation; | ||
export { transitionTextDecipher }; |
import { randomizeList } from '@arwes/tools'; | ||
import { createAnimation } from '@arwes/animated'; | ||
import { walkTextNodes } from "../internal/walkTextNodes/index.js"; | ||
import { setTextNodesContent } from "../internal/setTextNodesContent/index.js"; | ||
import { walkTextNodes } from '../internal/walkTextNodes/index.js'; | ||
import { setTextNodesContent } from '../internal/setTextNodesContent/index.js'; | ||
const LETTERS = 'abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ>!·$%&/()=?¿≤|@#'; | ||
@@ -27,3 +27,3 @@ const transitionTextDecipher = (props) => { | ||
const textsReal = []; | ||
walkTextNodes(cloneElement, child => { | ||
walkTextNodes(cloneElement, (child) => { | ||
textNodes.push(child); | ||
@@ -34,3 +34,5 @@ textsReal.push(child.textContent || ''); | ||
// A list of all the characters indexes in random positions. | ||
const indexes = randomizeList(Array(length).fill(null).map((_, i) => i)); | ||
const indexes = randomizeList(Array(length) | ||
.fill(null) | ||
.map((_, i) => i)); | ||
// A record of all characters indexes with `true` to know if their character | ||
@@ -45,3 +47,3 @@ // is now deciphered/visible. | ||
direction: isEntering ? 'normal' : 'reverse', | ||
onUpdate: progress => { | ||
onUpdate: (progress) => { | ||
// When entering, the animation decipher characters over time. | ||
@@ -53,3 +55,3 @@ // When exiting, the animation will cipher characters over time. | ||
} | ||
const textsCurrent = textsReal.map(text => text | ||
const textsCurrent = textsReal.map((text) => text | ||
.split('') | ||
@@ -67,5 +69,4 @@ .map((char, index) => { | ||
onComplete: () => { | ||
contentElement.style.visibility = (isEntering && hideOnEntered) || (!isEntering && hideOnExited) | ||
? 'hidden' | ||
: 'visible'; | ||
contentElement.style.visibility = | ||
(isEntering && hideOnEntered) || (!isEntering && hideOnExited) ? 'hidden' : 'visible'; | ||
cloneElement.remove(); | ||
@@ -72,0 +73,0 @@ }, |
@@ -1,1 +0,1 @@ | ||
export * from './transitionTextSequence'; | ||
export * from './transitionTextSequence.js'; |
@@ -1,1 +0,1 @@ | ||
export * from "./transitionTextSequence.js"; | ||
export * from './transitionTextSequence.js'; |
import { type Animation } from '@arwes/animated'; | ||
import type { TextTransitionProps } from '../types'; | ||
import type { TextTransitionProps } from '../types.js'; | ||
declare const transitionTextSequence: (props: TextTransitionProps) => Animation; | ||
export { transitionTextSequence }; |
import { animate } from 'motion'; | ||
import { createAnimation } from '@arwes/animated'; | ||
import { walkTextNodes } from "../internal/walkTextNodes/index.js"; | ||
import { setTextNodesContent } from "../internal/setTextNodesContent/index.js"; | ||
import { walkTextNodes } from '../internal/walkTextNodes/index.js'; | ||
import { setTextNodesContent } from '../internal/setTextNodesContent/index.js'; | ||
const transitionTextSequence = (props) => { | ||
@@ -37,3 +37,3 @@ const { rootElement, contentElement, duration, easing = 'linear', isEntering = true, hideOnExited = true, hideOnEntered } = props; | ||
const texts = []; | ||
walkTextNodes(cloneElement, child => { | ||
walkTextNodes(cloneElement, (child) => { | ||
textNodes.push(child); | ||
@@ -54,3 +54,3 @@ texts.push(child.textContent || ''); | ||
direction: isEntering ? 'normal' : 'reverse', | ||
onUpdate: progress => { | ||
onUpdate: (progress) => { | ||
const newLength = Math.round(progress * length); | ||
@@ -60,5 +60,4 @@ setTextNodesContent(textNodes, texts, newLength); | ||
onComplete: () => { | ||
contentElement.style.visibility = (isEntering && hideOnEntered) || (!isEntering && hideOnExited) | ||
? 'hidden' | ||
: 'visible'; | ||
contentElement.style.visibility = | ||
(isEntering && hideOnEntered) || (!isEntering && hideOnExited) ? 'hidden' : 'visible'; | ||
cloneElement.remove(); | ||
@@ -65,0 +64,0 @@ blinkAnimation.cancel(); |
{ | ||
"name": "@arwes/text", | ||
"version": "1.0.0-next.7", | ||
"version": "1.0.0-next.24041801", | ||
"publishConfig": { | ||
@@ -42,20 +42,17 @@ "access": "public" | ||
"main": "./build/cjs/index.js", | ||
"unpkg": "./build/umd/umd.min.js", | ||
"peerDependencies": { | ||
"@arwes/animated": "^1.0.0-next.3", | ||
"@arwes/tools": "^1.0.0-next.3", | ||
"motion": "10" | ||
}, | ||
"dependencies": { | ||
"tslib": "^2.3.1" | ||
"@arwes/animated": "^1.0.0-next.24041801", | ||
"@arwes/tools": "^1.0.0-next.24041801", | ||
"tslib": "2" | ||
}, | ||
"scripts": { | ||
"build": "npm run build-esm && npm run build-cjs && npm run build-umd && npm run build-types", | ||
"build": "npm run build-esm && npm run build-cjs", | ||
"build-esm": "sh ../../scripts/pkg-build-esm.sh", | ||
"build-cjs": "sh ../../scripts/pkg-build-cjs.sh", | ||
"build-umd": "sh ../../scripts/pkg-build-umd.sh", | ||
"build-types": "sh ../../scripts/pkg-build-types.sh", | ||
"dev": "sh ../../scripts/pkg-build-esm.sh --watch" | ||
}, | ||
"gitHead": "2ebdfdf47908d5c0100959660a9c3c08ccefbd69" | ||
"gitHead": "ee772f4eda2e2feb74a995234a2bc59667330d67" | ||
} |
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
22045
42
494
1
Updatedtslib@2