install gsap
This commit is contained in:
1 parent
1fc081a048
commit
d9b2762b72
182 files changed
+111895
No files matched your search
+1316
File diff suppressed because it is too large.
Load diff
+197
@@ -0,0 +1,197 @@
|
||||
/*!
|
||||
* VelocityTracker: 3.14.2
|
||||
* https://gsap.com
|
||||
*
|
||||
* Copyright 2008-2025, GreenSock. All rights reserved.
|
||||
* Subject to the terms at https://gsap.com/standard-license
|
||||
* @author: Jack Doyle, jack@greensock.com
|
||||
*/
|
||||
/* eslint-disable */
|
||||
|
||||
let gsap, _coreInitted, _toArray, _getUnit, _first, _ticker, _time1, _time2, _getCache,
|
||||
_getGSAP = () => gsap || typeof(window) !== "undefined" && (gsap = window.gsap),
|
||||
_lookup = {},
|
||||
_round = value => Math.round(value * 10000) / 10000,
|
||||
_getID = target => _getCache(target).id,
|
||||
_getByTarget = target => _lookup[_getID(typeof(target) === "string" ? _toArray(target)[0] : target)],
|
||||
_onTick = (time) => {
|
||||
let pt = _first,
|
||||
val;
|
||||
//if the frame rate is too high, we won't be able to track the velocity as well, so only update the values about 20 times per second
|
||||
if (time - _time1 >= 0.05) {
|
||||
_time2 = _time1;
|
||||
_time1 = time;
|
||||
while (pt) {
|
||||
val = pt.g(pt.t, pt.p);
|
||||
if (val !== pt.v1 || time - pt.t1 > 0.2) { //use a threshold of 0.2 seconds for zeroing-out velocity. If we only use 0.05 and things update slightly slower, like some Android devices dispatch "touchmove" events sluggishly so 2 or 3 ticks of the gsap.ticker may elapse inbetween, thus it may appear like the object is not moving but it actually is but it's not updating as frequently. A threshold of 0.2 seconds seems to be a good balance. We want to update things frequently (0.05 seconds) when they're moving so that we can respond to fast motions accurately, but we want to be more resistant to go back to a zero velocity.
|
||||
pt.v2 = pt.v1;
|
||||
pt.v1 = val;
|
||||
pt.t2 = pt.t1;
|
||||
pt.t1 = time;
|
||||
}
|
||||
pt = pt._next;
|
||||
}
|
||||
}
|
||||
},
|
||||
_types = {deg: 360, rad: Math.PI * 2},
|
||||
|
||||
_initCore = () => {
|
||||
gsap = _getGSAP();
|
||||
if (gsap) {
|
||||
_toArray = gsap.utils.toArray;
|
||||
_getUnit = gsap.utils.getUnit;
|
||||
_getCache = gsap.core.getCache;
|
||||
_ticker = gsap.ticker;
|
||||
_coreInitted = 1;
|
||||
}
|
||||
};
|
||||
|
||||
class PropTracker {
|
||||
|
||||
constructor(target, property, type, next) {
|
||||
this.t = target;
|
||||
this.p = property;
|
||||
this.g = target._gsap.get;
|
||||
this.rCap = _types[type || _getUnit(this.g(target, property))]; //rotational cap (for degrees, "deg", it's 360 and for radians, "rad", it's Math.PI * 2)
|
||||
this.v1 = this.v2 = this.g(target, property);
|
||||
this.t1 = this.t2 = _ticker.time;
|
||||
if (next) {
|
||||
this._next = next;
|
||||
next._prev = this;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export class VelocityTracker {
|
||||
|
||||
constructor(target, property) {
|
||||
_coreInitted || _initCore();
|
||||
this.target = _toArray(target)[0];
|
||||
_lookup[_getID(this.target)] = this;
|
||||
this._props = {};
|
||||
property && this.add(property);
|
||||
}
|
||||
|
||||
static register(core) {
|
||||
gsap = core;
|
||||
_initCore();
|
||||
}
|
||||
|
||||
get(property, skipRecentTick) {
|
||||
let pt = this._props[property] || console.warn("Not tracking " + property + " velocity."),
|
||||
val, dif, rotationCap;
|
||||
val = parseFloat(skipRecentTick ? pt.v1 : pt.g(pt.t, pt.p));
|
||||
dif = (val - parseFloat(pt.v2));
|
||||
rotationCap = pt.rCap;
|
||||
if (rotationCap) { //rotational values need special interpretation so that if, for example, they go from 179 to -178 degrees it is interpreted as a change of 3 instead of -357.
|
||||
dif = dif % rotationCap;
|
||||
if (dif !== dif % (rotationCap / 2)) {
|
||||
dif = (dif < 0) ? dif + rotationCap : dif - rotationCap;
|
||||
}
|
||||
}
|
||||
return _round(dif / ((skipRecentTick ? pt.t1 : _ticker.time) - pt.t2));
|
||||
}
|
||||
|
||||
getAll() {
|
||||
let result = {},
|
||||
props = this._props,
|
||||
p;
|
||||
for (p in props) {
|
||||
result[p] = this.get(p);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
isTracking(property) {
|
||||
return (property in this._props);
|
||||
}
|
||||
|
||||
add(property, type) {
|
||||
let pt = this._props[property];
|
||||
if (pt) { // reset
|
||||
pt.v1 = pt.v2 = pt.g(pt.t, pt.p);
|
||||
pt.t1 = pt.t2 = _ticker.time;
|
||||
} else {
|
||||
if (!_first) {
|
||||
_ticker.add(_onTick);
|
||||
_time1 = _time2 = _ticker.time;
|
||||
}
|
||||
_first = this._props[property] = new PropTracker(this.target, property, type, _first);
|
||||
}
|
||||
}
|
||||
|
||||
remove(property) {
|
||||
let pt = this._props[property],
|
||||
prev, next;
|
||||
if (pt) {
|
||||
prev = pt._prev;
|
||||
next = pt._next;
|
||||
if (prev) {
|
||||
prev._next = next;
|
||||
}
|
||||
if (next) {
|
||||
next._prev = prev;
|
||||
} else if (_first === pt) {
|
||||
_ticker.remove(_onTick);
|
||||
_first = 0;
|
||||
}
|
||||
delete this._props[property];
|
||||
}
|
||||
}
|
||||
|
||||
kill(shallow) {
|
||||
for (let p in this._props) {
|
||||
this.remove(p);
|
||||
}
|
||||
if (!shallow) {
|
||||
delete _lookup[_getID(this.target)];
|
||||
}
|
||||
}
|
||||
|
||||
static track(targets, properties, types) {
|
||||
_coreInitted || _initCore();
|
||||
let result = [],
|
||||
targs = _toArray(targets),
|
||||
a = properties.split(","),
|
||||
t = (types || "").split(","),
|
||||
i = targs.length,
|
||||
tracker, j;
|
||||
while (i--) {
|
||||
tracker = _getByTarget(targs[i]) || new VelocityTracker(targs[i]);
|
||||
j = a.length;
|
||||
while (j--) {
|
||||
tracker.add(a[j], t[j] || t[0]);
|
||||
}
|
||||
result.push(tracker);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static untrack(targets, properties) {
|
||||
let props = properties && properties.split(",");
|
||||
_toArray(targets).forEach(target => {
|
||||
let tracker = _getByTarget(target);
|
||||
if (tracker) {
|
||||
props ? props.forEach(p => tracker.remove(p)) : tracker.kill(1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static isTracking(target, property) {
|
||||
let tracker = _getByTarget(target);
|
||||
return tracker && tracker.isTracking(property);
|
||||
}
|
||||
|
||||
static getVelocity(target, property) {
|
||||
let tracker = _getByTarget(target);
|
||||
return (!tracker || !tracker.isTracking(property)) ? console.warn("Not tracking velocity of " + property) : tracker.get(property);
|
||||
}
|
||||
}
|
||||
|
||||
VelocityTracker.getByTarget = _getByTarget;
|
||||
|
||||
|
||||
_getGSAP() && gsap.registerPlugin(VelocityTracker);
|
||||
|
||||
export { VelocityTracker as default };
|
||||
+326
@@ -0,0 +1,326 @@
|
||||
/*!
|
||||
* matrix 3.14.2
|
||||
* https://gsap.com
|
||||
*
|
||||
* Copyright 2008-2025, GreenSock. All rights reserved.
|
||||
* Subject to the terms at https://gsap.com/standard-license
|
||||
* @author: Jack Doyle, jack@greensock.com
|
||||
*/
|
||||
/* eslint-disable */
|
||||
|
||||
let _doc, _win, _docElement, _body, _divContainer, _svgContainer, _identityMatrix, _gEl,
|
||||
_transformProp = "transform",
|
||||
_transformOriginProp = _transformProp + "Origin",
|
||||
_hasOffsetBug,
|
||||
_setDoc = element => {
|
||||
let doc = element.ownerDocument || element;
|
||||
if (!(_transformProp in element.style) && "msTransform" in element.style) { //to improve compatibility with old Microsoft browsers
|
||||
_transformProp = "msTransform";
|
||||
_transformOriginProp = _transformProp + "Origin";
|
||||
}
|
||||
while (doc.parentNode && (doc = doc.parentNode)) { }
|
||||
_win = window;
|
||||
_identityMatrix = new Matrix2D();
|
||||
if (doc) {
|
||||
_doc = doc;
|
||||
_docElement = doc.documentElement;
|
||||
_body = doc.body;
|
||||
_gEl = _doc.createElementNS("http://www.w3.org/2000/svg", "g");
|
||||
// prevent any existing CSS from transforming it
|
||||
_gEl.style.transform = "none";
|
||||
// now test for the offset reporting bug. Use feature detection instead of browser sniffing to make things more bulletproof and future-proof. Hopefully Safari will fix their bug soon.
|
||||
let d1 = doc.createElement("div"),
|
||||
d2 = doc.createElement("div"),
|
||||
root = doc && (doc.body || doc.firstElementChild);
|
||||
if (root && root.appendChild) {
|
||||
root.appendChild(d1);
|
||||
d1.appendChild(d2);
|
||||
d1.style.position = "static";
|
||||
d1.style.transform = "translate3d(0,0,1px)";
|
||||
_hasOffsetBug = (d2.offsetParent !== d1);
|
||||
root.removeChild(d1);
|
||||
}
|
||||
}
|
||||
return doc;
|
||||
},
|
||||
_forceNonZeroScale = e => { // walks up the element's ancestors and finds any that had their scale set to 0 via GSAP, and changes them to 0.0001 to ensure that measurements work. Firefox has a bug that causes it to incorrectly report getBoundingClientRect() when scale is 0.
|
||||
let a, cache;
|
||||
while (e && e !== _body) {
|
||||
cache = e._gsap;
|
||||
cache && cache.uncache && cache.get(e, "x"); // force re-parsing of transforms if necessary
|
||||
if (cache && !cache.scaleX && !cache.scaleY && cache.renderTransform) {
|
||||
cache.scaleX = cache.scaleY = 1e-4;
|
||||
cache.renderTransform(1, cache);
|
||||
a ? a.push(cache) : (a = [cache]);
|
||||
}
|
||||
e = e.parentNode;
|
||||
}
|
||||
return a;
|
||||
},
|
||||
// possible future addition: pass an element to _forceDisplay() and it'll walk up all its ancestors and make sure anything with display: none is set to display: block, and if there's no parentNode, it'll add it to the body. It returns an Array that you can then feed to _revertDisplay() to have it revert all the changes it made.
|
||||
// _forceDisplay = e => {
|
||||
// let a = [],
|
||||
// parent;
|
||||
// while (e && e !== _body) {
|
||||
// parent = e.parentNode;
|
||||
// (_win.getComputedStyle(e).display === "none" || !parent) && a.push(e, e.style.display, parent) && (e.style.display = "block");
|
||||
// parent || _body.appendChild(e);
|
||||
// e = parent;
|
||||
// }
|
||||
// return a;
|
||||
// },
|
||||
// _revertDisplay = a => {
|
||||
// for (let i = 0; i < a.length; i+=3) {
|
||||
// a[i+1] ? (a[i].style.display = a[i+1]) : a[i].style.removeProperty("display");
|
||||
// a[i+2] || a[i].parentNode.removeChild(a[i]);
|
||||
// }
|
||||
// },
|
||||
_svgTemps = [], //we create 3 elements for SVG, and 3 for other DOM elements and cache them for performance reasons. They get nested in _divContainer and _svgContainer so that just one element is added to the DOM on each successive attempt. Again, performance is key.
|
||||
_divTemps = [],
|
||||
_getDocScrollTop = () => _win.pageYOffset || _doc.scrollTop || _docElement.scrollTop || _body.scrollTop || 0,
|
||||
_getDocScrollLeft = () => _win.pageXOffset || _doc.scrollLeft || _docElement.scrollLeft || _body.scrollLeft || 0,
|
||||
_svgOwner = element => element.ownerSVGElement || ((element.tagName + "").toLowerCase() === "svg" ? element : null),
|
||||
_isFixed = element => {
|
||||
if (_win.getComputedStyle(element).position === "fixed") {
|
||||
return true;
|
||||
}
|
||||
element = element.parentNode;
|
||||
if (element && element.nodeType === 1) { // avoid document fragments which will throw an error.
|
||||
return _isFixed(element);
|
||||
}
|
||||
},
|
||||
_createSibling = (element, i) => {
|
||||
if (element.parentNode && (_doc || _setDoc(element))) {
|
||||
let svg = _svgOwner(element),
|
||||
ns = svg ? (svg.getAttribute("xmlns") || "http://www.w3.org/2000/svg") : "http://www.w3.org/1999/xhtml",
|
||||
type = svg ? (i ? "rect" : "g") : "div",
|
||||
x = i !== 2 ? 0 : 100,
|
||||
y = i === 3 ? 100 : 0,
|
||||
css = {position: "absolute", display: "block", pointerEvents: "none", margin: "0", padding: "0"},
|
||||
e = _doc.createElementNS ? _doc.createElementNS(ns.replace(/^https/, "http"), type) : _doc.createElement(type);
|
||||
if (i) {
|
||||
if (!svg) {
|
||||
if (!_divContainer) {
|
||||
_divContainer = _createSibling(element);
|
||||
Object.assign(_divContainer.style, css);
|
||||
}
|
||||
Object.assign(e.style, css, {width: "0.1px", height: "0.1px", top: y + "px", left: x + "px"});
|
||||
_divContainer.appendChild(e);
|
||||
|
||||
} else {
|
||||
_svgContainer || (_svgContainer = _createSibling(element));
|
||||
e.setAttribute("width", 0.01);
|
||||
e.setAttribute("height", 0.01);
|
||||
e.setAttribute("transform", "translate(" + x + "," + y + ")");
|
||||
e.setAttribute("fill", "transparent");
|
||||
_svgContainer.appendChild(e);
|
||||
}
|
||||
}
|
||||
return e;
|
||||
}
|
||||
throw "Need document and parent.";
|
||||
},
|
||||
_consolidate = m => { // replaces SVGTransformList.consolidate() because a bug in Firefox causes it to break pointer events. See https://gsap.com/forums/topic/23248-touch-is-not-working-on-draggable-in-firefox-windows-v324/?tab=comments#comment-109800
|
||||
let c = new Matrix2D(),
|
||||
i = 0;
|
||||
for (; i < m.numberOfItems; i++) {
|
||||
c.multiply(m.getItem(i).matrix);
|
||||
}
|
||||
return c;
|
||||
},
|
||||
_getCTM = svg => {
|
||||
let m = svg.getCTM(),
|
||||
transform;
|
||||
if (!m) { // Firefox returns null for getCTM() on root <svg> elements, so this is a workaround using a <g> that we temporarily append.
|
||||
transform = svg.style[_transformProp];
|
||||
svg.style[_transformProp] = "none"; // a bug in Firefox causes css transforms to contaminate the getCTM()
|
||||
svg.appendChild(_gEl);
|
||||
m = _gEl.getCTM();
|
||||
svg.removeChild(_gEl);
|
||||
transform ? (svg.style[_transformProp] = transform) : svg.style.removeProperty(_transformProp.replace(/([A-Z])/g, "-$1").toLowerCase());
|
||||
}
|
||||
return m || _identityMatrix.clone(); // Firefox will still return null if the <svg> has a width/height of 0 in the browser.
|
||||
},
|
||||
_placeSiblings = (element, adjustGOffset) => {
|
||||
let svg = _svgOwner(element),
|
||||
isRootSVG = element === svg,
|
||||
siblings = svg ? _svgTemps : _divTemps,
|
||||
parent = element.parentNode,
|
||||
appendToEl = parent && !svg && parent.shadowRoot && parent.shadowRoot.appendChild ? parent.shadowRoot : parent,
|
||||
container, m, b, x, y, cs;
|
||||
if (element === _win) {
|
||||
return element;
|
||||
}
|
||||
siblings.length || siblings.push(_createSibling(element, 1), _createSibling(element, 2), _createSibling(element, 3));
|
||||
container = svg ? _svgContainer : _divContainer;
|
||||
if (svg) {
|
||||
if (isRootSVG) {
|
||||
b = _getCTM(element);
|
||||
x = -b.e / b.a;
|
||||
y = -b.f / b.d;
|
||||
m = _identityMatrix;
|
||||
} else if (element.getBBox) {
|
||||
b = element.getBBox();
|
||||
m = element.transform ? element.transform.baseVal : {}; // IE11 doesn't follow the spec.
|
||||
m = !m.numberOfItems ? _identityMatrix : m.numberOfItems > 1 ? _consolidate(m) : m.getItem(0).matrix; // don't call m.consolidate().matrix because a bug in Firefox makes pointer events not work when consolidate() is called on the same tick as getBoundingClientRect()! See https://gsap.com/forums/topic/23248-touch-is-not-working-on-draggable-in-firefox-windows-v324/?tab=comments#comment-109800
|
||||
x = m.a * b.x + m.c * b.y;
|
||||
y = m.b * b.x + m.d * b.y;
|
||||
} else { // may be a <mask> which has no getBBox() so just use defaults instead of throwing errors.
|
||||
m = new Matrix2D();
|
||||
x = y = 0;
|
||||
}
|
||||
if (adjustGOffset && element.tagName.toLowerCase() === "g") {
|
||||
x = y = 0;
|
||||
}
|
||||
(isRootSVG || !element.getBoundingClientRect().width ? svg : parent).appendChild(container); // check getBoundingClientRect().width because things inside a <mask>, for example, may return 0 in which case we need to move the element to the root SVG to properly measure things. An alternative would be to walk up the DOM and see if any ancestor is a nodeName of "mask" and if so, set parent to svg.
|
||||
container.setAttribute("transform", "matrix(" + m.a + "," + m.b + "," + m.c + "," + m.d + "," + (m.e + x) + "," + (m.f + y) + ")");
|
||||
} else {
|
||||
x = y = 0;
|
||||
if (_hasOffsetBug) { // some browsers (like Safari) have a bug that causes them to misreport offset values. When an ancestor element has a transform applied, it's supposed to treat it as if it's position: relative (new context). Safari botches this, so we need to find the closest ancestor (between the element and its offsetParent) that has a transform applied and if one is found, grab its offsetTop/Left and subtract them to compensate.
|
||||
m = element.offsetParent;
|
||||
b = element;
|
||||
while (b && (b = b.parentNode) && b !== m && b.parentNode) {
|
||||
if ((_win.getComputedStyle(b)[_transformProp] + "").length > 4) {
|
||||
x = b.offsetLeft;
|
||||
y = b.offsetTop;
|
||||
b = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
cs = _win.getComputedStyle(element);
|
||||
if (cs.position !== "absolute" && cs.position !== "fixed") {
|
||||
m = element.offsetParent;
|
||||
while (parent && parent !== m) { // if there's an ancestor element between the element and its offsetParent that's scrolled, we must factor that in.
|
||||
x += parent.scrollLeft || 0;
|
||||
y += parent.scrollTop || 0;
|
||||
parent = parent.parentNode;
|
||||
}
|
||||
}
|
||||
b = container.style;
|
||||
b.top = (element.offsetTop - y) + "px";
|
||||
b.left = (element.offsetLeft - x) + "px";
|
||||
b[_transformProp] = cs[_transformProp];
|
||||
b[_transformOriginProp] = cs[_transformOriginProp];
|
||||
// b.border = m.border;
|
||||
// b.borderLeftStyle = m.borderLeftStyle;
|
||||
// b.borderTopStyle = m.borderTopStyle;
|
||||
// b.borderLeftWidth = m.borderLeftWidth;
|
||||
// b.borderTopWidth = m.borderTopWidth;
|
||||
b.position = cs.position === "fixed" ? "fixed" : "absolute";
|
||||
appendToEl.appendChild(container);
|
||||
}
|
||||
return container;
|
||||
},
|
||||
_setMatrix = (m, a, b, c, d, e, f) => {
|
||||
m.a = a;
|
||||
m.b = b;
|
||||
m.c = c;
|
||||
m.d = d;
|
||||
m.e = e;
|
||||
m.f = f;
|
||||
return m;
|
||||
};
|
||||
|
||||
export class Matrix2D {
|
||||
constructor(a=1, b=0, c=0, d=1, e=0, f=0) {
|
||||
_setMatrix(this, a, b, c, d, e, f);
|
||||
}
|
||||
|
||||
inverse() {
|
||||
let {a, b, c, d, e, f} = this,
|
||||
determinant = (a * d - b * c) || 1e-10;
|
||||
return _setMatrix(
|
||||
this,
|
||||
d / determinant,
|
||||
-b / determinant,
|
||||
-c / determinant,
|
||||
a / determinant,
|
||||
(c * f - d * e) / determinant,
|
||||
-(a * f - b * e) / determinant
|
||||
);
|
||||
}
|
||||
|
||||
multiply(matrix) {
|
||||
let {a, b, c, d, e, f} = this,
|
||||
a2 = matrix.a,
|
||||
b2 = matrix.c,
|
||||
c2 = matrix.b,
|
||||
d2 = matrix.d,
|
||||
e2 = matrix.e,
|
||||
f2 = matrix.f;
|
||||
return _setMatrix(this,
|
||||
a2 * a + c2 * c,
|
||||
a2 * b + c2 * d,
|
||||
b2 * a + d2 * c,
|
||||
b2 * b + d2 * d,
|
||||
e + e2 * a + f2 * c,
|
||||
f + e2 * b + f2 * d);
|
||||
}
|
||||
|
||||
clone() {
|
||||
return new Matrix2D(this.a, this.b, this.c, this.d, this.e, this.f);
|
||||
}
|
||||
|
||||
equals(matrix) {
|
||||
let {a, b, c, d, e, f} = this;
|
||||
return (a === matrix.a && b === matrix.b && c === matrix.c && d === matrix.d && e === matrix.e && f === matrix.f);
|
||||
}
|
||||
|
||||
apply(point, decoratee={}) {
|
||||
let {x, y} = point,
|
||||
{a, b, c, d, e, f} = this;
|
||||
decoratee.x = (x * a + y * c + e) || 0;
|
||||
decoratee.y = (x * b + y * d + f) || 0;
|
||||
return decoratee;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Feed in an element and it'll return a 2D matrix (optionally inverted) so that you can translate between coordinate spaces.
|
||||
// Inverting lets you translate a global point into a local coordinate space. No inverting lets you go the other way.
|
||||
// We needed this to work around various browser bugs, like Firefox doesn't accurately report getScreenCTM() when there
|
||||
// are transforms applied to ancestor elements.
|
||||
// The matrix math to convert any x/y coordinate is as follows, which is wrapped in a convenient apply() method of Matrix2D above:
|
||||
// tx = m.a * x + m.c * y + m.e
|
||||
// ty = m.b * x + m.d * y + m.f
|
||||
export function getGlobalMatrix(element, inverse, adjustGOffset, includeScrollInFixed) { // adjustGOffset is typically used only when grabbing an element's PARENT's global matrix, and it ignores the x/y offset of any SVG <g> elements because they behave in a special way.
|
||||
if (!element || !element.parentNode || (_doc || _setDoc(element)).documentElement === element) {
|
||||
return new Matrix2D();
|
||||
}
|
||||
let zeroScales = _forceNonZeroScale(element),
|
||||
svg = _svgOwner(element),
|
||||
temps = svg ? _svgTemps : _divTemps,
|
||||
container = _placeSiblings(element, adjustGOffset),
|
||||
b1 = temps[0].getBoundingClientRect(),
|
||||
b2 = temps[1].getBoundingClientRect(),
|
||||
b3 = temps[2].getBoundingClientRect(),
|
||||
parent = container.parentNode,
|
||||
isFixed = !includeScrollInFixed && _isFixed(element),
|
||||
m = new Matrix2D(
|
||||
(b2.left - b1.left) / 100,
|
||||
(b2.top - b1.top) / 100,
|
||||
(b3.left - b1.left) / 100,
|
||||
(b3.top - b1.top) / 100,
|
||||
b1.left + (isFixed ? 0 : _getDocScrollLeft()),
|
||||
b1.top + (isFixed ? 0 : _getDocScrollTop())
|
||||
);
|
||||
parent.removeChild(container);
|
||||
if (zeroScales) {
|
||||
b1 = zeroScales.length;
|
||||
while (b1--) {
|
||||
b2 = zeroScales[b1];
|
||||
b2.scaleX = b2.scaleY = 0;
|
||||
b2.renderTransform(1, b2);
|
||||
}
|
||||
}
|
||||
return inverse ? m.inverse() : m;
|
||||
}
|
||||
|
||||
export { _getDocScrollTop, _getDocScrollLeft, _setDoc, _isFixed, _getCTM };
|
||||
|
||||
// export function getMatrix(element) {
|
||||
// _doc || _setDoc(element);
|
||||
// let m = (_win.getComputedStyle(element)[_transformProp] + "").substr(7).match(/[-.]*\d+[.e\-+]*\d*[e\-\+]*\d*/g),
|
||||
// is2D = m && m.length === 6;
|
||||
// return !m || m.length < 6 ? new Matrix2D() : new Matrix2D(+m[0], +m[1], +m[is2D ? 2 : 4], +m[is2D ? 3 : 5], +m[is2D ? 4 : 12], +m[is2D ? 5 : 13]);
|
||||
// }
|
||||
+1317
File diff suppressed because it is too large.
Load diff
+92
@@ -0,0 +1,92 @@
|
||||
/*!
|
||||
* strings: 3.14.2
|
||||
* https://gsap.com
|
||||
*
|
||||
* Copyright 2008-2025, GreenSock. All rights reserved.
|
||||
* Subject to the terms at https://gsap.com/standard-license
|
||||
* @author: Jack Doyle, jack@greensock.com
|
||||
*/
|
||||
/* eslint-disable */
|
||||
|
||||
let _trimExp = /(?:^\s+|\s+$)/g;
|
||||
|
||||
export const 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\uDDF5])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|\uD83D\uDC68(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:(?:\uD83D[\uDC68\uDC69])\u200D)?\uD83D\uDC66\u200D\uD83D\uDC66|(?:(?:\uD83D[\uDC68\uDC69])\u200D)?\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92])|(?:\uD83C[\uDFFB-\uDFFF])\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]))|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:\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])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\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-\uDDDDLine truncated
|
||||
|
||||
export function getText(e) {
|
||||
let 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;
|
||||
}
|
||||
|
||||
export function splitInnerHTML(element, delimiter, trim, preserveSpaces, unescapedCharCodes) {
|
||||
let node = element.firstChild,
|
||||
result = [], s;
|
||||
while (node) {
|
||||
if (node.nodeType === 3) {
|
||||
s = (node.nodeValue + "").replace(/^\n+/g, "");
|
||||
if (!preserveSpaces) {
|
||||
s = s.replace(/\s+/g, " ");
|
||||
}
|
||||
result.push(...emojiSafeSplit(s, delimiter, trim, preserveSpaces, unescapedCharCodes));
|
||||
} else if ((node.nodeName + "").toLowerCase() === "br") {
|
||||
result[result.length-1] += "<br>";
|
||||
} else {
|
||||
result.push(node.outerHTML);
|
||||
}
|
||||
node = node.nextSibling;
|
||||
}
|
||||
if (!unescapedCharCodes) {
|
||||
s = result.length;
|
||||
while (s--) {
|
||||
result[s] === "&" && result.splice(s, 1, "&");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
//smaller kb version that only handles the simpler emoji's, which is often perfectly adequate.
|
||||
|
||||
let _emoji = "[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2694-\u2697]|\uD83E[\uDD10-\uDD5D]|[\uD800-\uDBFF][\uDC00-\uDFFF]",
|
||||
_emojiExp = new RegExp(_emoji),
|
||||
_emojiAndCharsExp = new RegExp(_emoji + "|.", "g"),
|
||||
_emojiSafeSplit = (text, delimiter, trim) => {
|
||||
if (trim) {
|
||||
text = text.replace(_trimExp, "");
|
||||
}
|
||||
return ((delimiter === "" || !delimiter) && _emojiExp.test(text)) ? text.match(_emojiAndCharsExp) : text.split(delimiter || "");
|
||||
};
|
||||
*/
|
||||
export function emojiSafeSplit(text, delimiter, trim, preserveSpaces, unescapedCharCodes) {
|
||||
text += ""; // make sure it's cast as a string. Someone may pass in a number.
|
||||
trim && (text = text.trim ? text.trim() : text.replace(_trimExp, "")); // IE9 and earlier compatibility
|
||||
if (delimiter && delimiter !== "") {
|
||||
return text.replace(/>/g, ">").replace(/</g, "<").split(delimiter);
|
||||
}
|
||||
let 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)) { //special emoji characters use 2 or 4 unicode characters that we must keep together.
|
||||
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;
|
||||
}
|
||||
Reference in new issue
Block a user