install gsap
This commit is contained in:
1 parent
1fc081a048
commit
d9b2762b72
182 files changed
+111895
No files matched your search
+307
@@ -0,0 +1,307 @@
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
||||
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
||||
(global = global || self, factory(global.window = global.window || {}));
|
||||
}(this, (function (exports) { 'use strict';
|
||||
|
||||
var _trimExp = /(?:^\s+|\s+$)/g;
|
||||
var emojiExp = /([\uD800-\uDBFF][\uDC00-\uDFFF](?:[\u200D\uFE0F][\uD800-\uDBFF][\uDC00-\uDFFF]){2,}|\uD83D\uDC69(?:\u200D(?:(?:\uD83D\uDC69\u200D)?\uD83D\uDC67|(?:\uD83D\uDC69\u200D)?\uD83D\uDC66)|\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D(?:\uD83D\uDC69\u200D)?\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D(?:\uD83D\uDC69\u200D)?\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2642\u2640]\uFE0F|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDD27\uDCBC\uDD2C\uDE80\uDE92])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC6F\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3C-\uDD3E\uDDD6-\uDDDF])\u200D[\u2640\u2642]\uFE0F|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|(?:\u26F9|\uD83C[\uDFCC\uDFCB]|\uD83D\uDD75)(?:\uFE0F\u200D[\u2640\u2642]|(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642])\uFE0F|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2695\u2696\u2708]|\uD83D\uDC69\u200D[\u2695\u2696\u2708]|\uD83D\uDC68(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708]))\uFE0F|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83D\uDC69\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDD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C46-\uDC50\uDC66\uDC67\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDD1-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\u200D(?:(?:(?:\uD83D[\uDC68\uDC69])\u200D)?\uD83D\uDC67|(?:(?:\uD83D[\uDC68\uDC69])\u200D)?\uD83D\uDC66)|\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC69\uDC6E\uDC70-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD18-\uDD1C\uDD1E\uDD1F\uDD26\uDD30-\uDD39\uDD3D\uDD3E\uDDD1-\uDDDD])(?:\uDLine truncated
|
||||
function getText(e) {
|
||||
var type = e.nodeType,
|
||||
result = "";
|
||||
|
||||
if (type === 1 || type === 9 || type === 11) {
|
||||
if (typeof e.textContent === "string") {
|
||||
return e.textContent;
|
||||
} else {
|
||||
for (e = e.firstChild; e; e = e.nextSibling) {
|
||||
result += getText(e);
|
||||
}
|
||||
}
|
||||
} else if (type === 3 || type === 4) {
|
||||
return e.nodeValue;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
function emojiSafeSplit(text, delimiter, trim, preserveSpaces, unescapedCharCodes) {
|
||||
text += "";
|
||||
trim && (text = text.trim ? text.trim() : text.replace(_trimExp, ""));
|
||||
|
||||
if (delimiter && delimiter !== "") {
|
||||
return text.replace(/>/g, ">").replace(/</g, "<").split(delimiter);
|
||||
}
|
||||
|
||||
var result = [],
|
||||
l = text.length,
|
||||
i = 0,
|
||||
j,
|
||||
character;
|
||||
|
||||
for (; i < l; i++) {
|
||||
character = text.charAt(i);
|
||||
|
||||
if (character.charCodeAt(0) >= 0xD800 && character.charCodeAt(0) <= 0xDBFF || text.charCodeAt(i + 1) >= 0xFE00 && text.charCodeAt(i + 1) <= 0xFE0F) {
|
||||
j = ((text.substr(i, 12).split(emojiExp) || [])[1] || "").length || 2;
|
||||
character = text.substr(i, j);
|
||||
result.emoji = 1;
|
||||
i += j - 1;
|
||||
}
|
||||
|
||||
result.push(unescapedCharCodes ? character : character === ">" ? ">" : character === "<" ? "<" : preserveSpaces && character === " " && (text.charAt(i - 1) === " " || text.charAt(i + 1) === " ") ? " " : character);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*!
|
||||
* ScrambleTextPlugin 3.14.2
|
||||
* https://gsap.com
|
||||
*
|
||||
* @license Copyright 2008-2025, GreenSock. All rights reserved.
|
||||
* Subject to the terms at https://gsap.com/standard-license
|
||||
* @author: Jack Doyle, jack@greensock.com
|
||||
*/
|
||||
|
||||
var CharSet = function () {
|
||||
function CharSet(chars) {
|
||||
this.chars = emojiSafeSplit(chars);
|
||||
this.sets = [];
|
||||
this.length = 50;
|
||||
|
||||
for (var i = 0; i < 20; i++) {
|
||||
this.sets[i] = _scrambleText(80, this.chars);
|
||||
}
|
||||
}
|
||||
|
||||
var _proto = CharSet.prototype;
|
||||
|
||||
_proto.grow = function grow(newLength) {
|
||||
for (var i = 0; i < 20; i++) {
|
||||
this.sets[i] += _scrambleText(newLength - this.length, this.chars);
|
||||
}
|
||||
|
||||
this.length = newLength;
|
||||
};
|
||||
|
||||
return CharSet;
|
||||
}();
|
||||
|
||||
var gsap,
|
||||
_coreInitted,
|
||||
_getGSAP = function _getGSAP() {
|
||||
return gsap || typeof window !== "undefined" && (gsap = window.gsap) && gsap.registerPlugin && gsap;
|
||||
},
|
||||
_bonusValidated = 1,
|
||||
_spacesExp = /\s+/g,
|
||||
_scrambleText = function _scrambleText(length, chars) {
|
||||
var l = chars.length,
|
||||
s = "";
|
||||
|
||||
while (--length > -1) {
|
||||
s += chars[~~(Math.random() * l)];
|
||||
}
|
||||
|
||||
return s;
|
||||
},
|
||||
_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
||||
_lower = _upper.toLowerCase(),
|
||||
_charsLookup = {
|
||||
upperCase: new CharSet(_upper),
|
||||
lowerCase: new CharSet(_lower),
|
||||
upperAndLowerCase: new CharSet(_upper + _lower)
|
||||
},
|
||||
_initCore = function _initCore() {
|
||||
_coreInitted = gsap = _getGSAP();
|
||||
};
|
||||
|
||||
var ScrambleTextPlugin = {
|
||||
version: "3.14.2",
|
||||
name: "scrambleText",
|
||||
register: function register(core, Plugin, propTween) {
|
||||
gsap = core;
|
||||
|
||||
_initCore();
|
||||
},
|
||||
init: function init(target, value, tween, index, targets) {
|
||||
_coreInitted || _initCore();
|
||||
this.prop = "innerHTML" in target ? "innerHTML" : "textContent" in target ? "textContent" : 0;
|
||||
|
||||
if (!this.prop) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.target = target;
|
||||
|
||||
if (typeof value !== "object") {
|
||||
value = {
|
||||
text: value
|
||||
};
|
||||
}
|
||||
|
||||
var text = value.text || value.value || "",
|
||||
trim = value.trim !== false,
|
||||
data = this,
|
||||
delim,
|
||||
maxLength,
|
||||
charset,
|
||||
splitByChars;
|
||||
data.delimiter = delim = value.delimiter || "";
|
||||
data.original = emojiSafeSplit(getText(target).replace(_spacesExp, " ").split(" ").join(""), delim, trim);
|
||||
|
||||
if (text === "{original}" || text === true || text == null) {
|
||||
text = data.original.join(delim);
|
||||
}
|
||||
|
||||
data.text = emojiSafeSplit((text || "").replace(_spacesExp, " "), delim, trim);
|
||||
data.hasClass = !!(value.newClass || value.oldClass);
|
||||
data.newClass = value.newClass;
|
||||
data.oldClass = value.oldClass;
|
||||
splitByChars = delim === "";
|
||||
data.textHasEmoji = splitByChars && !!data.text.emoji;
|
||||
data.charsHaveEmoji = !!value.chars && !!emojiSafeSplit(value.chars).emoji;
|
||||
data.length = splitByChars ? data.original.length : data.original.join(delim).length;
|
||||
data.lengthDif = (splitByChars ? data.text.length : data.text.join(delim).length) - data.length;
|
||||
data.fillChar = value.fillChar || value.chars && ~value.chars.indexOf(" ") ? " " : "";
|
||||
data.charSet = charset = _charsLookup[value.chars || "upperCase"] || new CharSet(value.chars);
|
||||
data.speed = 0.05 / (value.speed || 1);
|
||||
data.prevScrambleTime = 0;
|
||||
data.setIndex = Math.random() * 20 | 0;
|
||||
maxLength = data.length + Math.max(data.lengthDif, 0);
|
||||
|
||||
if (maxLength > charset.length) {
|
||||
charset.grow(maxLength);
|
||||
}
|
||||
|
||||
data.chars = charset.sets[data.setIndex];
|
||||
data.revealDelay = value.revealDelay || 0;
|
||||
data.tweenLength = value.tweenLength !== false;
|
||||
data.tween = tween;
|
||||
data.rightToLeft = !!value.rightToLeft;
|
||||
|
||||
data._props.push("scrambleText", "text");
|
||||
|
||||
return _bonusValidated;
|
||||
},
|
||||
render: function render(ratio, data) {
|
||||
var target = data.target,
|
||||
prop = data.prop,
|
||||
text = data.text,
|
||||
delimiter = data.delimiter,
|
||||
tween = data.tween,
|
||||
prevScrambleTime = data.prevScrambleTime,
|
||||
revealDelay = data.revealDelay,
|
||||
setIndex = data.setIndex,
|
||||
chars = data.chars,
|
||||
charSet = data.charSet,
|
||||
length = data.length,
|
||||
textHasEmoji = data.textHasEmoji,
|
||||
charsHaveEmoji = data.charsHaveEmoji,
|
||||
lengthDif = data.lengthDif,
|
||||
tweenLength = data.tweenLength,
|
||||
oldClass = data.oldClass,
|
||||
newClass = data.newClass,
|
||||
rightToLeft = data.rightToLeft,
|
||||
fillChar = data.fillChar,
|
||||
speed = data.speed,
|
||||
original = data.original,
|
||||
hasClass = data.hasClass,
|
||||
l = text.length,
|
||||
time = tween._time,
|
||||
timeDif = time - prevScrambleTime,
|
||||
i,
|
||||
i2,
|
||||
startText,
|
||||
endText,
|
||||
applyNew,
|
||||
applyOld,
|
||||
str,
|
||||
startClass,
|
||||
endClass,
|
||||
position,
|
||||
r;
|
||||
|
||||
if (revealDelay) {
|
||||
if (tween._from) {
|
||||
time = tween._dur - time;
|
||||
}
|
||||
|
||||
ratio = time === 0 ? 0 : time < revealDelay ? 0.000001 : time === tween._dur ? 1 : tween._ease((time - revealDelay) / (tween._dur - revealDelay));
|
||||
}
|
||||
|
||||
if (ratio < 0) {
|
||||
ratio = 0;
|
||||
} else if (ratio > 1) {
|
||||
ratio = 1;
|
||||
}
|
||||
|
||||
if (rightToLeft) {
|
||||
ratio = 1 - ratio;
|
||||
}
|
||||
|
||||
i = ~~(ratio * l + 0.5);
|
||||
|
||||
if (ratio) {
|
||||
if (timeDif > speed || timeDif < -speed) {
|
||||
data.setIndex = setIndex = (setIndex + (Math.random() * 19 | 0)) % 20;
|
||||
data.chars = charSet.sets[setIndex];
|
||||
data.prevScrambleTime += timeDif;
|
||||
}
|
||||
|
||||
endText = chars;
|
||||
} else {
|
||||
endText = original.join(delimiter);
|
||||
}
|
||||
|
||||
r = tween._from ? ratio : 1 - ratio;
|
||||
position = length + (tweenLength ? tween._from ? r * r * r : 1 - r * r * r : 1) * lengthDif;
|
||||
|
||||
if (rightToLeft) {
|
||||
if (ratio === 1 && (tween._from || tween.data === "isFromStart")) {
|
||||
startText = "";
|
||||
endText = original.join(delimiter);
|
||||
} else {
|
||||
str = text.slice(i).join(delimiter);
|
||||
|
||||
if (charsHaveEmoji) {
|
||||
startText = emojiSafeSplit(endText).slice(0, position - (textHasEmoji ? emojiSafeSplit(str) : str).length + 0.5 | 0).join("");
|
||||
} else {
|
||||
startText = endText.substr(0, position - (textHasEmoji ? emojiSafeSplit(str) : str).length + 0.5 | 0);
|
||||
}
|
||||
|
||||
endText = str;
|
||||
}
|
||||
} else {
|
||||
startText = text.slice(0, i).join(delimiter);
|
||||
i2 = (textHasEmoji ? emojiSafeSplit(startText) : startText).length;
|
||||
|
||||
if (charsHaveEmoji) {
|
||||
endText = emojiSafeSplit(endText).slice(i2, position + 0.5 | 0).join("");
|
||||
} else {
|
||||
endText = endText.substr(i2, position - i2 + 0.5 | 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (hasClass) {
|
||||
startClass = rightToLeft ? oldClass : newClass;
|
||||
endClass = rightToLeft ? newClass : oldClass;
|
||||
applyNew = startClass && i !== 0;
|
||||
applyOld = endClass && i !== l;
|
||||
str = (applyNew ? "<span class='" + startClass + "'>" : "") + startText + (applyNew ? "</span>" : "") + (applyOld ? "<span class='" + endClass + "'>" : "") + delimiter + endText + (applyOld ? "</span>" : "");
|
||||
} else {
|
||||
str = startText + delimiter + endText;
|
||||
}
|
||||
|
||||
target[prop] = fillChar === " " && ~str.indexOf(" ") ? str.split(" ").join(" ") : str;
|
||||
}
|
||||
};
|
||||
ScrambleTextPlugin.emojiSafeSplit = emojiSafeSplit;
|
||||
ScrambleTextPlugin.getText = getText;
|
||||
_getGSAP() && gsap.registerPlugin(ScrambleTextPlugin);
|
||||
|
||||
exports.ScrambleTextPlugin = ScrambleTextPlugin;
|
||||
exports.default = ScrambleTextPlugin;
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
})));
|
||||
Reference in new issue
Block a user