Compare commits
35
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
41fa7ddf73 | ||
|
|
ab9dfff33f | ||
|
|
2cb39f0c55 | ||
|
|
c1345eaca7 | ||
|
|
d0c7916386 | ||
|
|
9de9ce7f43 | ||
|
|
9d3180287a | ||
|
|
3f2c51eb1f | ||
|
|
0786fbac8b | ||
|
|
ab588fd27b | ||
|
|
fb801e3752 | ||
|
|
414967441a | ||
|
|
0b5d248c4e | ||
|
|
b6e57ba551 | ||
|
|
f31f0f3a05 | ||
|
|
54c22ca24b | ||
|
|
3671509f82 | ||
|
|
3504220abc | ||
|
|
012505e7bb | ||
|
|
feeebf6f2d | ||
|
|
8140efb951 | ||
|
|
a524a5d36a | ||
|
|
3628d7b31f | ||
|
|
2da092a6f2 | ||
|
|
aba904f796 | ||
|
|
955b982a5a | ||
|
|
367ae871a0 | ||
|
|
8951b36ae3 | ||
|
|
624c8c8f1a | ||
|
|
6479792acf | ||
|
|
d9b2762b72 | ||
|
|
1fc081a048 | ||
|
|
a8a07289b6 | ||
|
|
fa756a8c67 | ||
|
|
cfe7237bf8 |
No files matched your search
+64
@@ -0,0 +1,64 @@
|
||||
{
|
||||
"name": "parfum_agsd",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"node_modules/cookie": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/cookie/-/cookie-1.1.1.tgz",
|
||||
"integrity": "sha512-ei8Aos7ja0weRpFzJnEA9UHJ/7XQmqglbRwnf2ATjcB9Wq874VKH9kfjjirM6UhU2/E5fFYadylyhFldcqSidQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/express"
|
||||
}
|
||||
},
|
||||
"node_modules/gsap": {
|
||||
"version": "3.14.2",
|
||||
"resolved": "https://registry.npmjs.org/gsap/-/gsap-3.14.2.tgz",
|
||||
"integrity": "sha512-P8/mMxVLU7o4+55+1TCnQrPmgjPKnwkzkXOK1asnR9Jg2lna4tEY5qBJjMmAaOBDDZWtlRjBXjLa0w53G/uBLA==",
|
||||
"license": "Standard 'no charge' license: https://gsap.com/standard-license."
|
||||
},
|
||||
"node_modules/react": {
|
||||
"version": "19.2.4",
|
||||
"resolved": "https://registry.npmjs.org/react/-/react-19.2.4.tgz",
|
||||
"integrity": "sha512-9nfp2hYpCwOjAN+8TZFGhtWEwgvWHXqESH8qT89AT/lWklpLON22Lc8pEtnpsZz7VmawabSU0gCjnj8aC0euHQ==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/react-router": {
|
||||
"version": "7.14.0",
|
||||
"resolved": "https://registry.npmjs.org/react-router/-/react-router-7.14.0.tgz",
|
||||
"integrity": "sha512-m/xR9N4LQLmAS0ZhkY2nkPA1N7gQ5TUVa5n8TgANuDTARbn1gt+zLPXEm7W0XDTbrQ2AJSJKhoa6yx1D8BcpxQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"cookie": "^1.0.1",
|
||||
"set-cookie-parser": "^2.6.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": ">=18",
|
||||
"react-dom": ">=18"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"react-dom": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/set-cookie-parser": {
|
||||
"version": "2.7.2",
|
||||
"resolved": "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-2.7.2.tgz",
|
||||
"integrity": "sha512-oeM1lpU/UvhTxw+g3cIfxXHyJRc/uidd3yK1P242gzHds0udQBYzs3y8j4gCCW+ZJ7ad0yctld8RYO+bdurlvw==",
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2012-2014 Roman Shtylman <shtylman@gmail.com>
|
||||
Copyright (c) 2015 Douglas Christopher Wilson <doug@somethingdoug.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
+295
@@ -0,0 +1,295 @@
|
||||
# cookie
|
||||
|
||||
[![NPM Version][npm-version-image]][npm-url]
|
||||
[![NPM Downloads][npm-downloads-image]][npm-url]
|
||||
[![Build Status][ci-image]][ci-url]
|
||||
[![Coverage Status][coverage-image]][coverage-url]
|
||||
|
||||
Basic HTTP cookie parser and serializer for HTTP servers.
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
$ npm install cookie
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
```js
|
||||
const cookie = require("cookie");
|
||||
// import * as cookie from 'cookie';
|
||||
```
|
||||
|
||||
### cookie.parseCookie(str, options)
|
||||
|
||||
Parse an HTTP `Cookie` header string and return an [object](#cookie-object) of all cookie name-value pairs.
|
||||
The `str` argument is the string representing a `Cookie` header value and `options` is an
|
||||
optional object containing additional parsing options.
|
||||
|
||||
```js
|
||||
const cookieObject = cookie.parseCookie("foo=bar; equation=E%3Dmc%5E2");
|
||||
// { foo: 'bar', equation: 'E=mc^2' }
|
||||
```
|
||||
|
||||
#### Options
|
||||
|
||||
- `decode` Specifies the function to decode a [cookie-value](https://datatracker.ietf.org/doc/html/rfc6265#section-4.1.1). Defaults to [`decodeURIComponent`](#encode-and-decode).
|
||||
|
||||
### cookie.stringifyCookie(cookieObj, options)
|
||||
|
||||
Stringifies a [cookie object](#cookie-object) into an HTTP `Cookie` header.
|
||||
|
||||
```js
|
||||
const cookieHeader = cookie.stringify({ a: "foo", b: "bar" });
|
||||
// a=foo; b=bar
|
||||
```
|
||||
|
||||
#### Options
|
||||
|
||||
- `encode` Specifies the function to encode a [cookie-value](https://datatracker.ietf.org/doc/html/rfc6265#section-4.1.1). Defaults to [`encodeURIComponent`](#encode-and-decode).
|
||||
|
||||
### cookie.parseSetCookie(str, options)
|
||||
|
||||
Parse an HTTP `Set-Cookie` header string and return an [object](#set-cookie-object) of the options.
|
||||
|
||||
```js
|
||||
const setCookieObject = cookie.parseSetCookie("foo=bar; httpOnly");
|
||||
// { name: "foo", value: "bar", httpOnly: true }
|
||||
```
|
||||
|
||||
**Note:** Cookie follows the specification and ignores invalid attributes, but does not attempt to normalize or modify any attributes as a browser might. For example:
|
||||
|
||||
```js
|
||||
cookie.parseSetCookie(
|
||||
"session=abc; max-age=1.5; expires=invalid; custom=value; domain=example.com",
|
||||
);
|
||||
// { name: "session", value: "abc", domain: "example.com" }
|
||||
```
|
||||
|
||||
#### Options
|
||||
|
||||
- `decode` Specifies the function to decode a [cookie-value](https://datatracker.ietf.org/doc/html/rfc6265#section-4.1.1). Defaults to [`decodeURIComponent`](#encode-and-decode).
|
||||
|
||||
### cookie.stringifySetCookie(setCookieObj, options)
|
||||
|
||||
Stringifies a [`Set-Cookie` object](#set-cookie-object) into a `Set-Cookie` header string.
|
||||
|
||||
```js
|
||||
const setCookieHeader = cookie.stringifySetCookie({
|
||||
name: "foo",
|
||||
value: "bar",
|
||||
});
|
||||
// foo=bar
|
||||
```
|
||||
|
||||
#### Options
|
||||
|
||||
- `encode` Specifies the function to encode a [cookie-value](https://datatracker.ietf.org/doc/html/rfc6265#section-4.1.1). Defaults to [`encodeURIComponent`](#encode-and-decode).
|
||||
|
||||
## Cookie object
|
||||
|
||||
The cookie object represents all cookie name-value pairs in a `Cookie` header, where `{ name: "value" }` is used for `name=value`.
|
||||
|
||||
## `Set-Cookie` object
|
||||
|
||||
The `Set-Cookie` object represents all the options in a `Set-Cookie` header.
|
||||
|
||||
### name
|
||||
|
||||
The name of the cookie.
|
||||
|
||||
### value
|
||||
|
||||
The value of a cookie after it has been [decoded](#encode-and-decode).
|
||||
|
||||
### maxAge
|
||||
|
||||
Specifies the `number` (in seconds) to be the value for the [`Max-Age` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.2).
|
||||
|
||||
The [cookie storage model specification](https://tools.ietf.org/html/rfc6265#section-5.3) states that if both `expires` and
|
||||
`maxAge` are set, then `maxAge` takes precedence, but it is possible not all clients by obey this,
|
||||
so if both are set, they should point to the same date and time.
|
||||
|
||||
### expires
|
||||
|
||||
Specifies the `Date` object to be the value for the [`Expires` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.1).
|
||||
When no expiration is set, clients consider this a "non-persistent cookie" and delete it when the current session is over.
|
||||
|
||||
The [cookie storage model specification](https://tools.ietf.org/html/rfc6265#section-5.3) states that if both `expires` and
|
||||
`maxAge` are set, then `maxAge` takes precedence, but it is possible not all clients by obey this,
|
||||
so if both are set, they should point to the same date and time.
|
||||
|
||||
### domain
|
||||
|
||||
Specifies the value for the [`Domain` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.3).
|
||||
When no domain is set, clients consider the cookie to apply to the current domain only.
|
||||
|
||||
### path
|
||||
|
||||
Specifies the value for the [`Path` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.4).
|
||||
When no path is set, the path is considered the ["default path"](https://tools.ietf.org/html/rfc6265#section-5.1.4).
|
||||
|
||||
### httpOnly
|
||||
|
||||
Enables the [`HttpOnly` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.6).
|
||||
When enabled, clients will not allow client-side JavaScript to see the cookie in `document.cookie`.
|
||||
|
||||
### secure
|
||||
|
||||
Enables the [`Secure` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.5).
|
||||
When enabled, clients will only send the cookie back if the browser has an HTTPS connection.
|
||||
|
||||
### partitioned
|
||||
|
||||
Enables the [`Partitioned` `Set-Cookie` attribute](https://tools.ietf.org/html/draft-cutler-httpbis-partitioned-cookies/).
|
||||
When enabled, clients will only send the cookie back when the current domain _and_ top-level domain matches.
|
||||
|
||||
This is an attribute that has not yet been fully standardized, and may change in the future.
|
||||
This also means clients may ignore this attribute until they understand it. More information
|
||||
about can be found in [the proposal](https://github.com/privacycg/CHIPS).
|
||||
|
||||
### priority
|
||||
|
||||
Specifies the value for the [`Priority` `Set-Cookie` attribute](https://tools.ietf.org/html/draft-west-cookie-priority-00#section-4.1).
|
||||
|
||||
- `'low'` will set the `Priority` attribute to `Low`.
|
||||
- `'medium'` will set the `Priority` attribute to `Medium`, the default priority when not set.
|
||||
- `'high'` will set the `Priority` attribute to `High`.
|
||||
|
||||
More information about priority levels can be found in [the specification](https://tools.ietf.org/html/draft-west-cookie-priority-00#section-4.1).
|
||||
|
||||
### sameSite
|
||||
|
||||
Specifies the value for the [`SameSite` `Set-Cookie` attribute](https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-09#section-5.4.7).
|
||||
|
||||
- `true` will set the `SameSite` attribute to `Strict` for strict same site enforcement.
|
||||
- `'lax'` will set the `SameSite` attribute to `Lax` for lax same site enforcement.
|
||||
- `'none'` will set the `SameSite` attribute to `None` for an explicit cross-site cookie.
|
||||
- `'strict'` will set the `SameSite` attribute to `Strict` for strict same site enforcement.
|
||||
|
||||
More information about enforcement levels can be found in [the specification](https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-09#section-5.4.7).
|
||||
|
||||
## Encode and decode
|
||||
|
||||
Cookie accepts `encode` or `decode` options for processing a [cookie-value](https://datatracker.ietf.org/doc/html/rfc6265#section-4.1.1).
|
||||
Since the value of a cookie has a limited character set (and must be a simple string), these functions are used to transform values into strings suitable for a cookies value.
|
||||
|
||||
The default `encode` function is the global `encodeURIComponent`.
|
||||
|
||||
The default `decode` function is the global `decodeURIComponent`, wrapped in a `try..catch`. If an error
|
||||
is thrown it will return the cookie's original value. If you provide your own encode/decode
|
||||
scheme you must ensure errors are appropriately handled.
|
||||
|
||||
## Example
|
||||
|
||||
The following example uses this module in conjunction with the Node.js core HTTP server
|
||||
to prompt a user for their name and display it back on future visits.
|
||||
|
||||
```js
|
||||
var cookie = require("cookie");
|
||||
var escapeHtml = require("escape-html");
|
||||
var http = require("http");
|
||||
var url = require("url");
|
||||
|
||||
function onRequest(req, res) {
|
||||
// Parse the query string
|
||||
var query = url.parse(req.url, true, true).query;
|
||||
|
||||
if (query && query.name) {
|
||||
// Set a new cookie with the name
|
||||
res.setHeader(
|
||||
"Set-Cookie",
|
||||
cookie.stringifySetCookie({
|
||||
name: "name",
|
||||
value: String(query.name),
|
||||
httpOnly: true,
|
||||
maxAge: 60 * 60 * 24 * 7, // 1 week
|
||||
}),
|
||||
);
|
||||
|
||||
// Redirect back after setting cookie
|
||||
res.statusCode = 302;
|
||||
res.setHeader("Location", req.headers.referer || "/");
|
||||
res.end();
|
||||
return;
|
||||
}
|
||||
|
||||
// Parse the cookies on the request
|
||||
var cookies = cookie.parseCookie(req.headers.cookie || "");
|
||||
|
||||
// Get the visitor name set in the cookie
|
||||
var name = cookies.name;
|
||||
|
||||
res.setHeader("Content-Type", "text/html; charset=UTF-8");
|
||||
|
||||
if (name) {
|
||||
res.write("<p>Welcome back, <b>" + escapeHtml(name) + "</b>!</p>");
|
||||
} else {
|
||||
res.write("<p>Hello, new visitor!</p>");
|
||||
}
|
||||
|
||||
res.write('<form method="GET">');
|
||||
res.write(
|
||||
'<input placeholder="enter your name" name="name"> <input type="submit" value="Set Name">',
|
||||
);
|
||||
res.end("</form>");
|
||||
}
|
||||
|
||||
http.createServer(onRequest).listen(3000);
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
||||
```sh
|
||||
npm test
|
||||
```
|
||||
|
||||
## Benchmark
|
||||
|
||||
```sh
|
||||
npm run bench
|
||||
```
|
||||
|
||||
```
|
||||
name hz min max mean p75 p99 p995 p999 rme samples
|
||||
· simple 8,566,313.09 0.0000 0.3694 0.0001 0.0001 0.0002 0.0002 0.0003 ±0.64% 4283157 fastest
|
||||
· decode 3,834,348.85 0.0001 0.2465 0.0003 0.0003 0.0003 0.0004 0.0006 ±0.38% 1917175
|
||||
· unquote 8,315,355.96 0.0000 0.3824 0.0001 0.0001 0.0002 0.0002 0.0003 ±0.72% 4157880
|
||||
· duplicates 1,944,765.97 0.0004 0.2959 0.0005 0.0005 0.0006 0.0006 0.0008 ±0.24% 972384
|
||||
· 10 cookies 675,345.67 0.0012 0.4328 0.0015 0.0015 0.0019 0.0020 0.0058 ±0.75% 337673
|
||||
· 100 cookies 61,040.71 0.0152 0.4092 0.0164 0.0160 0.0196 0.0228 0.2260 ±0.71% 30521 slowest
|
||||
✓ parse top-sites (15) 22945ms
|
||||
name hz min max mean p75 p99 p995 p999 rme samples
|
||||
· parse accounts.google.com 7,164,349.17 0.0000 0.0929 0.0001 0.0002 0.0002 0.0002 0.0003 ±0.09% 3582184
|
||||
· parse apple.com 7,817,686.84 0.0000 0.6048 0.0001 0.0001 0.0002 0.0002 0.0003 ±1.05% 3908844
|
||||
· parse cloudflare.com 7,189,841.70 0.0000 0.0390 0.0001 0.0002 0.0002 0.0002 0.0003 ±0.06% 3594921
|
||||
· parse docs.google.com 7,051,765.61 0.0000 0.0296 0.0001 0.0002 0.0002 0.0002 0.0003 ±0.06% 3525883
|
||||
· parse drive.google.com 7,349,104.77 0.0000 0.0368 0.0001 0.0001 0.0002 0.0002 0.0003 ±0.05% 3674553
|
||||
· parse en.wikipedia.org 1,929,909.49 0.0004 0.3598 0.0005 0.0005 0.0007 0.0007 0.0012 ±0.16% 964955
|
||||
· parse linkedin.com 2,225,658.01 0.0003 0.0595 0.0004 0.0005 0.0005 0.0005 0.0006 ±0.06% 1112830
|
||||
· parse maps.google.com 4,423,511.68 0.0001 0.0942 0.0002 0.0003 0.0003 0.0003 0.0005 ±0.08% 2211756
|
||||
· parse microsoft.com 3,387,601.88 0.0002 0.0725 0.0003 0.0003 0.0004 0.0004 0.0005 ±0.09% 1693801
|
||||
· parse play.google.com 7,375,980.86 0.0000 0.1994 0.0001 0.0001 0.0002 0.0002 0.0003 ±0.12% 3687991
|
||||
· parse support.google.com 4,912,267.94 0.0001 2.8958 0.0002 0.0002 0.0003 0.0003 0.0005 ±1.28% 2456134
|
||||
· parse www.google.com 3,443,035.87 0.0002 0.2783 0.0003 0.0003 0.0004 0.0004 0.0007 ±0.51% 1721518
|
||||
· parse youtu.be 1,910,492.87 0.0004 0.3490 0.0005 0.0005 0.0007 0.0007 0.0011 ±0.46% 955247
|
||||
· parse youtube.com 1,895,082.62 0.0004 0.7454 0.0005 0.0005 0.0006 0.0007 0.0013 ±0.64% 947542 slowest
|
||||
· parse example.com 21,582,835.27 0.0000 0.1095 0.0000 0.0000 0.0001 0.0001 0.0001 ±0.13% 10791418
|
||||
```
|
||||
|
||||
## References
|
||||
|
||||
- [RFC 6265: HTTP State Management Mechanism](https://tools.ietf.org/html/rfc6265)
|
||||
- [Same-site Cookies](https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-09#section-5.4.7)
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
[ci-image]: https://img.shields.io/github/actions/workflow/status/jshttp/cookie/ci.yml
|
||||
[ci-url]: https://github.com/jshttp/cookie/actions/workflows/ci.yml?query=branch%3Amaster
|
||||
[coverage-image]: https://img.shields.io/codecov/c/github/jshttp/cookie/master
|
||||
[coverage-url]: https://app.codecov.io/gh/jshttp/cookie
|
||||
[npm-downloads-image]: https://img.shields.io/npm/dm/cookie
|
||||
[npm-url]: https://npmjs.org/package/cookie
|
||||
[npm-version-image]: https://img.shields.io/npm/v/cookie
|
||||
+148
@@ -0,0 +1,148 @@
|
||||
/**
|
||||
* Parse options.
|
||||
*/
|
||||
export interface ParseOptions {
|
||||
/**
|
||||
* Specifies a function that will be used to decode a [cookie-value](https://datatracker.ietf.org/doc/html/rfc6265#section-4.1.1).
|
||||
* Since the value of a cookie has a limited character set (and must be a simple string), this function can be used to decode
|
||||
* a previously-encoded cookie value into a JavaScript string.
|
||||
*
|
||||
* The default function is the global `decodeURIComponent`, wrapped in a `try..catch`. If an error
|
||||
* is thrown it will return the cookie's original value. If you provide your own encode/decode
|
||||
* scheme you must ensure errors are appropriately handled.
|
||||
*
|
||||
* @default decode
|
||||
*/
|
||||
decode?: (str: string) => string | undefined;
|
||||
}
|
||||
/**
|
||||
* Cookies object.
|
||||
*/
|
||||
export type Cookies = Record<string, string | undefined>;
|
||||
/**
|
||||
* Parse a `Cookie` header.
|
||||
*
|
||||
* Parse the given cookie header string into an object
|
||||
* The object has the various cookies as keys(names) => values
|
||||
*/
|
||||
export declare function parseCookie(str: string, options?: ParseOptions): Cookies;
|
||||
export interface StringifyOptions {
|
||||
/**
|
||||
* Specifies a function that will be used to encode a [cookie-value](https://datatracker.ietf.org/doc/html/rfc6265#section-4.1.1).
|
||||
* Since value of a cookie has a limited character set (and must be a simple string), this function can be used to encode
|
||||
* a value into a string suited for a cookie's value, and should mirror `decode` when parsing.
|
||||
*
|
||||
* @default encodeURIComponent
|
||||
*/
|
||||
encode?: (str: string) => string;
|
||||
}
|
||||
/**
|
||||
* Stringifies an object into an HTTP `Cookie` header.
|
||||
*/
|
||||
export declare function stringifyCookie(cookie: Cookies, options?: StringifyOptions): string;
|
||||
/**
|
||||
* Set-Cookie object.
|
||||
*/
|
||||
export interface SetCookie {
|
||||
/**
|
||||
* Specifies the name of the cookie.
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* Specifies the string to be the value for the cookie.
|
||||
*/
|
||||
value: string | undefined;
|
||||
/**
|
||||
* Specifies the `number` (in seconds) to be the value for the [`Max-Age` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.2).
|
||||
*
|
||||
* The [cookie storage model specification](https://tools.ietf.org/html/rfc6265#section-5.3) states that if both `expires` and
|
||||
* `maxAge` are set, then `maxAge` takes precedence, but it is possible not all clients by obey this,
|
||||
* so if both are set, they should point to the same date and time.
|
||||
*/
|
||||
maxAge?: number;
|
||||
/**
|
||||
* Specifies the `Date` object to be the value for the [`Expires` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.1).
|
||||
* When no expiration is set, clients consider this a "non-persistent cookie" and delete it when the current session is over.
|
||||
*
|
||||
* The [cookie storage model specification](https://tools.ietf.org/html/rfc6265#section-5.3) states that if both `expires` and
|
||||
* `maxAge` are set, then `maxAge` takes precedence, but it is possible not all clients by obey this,
|
||||
* so if both are set, they should point to the same date and time.
|
||||
*/
|
||||
expires?: Date;
|
||||
/**
|
||||
* Specifies the value for the [`Domain` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.3).
|
||||
* When no domain is set, clients consider the cookie to apply to the current domain only.
|
||||
*/
|
||||
domain?: string;
|
||||
/**
|
||||
* Specifies the value for the [`Path` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.4).
|
||||
* When no path is set, the path is considered the ["default path"](https://tools.ietf.org/html/rfc6265#section-5.1.4).
|
||||
*/
|
||||
path?: string;
|
||||
/**
|
||||
* Enables the [`HttpOnly` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.6).
|
||||
* When enabled, clients will not allow client-side JavaScript to see the cookie in `document.cookie`.
|
||||
*/
|
||||
httpOnly?: boolean;
|
||||
/**
|
||||
* Enables the [`Secure` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.5).
|
||||
* When enabled, clients will only send the cookie back if the browser has an HTTPS connection.
|
||||
*/
|
||||
secure?: boolean;
|
||||
/**
|
||||
* Enables the [`Partitioned` `Set-Cookie` attribute](https://tools.ietf.org/html/draft-cutler-httpbis-partitioned-cookies/).
|
||||
* When enabled, clients will only send the cookie back when the current domain _and_ top-level domain matches.
|
||||
*
|
||||
* This is an attribute that has not yet been fully standardized, and may change in the future.
|
||||
* This also means clients may ignore this attribute until they understand it. More information
|
||||
* about can be found in [the proposal](https://github.com/privacycg/CHIPS).
|
||||
*/
|
||||
partitioned?: boolean;
|
||||
/**
|
||||
* Specifies the value for the [`Priority` `Set-Cookie` attribute](https://tools.ietf.org/html/draft-west-cookie-priority-00#section-4.1).
|
||||
*
|
||||
* - `'low'` will set the `Priority` attribute to `Low`.
|
||||
* - `'medium'` will set the `Priority` attribute to `Medium`, the default priority when not set.
|
||||
* - `'high'` will set the `Priority` attribute to `High`.
|
||||
*
|
||||
* More information about priority levels can be found in [the specification](https://tools.ietf.org/html/draft-west-cookie-priority-00#section-4.1).
|
||||
*/
|
||||
priority?: "low" | "medium" | "high";
|
||||
/**
|
||||
* Specifies the value for the [`SameSite` `Set-Cookie` attribute](https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-09#section-5.4.7).
|
||||
*
|
||||
* - `true` will set the `SameSite` attribute to `Strict` for strict same site enforcement.
|
||||
* - `'lax'` will set the `SameSite` attribute to `Lax` for lax same site enforcement.
|
||||
* - `'none'` will set the `SameSite` attribute to `None` for an explicit cross-site cookie.
|
||||
* - `'strict'` will set the `SameSite` attribute to `Strict` for strict same site enforcement.
|
||||
*
|
||||
* More information about enforcement levels can be found in [the specification](https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-09#section-5.4.7).
|
||||
*/
|
||||
sameSite?: boolean | "lax" | "strict" | "none";
|
||||
}
|
||||
/**
|
||||
* Backward compatibility serialize options.
|
||||
*/
|
||||
export type SerializeOptions = StringifyOptions & Omit<SetCookie, "name" | "value">;
|
||||
/**
|
||||
* Serialize data into a cookie header.
|
||||
*
|
||||
* Serialize a name value pair into a cookie string suitable for
|
||||
* http headers. An optional options object specifies cookie parameters.
|
||||
*
|
||||
* serialize('foo', 'bar', { httpOnly: true })
|
||||
* => "foo=bar; httpOnly"
|
||||
*/
|
||||
export declare function stringifySetCookie(cookie: SetCookie, options?: StringifyOptions): string;
|
||||
export declare function stringifySetCookie(name: string, val: string, options?: SerializeOptions): string;
|
||||
/**
|
||||
* Deserialize a `Set-Cookie` header into an object.
|
||||
*
|
||||
* deserialize('foo=bar; httpOnly')
|
||||
* => { name: 'foo', value: 'bar', httpOnly: true }
|
||||
*/
|
||||
export declare function parseSetCookie(str: string, options?: ParseOptions): SetCookie;
|
||||
/**
|
||||
* Backward compatibility exports.
|
||||
*/
|
||||
export { stringifySetCookie as serialize, parseCookie as parse };
|
||||
+350
@@ -0,0 +1,350 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.parseCookie = parseCookie;
|
||||
exports.parse = parseCookie;
|
||||
exports.stringifyCookie = stringifyCookie;
|
||||
exports.stringifySetCookie = stringifySetCookie;
|
||||
exports.serialize = stringifySetCookie;
|
||||
exports.parseSetCookie = parseSetCookie;
|
||||
exports.stringifySetCookie = stringifySetCookie;
|
||||
exports.serialize = stringifySetCookie;
|
||||
/**
|
||||
* RegExp to match cookie-name in RFC 6265 sec 4.1.1
|
||||
* This refers out to the obsoleted definition of token in RFC 2616 sec 2.2
|
||||
* which has been replaced by the token definition in RFC 7230 appendix B.
|
||||
*
|
||||
* cookie-name = token
|
||||
* token = 1*tchar
|
||||
* tchar = "!" / "#" / "$" / "%" / "&" / "'" /
|
||||
* "*" / "+" / "-" / "." / "^" / "_" /
|
||||
* "`" / "|" / "~" / DIGIT / ALPHA
|
||||
*
|
||||
* Note: Allowing more characters - https://github.com/jshttp/cookie/issues/191
|
||||
* Allow same range as cookie value, except `=`, which delimits end of name.
|
||||
*/
|
||||
const cookieNameRegExp = /^[\u0021-\u003A\u003C\u003E-\u007E]+$/;
|
||||
/**
|
||||
* RegExp to match cookie-value in RFC 6265 sec 4.1.1
|
||||
*
|
||||
* cookie-value = *cookie-octet / ( DQUOTE *cookie-octet DQUOTE )
|
||||
* cookie-octet = %x21 / %x23-2B / %x2D-3A / %x3C-5B / %x5D-7E
|
||||
* ; US-ASCII characters excluding CTLs,
|
||||
* ; whitespace DQUOTE, comma, semicolon,
|
||||
* ; and backslash
|
||||
*
|
||||
* Allowing more characters: https://github.com/jshttp/cookie/issues/191
|
||||
* Comma, backslash, and DQUOTE are not part of the parsing algorithm.
|
||||
*/
|
||||
const cookieValueRegExp = /^[\u0021-\u003A\u003C-\u007E]*$/;
|
||||
/**
|
||||
* RegExp to match domain-value in RFC 6265 sec 4.1.1
|
||||
*
|
||||
* domain-value = <subdomain>
|
||||
* ; defined in [RFC1034], Section 3.5, as
|
||||
* ; enhanced by [RFC1123], Section 2.1
|
||||
* <subdomain> = <label> | <subdomain> "." <label>
|
||||
* <label> = <let-dig> [ [ <ldh-str> ] <let-dig> ]
|
||||
* Labels must be 63 characters or less.
|
||||
* 'let-dig' not 'letter' in the first char, per RFC1123
|
||||
* <ldh-str> = <let-dig-hyp> | <let-dig-hyp> <ldh-str>
|
||||
* <let-dig-hyp> = <let-dig> | "-"
|
||||
* <let-dig> = <letter> | <digit>
|
||||
* <letter> = any one of the 52 alphabetic characters A through Z in
|
||||
* upper case and a through z in lower case
|
||||
* <digit> = any one of the ten digits 0 through 9
|
||||
*
|
||||
* Keep support for leading dot: https://github.com/jshttp/cookie/issues/173
|
||||
*
|
||||
* > (Note that a leading %x2E ("."), if present, is ignored even though that
|
||||
* character is not permitted, but a trailing %x2E ("."), if present, will
|
||||
* cause the user agent to ignore the attribute.)
|
||||
*/
|
||||
const domainValueRegExp = /^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i;
|
||||
/**
|
||||
* RegExp to match path-value in RFC 6265 sec 4.1.1
|
||||
*
|
||||
* path-value = <any CHAR except CTLs or ";">
|
||||
* CHAR = %x01-7F
|
||||
* ; defined in RFC 5234 appendix B.1
|
||||
*/
|
||||
const pathValueRegExp = /^[\u0020-\u003A\u003D-\u007E]*$/;
|
||||
/**
|
||||
* RegExp to match max-age-value in RFC 6265 sec 5.6.2
|
||||
*/
|
||||
const maxAgeRegExp = /^-?\d+$/;
|
||||
const __toString = Object.prototype.toString;
|
||||
const NullObject = /* @__PURE__ */ (() => {
|
||||
const C = function () { };
|
||||
C.prototype = Object.create(null);
|
||||
return C;
|
||||
})();
|
||||
/**
|
||||
* Parse a `Cookie` header.
|
||||
*
|
||||
* Parse the given cookie header string into an object
|
||||
* The object has the various cookies as keys(names) => values
|
||||
*/
|
||||
function parseCookie(str, options) {
|
||||
const obj = new NullObject();
|
||||
const len = str.length;
|
||||
// RFC 6265 sec 4.1.1, RFC 2616 2.2 defines a cookie name consists of one char minimum, plus '='.
|
||||
if (len < 2)
|
||||
return obj;
|
||||
const dec = options?.decode || decode;
|
||||
let index = 0;
|
||||
do {
|
||||
const eqIdx = eqIndex(str, index, len);
|
||||
if (eqIdx === -1)
|
||||
break; // No more cookie pairs.
|
||||
const endIdx = endIndex(str, index, len);
|
||||
if (eqIdx > endIdx) {
|
||||
// backtrack on prior semicolon
|
||||
index = str.lastIndexOf(";", eqIdx - 1) + 1;
|
||||
continue;
|
||||
}
|
||||
const key = valueSlice(str, index, eqIdx);
|
||||
// only assign once
|
||||
if (obj[key] === undefined) {
|
||||
obj[key] = dec(valueSlice(str, eqIdx + 1, endIdx));
|
||||
}
|
||||
index = endIdx + 1;
|
||||
} while (index < len);
|
||||
return obj;
|
||||
}
|
||||
/**
|
||||
* Stringifies an object into an HTTP `Cookie` header.
|
||||
*/
|
||||
function stringifyCookie(cookie, options) {
|
||||
const enc = options?.encode || encodeURIComponent;
|
||||
const cookieStrings = [];
|
||||
for (const name of Object.keys(cookie)) {
|
||||
const val = cookie[name];
|
||||
if (val === undefined)
|
||||
continue;
|
||||
if (!cookieNameRegExp.test(name)) {
|
||||
throw new TypeError(`cookie name is invalid: ${name}`);
|
||||
}
|
||||
const value = enc(val);
|
||||
if (!cookieValueRegExp.test(value)) {
|
||||
throw new TypeError(`cookie val is invalid: ${val}`);
|
||||
}
|
||||
cookieStrings.push(`${name}=${value}`);
|
||||
}
|
||||
return cookieStrings.join("; ");
|
||||
}
|
||||
function stringifySetCookie(_name, _val, _opts) {
|
||||
const cookie = typeof _name === "object"
|
||||
? _name
|
||||
: { ..._opts, name: _name, value: String(_val) };
|
||||
const options = typeof _val === "object" ? _val : _opts;
|
||||
const enc = options?.encode || encodeURIComponent;
|
||||
if (!cookieNameRegExp.test(cookie.name)) {
|
||||
throw new TypeError(`argument name is invalid: ${cookie.name}`);
|
||||
}
|
||||
const value = cookie.value ? enc(cookie.value) : "";
|
||||
if (!cookieValueRegExp.test(value)) {
|
||||
throw new TypeError(`argument val is invalid: ${cookie.value}`);
|
||||
}
|
||||
let str = cookie.name + "=" + value;
|
||||
if (cookie.maxAge !== undefined) {
|
||||
if (!Number.isInteger(cookie.maxAge)) {
|
||||
throw new TypeError(`option maxAge is invalid: ${cookie.maxAge}`);
|
||||
}
|
||||
str += "; Max-Age=" + cookie.maxAge;
|
||||
}
|
||||
if (cookie.domain) {
|
||||
if (!domainValueRegExp.test(cookie.domain)) {
|
||||
throw new TypeError(`option domain is invalid: ${cookie.domain}`);
|
||||
}
|
||||
str += "; Domain=" + cookie.domain;
|
||||
}
|
||||
if (cookie.path) {
|
||||
if (!pathValueRegExp.test(cookie.path)) {
|
||||
throw new TypeError(`option path is invalid: ${cookie.path}`);
|
||||
}
|
||||
str += "; Path=" + cookie.path;
|
||||
}
|
||||
if (cookie.expires) {
|
||||
if (!isDate(cookie.expires) || !Number.isFinite(cookie.expires.valueOf())) {
|
||||
throw new TypeError(`option expires is invalid: ${cookie.expires}`);
|
||||
}
|
||||
str += "; Expires=" + cookie.expires.toUTCString();
|
||||
}
|
||||
if (cookie.httpOnly) {
|
||||
str += "; HttpOnly";
|
||||
}
|
||||
if (cookie.secure) {
|
||||
str += "; Secure";
|
||||
}
|
||||
if (cookie.partitioned) {
|
||||
str += "; Partitioned";
|
||||
}
|
||||
if (cookie.priority) {
|
||||
const priority = typeof cookie.priority === "string"
|
||||
? cookie.priority.toLowerCase()
|
||||
: undefined;
|
||||
switch (priority) {
|
||||
case "low":
|
||||
str += "; Priority=Low";
|
||||
break;
|
||||
case "medium":
|
||||
str += "; Priority=Medium";
|
||||
break;
|
||||
case "high":
|
||||
str += "; Priority=High";
|
||||
break;
|
||||
default:
|
||||
throw new TypeError(`option priority is invalid: ${cookie.priority}`);
|
||||
}
|
||||
}
|
||||
if (cookie.sameSite) {
|
||||
const sameSite = typeof cookie.sameSite === "string"
|
||||
? cookie.sameSite.toLowerCase()
|
||||
: cookie.sameSite;
|
||||
switch (sameSite) {
|
||||
case true:
|
||||
case "strict":
|
||||
str += "; SameSite=Strict";
|
||||
break;
|
||||
case "lax":
|
||||
str += "; SameSite=Lax";
|
||||
break;
|
||||
case "none":
|
||||
str += "; SameSite=None";
|
||||
break;
|
||||
default:
|
||||
throw new TypeError(`option sameSite is invalid: ${cookie.sameSite}`);
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
/**
|
||||
* Deserialize a `Set-Cookie` header into an object.
|
||||
*
|
||||
* deserialize('foo=bar; httpOnly')
|
||||
* => { name: 'foo', value: 'bar', httpOnly: true }
|
||||
*/
|
||||
function parseSetCookie(str, options) {
|
||||
const dec = options?.decode || decode;
|
||||
const len = str.length;
|
||||
const endIdx = endIndex(str, 0, len);
|
||||
const eqIdx = eqIndex(str, 0, endIdx);
|
||||
const setCookie = eqIdx === -1
|
||||
? { name: "", value: dec(valueSlice(str, 0, endIdx)) }
|
||||
: {
|
||||
name: valueSlice(str, 0, eqIdx),
|
||||
value: dec(valueSlice(str, eqIdx + 1, endIdx)),
|
||||
};
|
||||
let index = endIdx + 1;
|
||||
while (index < len) {
|
||||
const endIdx = endIndex(str, index, len);
|
||||
const eqIdx = eqIndex(str, index, endIdx);
|
||||
const attr = eqIdx === -1
|
||||
? valueSlice(str, index, endIdx)
|
||||
: valueSlice(str, index, eqIdx);
|
||||
const val = eqIdx === -1 ? undefined : valueSlice(str, eqIdx + 1, endIdx);
|
||||
switch (attr.toLowerCase()) {
|
||||
case "httponly":
|
||||
setCookie.httpOnly = true;
|
||||
break;
|
||||
case "secure":
|
||||
setCookie.secure = true;
|
||||
break;
|
||||
case "partitioned":
|
||||
setCookie.partitioned = true;
|
||||
break;
|
||||
case "domain":
|
||||
setCookie.domain = val;
|
||||
break;
|
||||
case "path":
|
||||
setCookie.path = val;
|
||||
break;
|
||||
case "max-age":
|
||||
if (val && maxAgeRegExp.test(val))
|
||||
setCookie.maxAge = Number(val);
|
||||
break;
|
||||
case "expires":
|
||||
if (!val)
|
||||
break;
|
||||
const date = new Date(val);
|
||||
if (Number.isFinite(date.valueOf()))
|
||||
setCookie.expires = date;
|
||||
break;
|
||||
case "priority":
|
||||
if (!val)
|
||||
break;
|
||||
const priority = val.toLowerCase();
|
||||
if (priority === "low" ||
|
||||
priority === "medium" ||
|
||||
priority === "high") {
|
||||
setCookie.priority = priority;
|
||||
}
|
||||
break;
|
||||
case "samesite":
|
||||
if (!val)
|
||||
break;
|
||||
const sameSite = val.toLowerCase();
|
||||
if (sameSite === "lax" ||
|
||||
sameSite === "strict" ||
|
||||
sameSite === "none") {
|
||||
setCookie.sameSite = sameSite;
|
||||
}
|
||||
break;
|
||||
}
|
||||
index = endIdx + 1;
|
||||
}
|
||||
return setCookie;
|
||||
}
|
||||
/**
|
||||
* Find the `;` character between `min` and `len` in str.
|
||||
*/
|
||||
function endIndex(str, min, len) {
|
||||
const index = str.indexOf(";", min);
|
||||
return index === -1 ? len : index;
|
||||
}
|
||||
/**
|
||||
* Find the `=` character between `min` and `max` in str.
|
||||
*/
|
||||
function eqIndex(str, min, max) {
|
||||
const index = str.indexOf("=", min);
|
||||
return index < max ? index : -1;
|
||||
}
|
||||
/**
|
||||
* Slice out a value between startPod to max.
|
||||
*/
|
||||
function valueSlice(str, min, max) {
|
||||
let start = min;
|
||||
let end = max;
|
||||
do {
|
||||
const code = str.charCodeAt(start);
|
||||
if (code !== 0x20 /* */ && code !== 0x09 /* \t */)
|
||||
break;
|
||||
} while (++start < end);
|
||||
while (end > start) {
|
||||
const code = str.charCodeAt(end - 1);
|
||||
if (code !== 0x20 /* */ && code !== 0x09 /* \t */)
|
||||
break;
|
||||
end--;
|
||||
}
|
||||
return str.slice(start, end);
|
||||
}
|
||||
/**
|
||||
* URL-decode string value. Optimized to skip native call when no %.
|
||||
*/
|
||||
function decode(str) {
|
||||
if (str.indexOf("%") === -1)
|
||||
return str;
|
||||
try {
|
||||
return decodeURIComponent(str);
|
||||
}
|
||||
catch (e) {
|
||||
return str;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Determine if value is a Date.
|
||||
*/
|
||||
function isDate(val) {
|
||||
return __toString.call(val) === "[object Date]";
|
||||
}
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AA2GA,kCAgCC;AAmZwD,4BAAK;AAnY9D,0CAyBC;AA2GD,gDA8GC;AAiJ8B,uCAAS;AAzIxC,wCA2EC;AA1MD,gDAGU;AAqQqB,uCAAS;AA9hBxC;;;;;;;;;;;;;GAaG;AACH,MAAM,gBAAgB,GAAG,uCAAuC,CAAC;AAEjE;;;;;;;;;;;GAWG;AACH,MAAM,iBAAiB,GAAG,iCAAiC,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,iBAAiB,GACrB,qFAAqF,CAAC;AAExF;;;;;;GAMG;AACH,MAAM,eAAe,GAAG,iCAAiC,CAAC;AAE1D;;GAEG;AACH,MAAM,YAAY,GAAG,SAAS,CAAC;AAE/B,MAAM,UAAU,GAAG,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC;AAE7C,MAAM,UAAU,GAAG,eAAe,CAAC,CAAC,GAAG,EAAE;IACvC,MAAM,CAAC,GAAG,cAAa,CAAC,CAAC;IACzB,CAAC,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAClC,OAAO,CAAC,CAAC;AACX,CAAC,CAAC,EAAgC,CAAC;AAyBnC;;;;;GAKG;AACH,SAAgB,WAAW,CAAC,GAAW,EAAE,OAAsB;IAC7D,MAAM,GAAG,GAAY,IAAI,UAAU,EAAE,CAAC;IACtC,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC;IACvB,iGAAiG;IACjG,IAAI,GAAG,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC;IAExB,MAAM,GAAG,GAAG,OAAO,EAAE,MAAM,IAAI,MAAM,CAAC;IACtC,IAAI,KAAK,GAAG,CAAC,CAAC;IAEd,GAAG,CAAC;QACF,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;QACvC,IAAI,KAAK,KAAK,CAAC,CAAC;YAAE,MAAM,CAAC,wBAAwB;QAEjD,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;QAEzC,IAAI,KAAK,GAAG,MAAM,EAAE,CAAC;YACnB,+BAA+B;YAC/B,KAAK,GAAG,GAAG,CAAC,WAAW,CAAC,GAAG,EAAE,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;YAC5C,SAAS;QACX,CAAC;QAED,MAAM,GAAG,GAAG,UAAU,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;QAE1C,mBAAmB;QACnB,IAAI,GAAG,CAAC,GAAG,CAAC,KAAK,SAAS,EAAE,CAAC;YAC3B,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;QACrD,CAAC;QAED,KAAK,GAAG,MAAM,GAAG,CAAC,CAAC;IACrB,CAAC,QAAQ,KAAK,GAAG,GAAG,EAAE;IAEtB,OAAO,GAAG,CAAC;AACb,CAAC;AAaD;;GAEG;AACH,SAAgB,eAAe,CAC7B,MAAe,EACf,OAA0B;IAE1B,MAAM,GAAG,GAAG,OAAO,EAAE,MAAM,IAAI,kBAAkB,CAAC;IAClD,MAAM,aAAa,GAAa,EAAE,CAAC;IAEnC,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACvC,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;QACzB,IAAI,GAAG,KAAK,SAAS;YAAE,SAAS;QAEhC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YACjC,MAAM,IAAI,SAAS,CAAC,2BAA2B,IAAI,EAAE,CAAC,CAAC;QACzD,CAAC;QAED,MAAM,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;QAEvB,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACnC,MAAM,IAAI,SAAS,CAAC,0BAA0B,GAAG,EAAE,CAAC,CAAC;QACvD,CAAC;QAED,aAAa,CAAC,IAAI,CAAC,GAAG,IAAI,IAAI,KAAK,EAAE,CAAC,CAAC;IACzC,CAAC;IAED,OAAO,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAClC,CAAC;AA2GD,SAAgB,kBAAkB,CAChC,KAAyB,EACzB,IAAgC,EAChC,KAAwB;IAExB,MAAM,MAAM,GACV,OAAO,KAAK,KAAK,QAAQ;QACvB,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;IACrD,MAAM,OAAO,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;IACxD,MAAM,GAAG,GAAG,OAAO,EAAE,MAAM,IAAI,kBAAkB,CAAC;IAElD,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;QACxC,MAAM,IAAI,SAAS,CAAC,6BAA6B,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IAClE,CAAC;IAED,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAEpD,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACnC,MAAM,IAAI,SAAS,CAAC,4BAA4B,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;IAClE,CAAC;IAED,IAAI,GAAG,GAAG,MAAM,CAAC,IAAI,GAAG,GAAG,GAAG,KAAK,CAAC;IAEpC,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QAChC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;YACrC,MAAM,IAAI,SAAS,CAAC,6BAA6B,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;QACpE,CAAC;QAED,GAAG,IAAI,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC;IACtC,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAClB,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;YAC3C,MAAM,IAAI,SAAS,CAAC,6BAA6B,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;QACpE,CAAC;QAED,GAAG,IAAI,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC;IACrC,CAAC;IAED,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;QAChB,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;YACvC,MAAM,IAAI,SAAS,CAAC,2BAA2B,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;QAChE,CAAC;QAED,GAAG,IAAI,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC;IACjC,CAAC;IAED,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC;YAC1E,MAAM,IAAI,SAAS,CAAC,8BAA8B,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;QACtE,CAAC;QAED,GAAG,IAAI,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;IACrD,CAAC;IAED,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;QACpB,GAAG,IAAI,YAAY,CAAC;IACtB,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAClB,GAAG,IAAI,UAAU,CAAC;IACpB,CAAC;IAED,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;QACvB,GAAG,IAAI,eAAe,CAAC;IACzB,CAAC;IAED,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;QACpB,MAAM,QAAQ,GACZ,OAAO,MAAM,CAAC,QAAQ,KAAK,QAAQ;YACjC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,EAAE;YAC/B,CAAC,CAAC,SAAS,CAAC;QAChB,QAAQ,QAAQ,EAAE,CAAC;YACjB,KAAK,KAAK;gBACR,GAAG,IAAI,gBAAgB,CAAC;gBACxB,MAAM;YACR,KAAK,QAAQ;gBACX,GAAG,IAAI,mBAAmB,CAAC;gBAC3B,MAAM;YACR,KAAK,MAAM;gBACT,GAAG,IAAI,iBAAiB,CAAC;gBACzB,MAAM;YACR;gBACE,MAAM,IAAI,SAAS,CAAC,+BAA+B,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC1E,CAAC;IACH,CAAC;IAED,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;QACpB,MAAM,QAAQ,GACZ,OAAO,MAAM,CAAC,QAAQ,KAAK,QAAQ;YACjC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,EAAE;YAC/B,CAAC,CAAC,MAAM,CAAC,QAALine truncated
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"name": "cookie",
|
||||
"version": "1.1.1",
|
||||
"description": "HTTP server cookie parsing and serialization",
|
||||
"keywords": [
|
||||
"cookie",
|
||||
"cookies"
|
||||
],
|
||||
"repository": "jshttp/cookie",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/express"
|
||||
},
|
||||
"license": "MIT",
|
||||
"author": "Roman Shtylman <shtylman@gmail.com>",
|
||||
"contributors": [
|
||||
"Douglas Christopher Wilson <doug@somethingdoug.com>"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"files": [
|
||||
"dist/"
|
||||
],
|
||||
"scripts": {
|
||||
"bench": "vitest bench",
|
||||
"build": "ts-scripts build",
|
||||
"format": "ts-scripts format",
|
||||
"prepare": "ts-scripts install",
|
||||
"prepublishOnly": "npm run build",
|
||||
"specs": "ts-scripts specs",
|
||||
"test": "ts-scripts test"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@borderless/ts-scripts": "^0.15.0",
|
||||
"@vitest/coverage-v8": "^3.2.4",
|
||||
"top-sites": "1.1.194",
|
||||
"typescript": "^5.6.2",
|
||||
"vitest": "^3.2.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"ts-scripts": {
|
||||
"project": "tsconfig.build.json"
|
||||
}
|
||||
}
|
||||
+1599
File diff suppressed because it is too large.
Load diff
+133
@@ -0,0 +1,133 @@
|
||||
/*!
|
||||
* CSSRulePlugin 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
|
||||
*/
|
||||
|
||||
/* eslint-disable */
|
||||
var gsap,
|
||||
_coreInitted,
|
||||
_win,
|
||||
_doc,
|
||||
CSSPlugin,
|
||||
_windowExists = function _windowExists() {
|
||||
return typeof window !== "undefined";
|
||||
},
|
||||
_getGSAP = function _getGSAP() {
|
||||
return gsap || _windowExists() && (gsap = window.gsap) && gsap.registerPlugin && gsap;
|
||||
},
|
||||
_checkRegister = function _checkRegister() {
|
||||
if (!_coreInitted) {
|
||||
_initCore();
|
||||
|
||||
if (!CSSPlugin) {
|
||||
console.warn("Please gsap.registerPlugin(CSSPlugin, CSSRulePlugin)");
|
||||
}
|
||||
}
|
||||
|
||||
return _coreInitted;
|
||||
},
|
||||
_initCore = function _initCore(core) {
|
||||
gsap = core || _getGSAP();
|
||||
|
||||
if (_windowExists()) {
|
||||
_win = window;
|
||||
_doc = document;
|
||||
}
|
||||
|
||||
if (gsap) {
|
||||
CSSPlugin = gsap.plugins.css;
|
||||
|
||||
if (CSSPlugin) {
|
||||
_coreInitted = 1;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export var CSSRulePlugin = {
|
||||
version: "3.14.2",
|
||||
name: "cssRule",
|
||||
init: function init(target, value, tween, index, targets) {
|
||||
if (!_checkRegister() || typeof target.cssText === "undefined") {
|
||||
return false;
|
||||
}
|
||||
|
||||
var div = target._gsProxy = target._gsProxy || _doc.createElement("div");
|
||||
|
||||
this.ss = target;
|
||||
this.style = div.style;
|
||||
div.style.cssText = target.cssText;
|
||||
CSSPlugin.prototype.init.call(this, div, value, tween, index, targets); //we just offload all the work to the regular CSSPlugin and then copy the cssText back over to the rule in the render() method. This allows us to have all of the updates to CSSPlugin automatically flow through to CSSRulePlugin instead of having to maintain both
|
||||
},
|
||||
render: function render(ratio, data) {
|
||||
var pt = data._pt,
|
||||
style = data.style,
|
||||
ss = data.ss,
|
||||
i;
|
||||
|
||||
while (pt) {
|
||||
pt.r(ratio, pt.d);
|
||||
pt = pt._next;
|
||||
}
|
||||
|
||||
i = style.length;
|
||||
|
||||
while (--i > -1) {
|
||||
ss[style[i]] = style[style[i]];
|
||||
}
|
||||
},
|
||||
getRule: function getRule(selector) {
|
||||
_checkRegister();
|
||||
|
||||
var ruleProp = _doc.all ? "rules" : "cssRules",
|
||||
styleSheets = _doc.styleSheets,
|
||||
i = styleSheets.length,
|
||||
pseudo = selector.charAt(0) === ":",
|
||||
j,
|
||||
curSS,
|
||||
cs,
|
||||
a;
|
||||
selector = (pseudo ? "" : ",") + selector.split("::").join(":").toLowerCase() + ","; //note: old versions of IE report tag name selectors as upper case, so we just change everything to lowercase.
|
||||
|
||||
if (pseudo) {
|
||||
a = [];
|
||||
}
|
||||
|
||||
while (i--) {
|
||||
//Firefox may throw insecure operation errors when css is loaded from other domains, so try/catch.
|
||||
try {
|
||||
curSS = styleSheets[i][ruleProp];
|
||||
|
||||
if (!curSS) {
|
||||
continue;
|
||||
}
|
||||
|
||||
j = curSS.length;
|
||||
} catch (e) {
|
||||
console.warn(e);
|
||||
continue;
|
||||
}
|
||||
|
||||
while (--j > -1) {
|
||||
cs = curSS[j];
|
||||
|
||||
if (cs.selectorText && ("," + cs.selectorText.split("::").join(":").toLowerCase() + ",").indexOf(selector) !== -1) {
|
||||
//note: IE adds an extra ":" to pseudo selectors, so .myClass:after becomes .myClass::after, so we need to strip the extra one out.
|
||||
if (pseudo) {
|
||||
a.push(cs.style);
|
||||
} else {
|
||||
return cs.style;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return a;
|
||||
},
|
||||
register: _initCore
|
||||
};
|
||||
_getGSAP() && gsap.registerPlugin(CSSRulePlugin);
|
||||
export { CSSRulePlugin as default };
|
||||
+165
@@ -0,0 +1,165 @@
|
||||
/*!
|
||||
* CustomBounce 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
|
||||
*/
|
||||
|
||||
/* eslint-disable */
|
||||
var gsap,
|
||||
_coreInitted,
|
||||
createCustomEase,
|
||||
_getGSAP = function _getGSAP() {
|
||||
return gsap || typeof window !== "undefined" && (gsap = window.gsap) && gsap.registerPlugin && gsap;
|
||||
},
|
||||
_initCore = function _initCore(required) {
|
||||
gsap = _getGSAP();
|
||||
createCustomEase = gsap && gsap.parseEase("_CE");
|
||||
|
||||
if (createCustomEase) {
|
||||
_coreInitted = 1;
|
||||
|
||||
gsap.parseEase("bounce").config = function (vars) {
|
||||
return typeof vars === "object" ? _create("", vars) : _create("bounce(" + vars + ")", {
|
||||
strength: +vars
|
||||
});
|
||||
};
|
||||
} else {
|
||||
required && console.warn("Please gsap.registerPlugin(CustomEase, CustomBounce)");
|
||||
}
|
||||
},
|
||||
_normalizeX = function _normalizeX(a) {
|
||||
//scales all the x values in an array [x, y, x, y...] AND rounds them to the closest hundredth (decimal)
|
||||
var l = a.length,
|
||||
s = 1 / a[l - 2],
|
||||
rnd = 1000,
|
||||
i;
|
||||
|
||||
for (i = 2; i < l; i += 2) {
|
||||
a[i] = ~~(a[i] * s * rnd) / rnd;
|
||||
}
|
||||
|
||||
a[l - 2] = 1; //in case there are any rounding errors. x should always end at 1.
|
||||
},
|
||||
_bonusValidated = 1,
|
||||
//<name>CustomBounce</name>
|
||||
_create = function _create(id, vars) {
|
||||
if (!_coreInitted) {
|
||||
_initCore(1);
|
||||
}
|
||||
|
||||
vars = vars || {};
|
||||
|
||||
if (_bonusValidated) {
|
||||
var max = 0.999,
|
||||
decay = Math.min(max, vars.strength || 0.7),
|
||||
// Math.min(0.999, 1 - 0.3 / (vars.strength || 1)),
|
||||
decayX = decay,
|
||||
gap = (vars.squash || 0) / 100,
|
||||
originalGap = gap,
|
||||
slope = 1 / 0.03,
|
||||
w = 0.2,
|
||||
h = 1,
|
||||
prevX = 0.1,
|
||||
path = [0, 0, 0.07, 0, 0.1, 1, 0.1, 1],
|
||||
squashPath = [0, 0, 0, 0, 0.1, 0, 0.1, 0],
|
||||
cp1,
|
||||
cp2,
|
||||
x,
|
||||
y,
|
||||
i,
|
||||
nextX,
|
||||
squishMagnitude;
|
||||
|
||||
for (i = 0; i < 200; i++) {
|
||||
w *= decayX * ((decayX + 1) / 2);
|
||||
h *= decay * decay;
|
||||
nextX = prevX + w;
|
||||
x = prevX + w * 0.49;
|
||||
y = 1 - h;
|
||||
cp1 = prevX + h / slope;
|
||||
cp2 = x + (x - cp1) * 0.8;
|
||||
|
||||
if (gap) {
|
||||
prevX += gap;
|
||||
cp1 += gap;
|
||||
x += gap;
|
||||
cp2 += gap;
|
||||
nextX += gap;
|
||||
squishMagnitude = gap / originalGap;
|
||||
squashPath.push(prevX - gap, 0, prevX - gap, squishMagnitude, prevX - gap / 2, squishMagnitude, //center peak anchor
|
||||
prevX, squishMagnitude, prevX, 0, prevX, 0, //base anchor
|
||||
prevX, squishMagnitude * -0.6, prevX + (nextX - prevX) / 6, 0, nextX, 0);
|
||||
path.push(prevX - gap, 1, prevX, 1, prevX, 1);
|
||||
gap *= decay * decay;
|
||||
}
|
||||
|
||||
path.push(prevX, 1, cp1, y, x, y, cp2, y, nextX, 1, nextX, 1);
|
||||
decay *= 0.95;
|
||||
slope = h / (nextX - cp2);
|
||||
prevX = nextX;
|
||||
|
||||
if (y > max) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (vars.endAtStart && vars.endAtStart !== "false") {
|
||||
x = -0.1;
|
||||
path.unshift(x, 1, x, 1, -0.07, 0);
|
||||
|
||||
if (originalGap) {
|
||||
gap = originalGap * 2.5; //make the initial anticipation squash longer (more realistic)
|
||||
|
||||
x -= gap;
|
||||
path.unshift(x, 1, x, 1, x, 1);
|
||||
squashPath.splice(0, 6);
|
||||
squashPath.unshift(x, 0, x, 0, x, 1, x + gap / 2, 1, x + gap, 1, x + gap, 0, x + gap, 0, x + gap, -0.6, x + gap + 0.033, 0);
|
||||
|
||||
for (i = 0; i < squashPath.length; i += 2) {
|
||||
squashPath[i] -= x;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < path.length; i += 2) {
|
||||
path[i] -= x;
|
||||
path[i + 1] = 1 - path[i + 1];
|
||||
}
|
||||
}
|
||||
|
||||
if (gap) {
|
||||
_normalizeX(squashPath);
|
||||
|
||||
squashPath[2] = "C" + squashPath[2];
|
||||
createCustomEase(vars.squashID || id + "-squash", "M" + squashPath.join(","));
|
||||
}
|
||||
|
||||
_normalizeX(path);
|
||||
|
||||
path[2] = "C" + path[2];
|
||||
return createCustomEase(id, "M" + path.join(","));
|
||||
}
|
||||
};
|
||||
|
||||
export var CustomBounce = /*#__PURE__*/function () {
|
||||
function CustomBounce(id, vars) {
|
||||
this.ease = _create(id, vars);
|
||||
}
|
||||
|
||||
CustomBounce.create = function create(id, vars) {
|
||||
return _create(id, vars);
|
||||
};
|
||||
|
||||
CustomBounce.register = function register(core) {
|
||||
gsap = core;
|
||||
|
||||
_initCore();
|
||||
};
|
||||
|
||||
return CustomBounce;
|
||||
}();
|
||||
_getGSAP() && gsap.registerPlugin(CustomBounce);
|
||||
CustomBounce.version = "3.14.2";
|
||||
export { CustomBounce as default };
|
||||
+373
@@ -0,0 +1,373 @@
|
||||
/*!
|
||||
* CustomEase 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
|
||||
*/
|
||||
|
||||
/* eslint-disable */
|
||||
import { stringToRawPath, rawPathToString, transformRawPath } from "./utils/paths.js";
|
||||
|
||||
var gsap,
|
||||
_coreInitted,
|
||||
_getGSAP = function _getGSAP() {
|
||||
return gsap || typeof window !== "undefined" && (gsap = window.gsap) && gsap.registerPlugin && gsap;
|
||||
},
|
||||
_initCore = function _initCore() {
|
||||
gsap = _getGSAP();
|
||||
|
||||
if (gsap) {
|
||||
gsap.registerEase("_CE", CustomEase.create);
|
||||
_coreInitted = 1;
|
||||
} else {
|
||||
console.warn("Please gsap.registerPlugin(CustomEase)");
|
||||
}
|
||||
},
|
||||
_bigNum = 1e20,
|
||||
_round = function _round(value) {
|
||||
return ~~(value * 1000 + (value < 0 ? -.5 : .5)) / 1000;
|
||||
},
|
||||
_bonusValidated = 1,
|
||||
//<name>CustomEase</name>
|
||||
_numExp = /[-+=.]*\d+[.e\-+]*\d*[e\-+]*\d*/gi,
|
||||
//finds any numbers, including ones that start with += or -=, negative numbers, and ones in scientific notation like 1e-8.
|
||||
_needsParsingExp = /[cLlsSaAhHvVtTqQ]/g,
|
||||
_findMinimum = function _findMinimum(values) {
|
||||
var l = values.length,
|
||||
min = _bigNum,
|
||||
i;
|
||||
|
||||
for (i = 1; i < l; i += 6) {
|
||||
+values[i] < min && (min = +values[i]);
|
||||
}
|
||||
|
||||
return min;
|
||||
},
|
||||
//takes all the points and translates/scales them so that the x starts at 0 and ends at 1.
|
||||
_normalize = function _normalize(values, height, originY) {
|
||||
if (!originY && originY !== 0) {
|
||||
originY = Math.max(+values[values.length - 1], +values[1]);
|
||||
}
|
||||
|
||||
var tx = +values[0] * -1,
|
||||
ty = -originY,
|
||||
l = values.length,
|
||||
sx = 1 / (+values[l - 2] + tx),
|
||||
sy = -height || (Math.abs(+values[l - 1] - +values[1]) < 0.01 * (+values[l - 2] - +values[0]) ? _findMinimum(values) + ty : +values[l - 1] + ty),
|
||||
i;
|
||||
|
||||
if (sy) {
|
||||
//typically y ends at 1 (so that the end values are reached)
|
||||
sy = 1 / sy;
|
||||
} else {
|
||||
//in case the ease returns to its beginning value, scale everything proportionally
|
||||
sy = -sx;
|
||||
}
|
||||
|
||||
for (i = 0; i < l; i += 2) {
|
||||
values[i] = (+values[i] + tx) * sx;
|
||||
values[i + 1] = (+values[i + 1] + ty) * sy;
|
||||
}
|
||||
},
|
||||
//note that this function returns point objects like {x, y} rather than working with segments which are arrays with alternating x, y values as in the similar function in paths.js
|
||||
_bezierToPoints = function _bezierToPoints(x1, y1, x2, y2, x3, y3, x4, y4, threshold, points, index) {
|
||||
var x12 = (x1 + x2) / 2,
|
||||
y12 = (y1 + y2) / 2,
|
||||
x23 = (x2 + x3) / 2,
|
||||
y23 = (y2 + y3) / 2,
|
||||
x34 = (x3 + x4) / 2,
|
||||
y34 = (y3 + y4) / 2,
|
||||
x123 = (x12 + x23) / 2,
|
||||
y123 = (y12 + y23) / 2,
|
||||
x234 = (x23 + x34) / 2,
|
||||
y234 = (y23 + y34) / 2,
|
||||
x1234 = (x123 + x234) / 2,
|
||||
y1234 = (y123 + y234) / 2,
|
||||
dx = x4 - x1,
|
||||
dy = y4 - y1,
|
||||
d2 = Math.abs((x2 - x4) * dy - (y2 - y4) * dx),
|
||||
d3 = Math.abs((x3 - x4) * dy - (y3 - y4) * dx),
|
||||
length;
|
||||
|
||||
if (!points) {
|
||||
points = [{
|
||||
x: x1,
|
||||
y: y1
|
||||
}, {
|
||||
x: x4,
|
||||
y: y4
|
||||
}];
|
||||
index = 1;
|
||||
}
|
||||
|
||||
points.splice(index || points.length - 1, 0, {
|
||||
x: x1234,
|
||||
y: y1234
|
||||
});
|
||||
|
||||
if ((d2 + d3) * (d2 + d3) > threshold * (dx * dx + dy * dy)) {
|
||||
length = points.length;
|
||||
|
||||
_bezierToPoints(x1, y1, x12, y12, x123, y123, x1234, y1234, threshold, points, index);
|
||||
|
||||
_bezierToPoints(x1234, y1234, x234, y234, x34, y34, x4, y4, threshold, points, index + 1 + (points.length - length));
|
||||
}
|
||||
|
||||
return points;
|
||||
};
|
||||
|
||||
export var CustomEase = /*#__PURE__*/function () {
|
||||
function CustomEase(id, data, config) {
|
||||
_coreInitted || _initCore();
|
||||
this.id = id;
|
||||
_bonusValidated && this.setData(data, config);
|
||||
}
|
||||
|
||||
var _proto = CustomEase.prototype;
|
||||
|
||||
_proto.setData = function setData(data, config) {
|
||||
config = config || {};
|
||||
data = data || "0,0,1,1";
|
||||
var values = data.match(_numExp),
|
||||
closest = 1,
|
||||
points = [],
|
||||
lookup = [],
|
||||
precision = config.precision || 1,
|
||||
fast = precision <= 1,
|
||||
l,
|
||||
a1,
|
||||
a2,
|
||||
i,
|
||||
inc,
|
||||
j,
|
||||
point,
|
||||
prevPoint,
|
||||
p;
|
||||
this.data = data;
|
||||
|
||||
if (_needsParsingExp.test(data) || ~data.indexOf("M") && data.indexOf("C") < 0) {
|
||||
values = stringToRawPath(data)[0];
|
||||
}
|
||||
|
||||
l = values.length;
|
||||
|
||||
if (l === 4) {
|
||||
values.unshift(0, 0);
|
||||
values.push(1, 1);
|
||||
l = 8;
|
||||
} else if ((l - 2) % 6) {
|
||||
throw "Invalid CustomEase";
|
||||
}
|
||||
|
||||
if (+values[0] !== 0 || +values[l - 2] !== 1) {
|
||||
_normalize(values, config.height, config.originY);
|
||||
}
|
||||
|
||||
this.segment = values;
|
||||
|
||||
for (i = 2; i < l; i += 6) {
|
||||
a1 = {
|
||||
x: +values[i - 2],
|
||||
y: +values[i - 1]
|
||||
};
|
||||
a2 = {
|
||||
x: +values[i + 4],
|
||||
y: +values[i + 5]
|
||||
};
|
||||
points.push(a1, a2);
|
||||
|
||||
_bezierToPoints(a1.x, a1.y, +values[i], +values[i + 1], +values[i + 2], +values[i + 3], a2.x, a2.y, 1 / (precision * 200000), points, points.length - 1);
|
||||
}
|
||||
|
||||
l = points.length;
|
||||
|
||||
for (i = 0; i < l; i++) {
|
||||
point = points[i];
|
||||
prevPoint = points[i - 1] || point;
|
||||
|
||||
if ((point.x > prevPoint.x || prevPoint.y !== point.y && prevPoint.x === point.x || point === prevPoint) && point.x <= 1) {
|
||||
//if a point goes BACKWARD in time or is a duplicate, just drop it. Also it shouldn't go past 1 on the x axis, as could happen in a string like "M0,0 C0,0 0.12,0.68 0.18,0.788 0.195,0.845 0.308,1 0.32,1 0.403,1.005 0.398,1 0.5,1 0.602,1 0.816,1.005 0.9,1 0.91,1 0.948,0.69 0.962,0.615 1.003,0.376 1,0 1,0".
|
||||
prevPoint.cx = point.x - prevPoint.x; //change in x between this point and the next point (performance optimization)
|
||||
|
||||
prevPoint.cy = point.y - prevPoint.y;
|
||||
prevPoint.n = point;
|
||||
prevPoint.nx = point.x; //next point's x value (performance optimization, making lookups faster in getRatio()). Remember, the lookup will always land on a spot where it's either this point or the very next one (never beyond that)
|
||||
|
||||
if (fast && i > 1 && Math.abs(prevPoint.cy / prevPoint.cx - points[i - 2].cy / points[i - 2].cx) > 2) {
|
||||
//if there's a sudden change in direction, prioritize accuracy over speed. Like a bounce ease - you don't want to risk the sampling chunks landing on each side of the bounce anchor and having it clipped off.
|
||||
fast = 0;
|
||||
}
|
||||
|
||||
if (prevPoint.cx < closest) {
|
||||
if (!prevPoint.cx) {
|
||||
prevPoint.cx = 0.001; //avoids math problems in getRatio() (dividing by zero)
|
||||
|
||||
if (i === l - 1) {
|
||||
//in case the final segment goes vertical RIGHT at the end, make sure we end at the end.
|
||||
prevPoint.x -= 0.001;
|
||||
closest = Math.min(closest, 0.001);
|
||||
fast = 0;
|
||||
}
|
||||
} else {
|
||||
closest = prevPoint.cx;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
points.splice(i--, 1);
|
||||
l--;
|
||||
}
|
||||
}
|
||||
|
||||
l = 1 / closest + 1 | 0;
|
||||
inc = 1 / l;
|
||||
j = 0;
|
||||
point = points[0];
|
||||
|
||||
if (fast) {
|
||||
for (i = 0; i < l; i++) {
|
||||
//for fastest lookups, we just sample along the path at equal x (time) distance. Uses more memory and is slightly less accurate for anchors that don't land on the sampling points, but for the vast majority of eases it's excellent (and fast).
|
||||
p = i * inc;
|
||||
|
||||
if (point.nx < p) {
|
||||
point = points[++j];
|
||||
}
|
||||
|
||||
a1 = point.y + (p - point.x) / point.cx * point.cy;
|
||||
lookup[i] = {
|
||||
x: p,
|
||||
cx: inc,
|
||||
y: a1,
|
||||
cy: 0,
|
||||
nx: 9
|
||||
};
|
||||
|
||||
if (i) {
|
||||
lookup[i - 1].cy = a1 - lookup[i - 1].y;
|
||||
}
|
||||
}
|
||||
|
||||
j = points[points.length - 1];
|
||||
lookup[l - 1].cy = j.y - a1;
|
||||
lookup[l - 1].cx = j.x - lookup[lookup.length - 1].x; //make sure it lands EXACTLY where it should. Otherwise, it might be something like 0.9999999999 instead of 1.
|
||||
} else {
|
||||
//this option is more accurate, ensuring that EVERY anchor is hit perfectly. Clipping across a bounce, for example, would never happen.
|
||||
for (i = 0; i < l; i++) {
|
||||
//build a lookup table based on the smallest distance so that we can instantly find the appropriate point (well, it'll either be that point or the very next one). We'll look up based on the linear progress. So it's it's 0.5 and the lookup table has 100 elements, it'd be like lookup[Math.floor(0.5 * 100)]
|
||||
if (point.nx < i * inc) {
|
||||
point = points[++j];
|
||||
}
|
||||
|
||||
lookup[i] = point;
|
||||
}
|
||||
|
||||
if (j < points.length - 1) {
|
||||
lookup[i - 1] = points[points.length - 2];
|
||||
}
|
||||
} //this._calcEnd = (points[points.length-1].y !== 1 || points[0].y !== 0); //ensures that we don't run into floating point errors. As long as we're starting at 0 and ending at 1, tell GSAP to skip the final calculation and use 0/1 as the factor.
|
||||
|
||||
|
||||
this.ease = function (p) {
|
||||
var point = lookup[p * l | 0] || lookup[l - 1];
|
||||
|
||||
if (point.nx < p) {
|
||||
point = point.n;
|
||||
}
|
||||
|
||||
return point.y + (p - point.x) / point.cx * point.cy;
|
||||
};
|
||||
|
||||
this.ease.custom = this;
|
||||
this.id && gsap && gsap.registerEase(this.id, this.ease);
|
||||
return this;
|
||||
};
|
||||
|
||||
_proto.getSVGData = function getSVGData(config) {
|
||||
return CustomEase.getSVGData(this, config);
|
||||
};
|
||||
|
||||
CustomEase.create = function create(id, data, config) {
|
||||
return new CustomEase(id, data, config).ease;
|
||||
};
|
||||
|
||||
CustomEase.register = function register(core) {
|
||||
gsap = core;
|
||||
|
||||
_initCore();
|
||||
};
|
||||
|
||||
CustomEase.get = function get(id) {
|
||||
return gsap.parseEase(id);
|
||||
};
|
||||
|
||||
CustomEase.getSVGData = function getSVGData(ease, config) {
|
||||
config = config || {};
|
||||
var width = config.width || 100,
|
||||
height = config.height || 100,
|
||||
x = config.x || 0,
|
||||
y = (config.y || 0) + height,
|
||||
e = gsap.utils.toArray(config.path)[0],
|
||||
a,
|
||||
slope,
|
||||
i,
|
||||
inc,
|
||||
tx,
|
||||
ty,
|
||||
precision,
|
||||
threshold,
|
||||
prevX,
|
||||
prevY;
|
||||
|
||||
if (config.invert) {
|
||||
height = -height;
|
||||
y = 0;
|
||||
}
|
||||
|
||||
if (typeof ease === "string") {
|
||||
ease = gsap.parseEase(ease);
|
||||
}
|
||||
|
||||
if (ease.custom) {
|
||||
ease = ease.custom;
|
||||
}
|
||||
|
||||
if (ease instanceof CustomEase) {
|
||||
a = rawPathToString(transformRawPath([ease.segment.slice(0)], width, 0, 0, -height, x, y));
|
||||
} else {
|
||||
a = [x, y];
|
||||
precision = Math.max(5, (config.precision || 1) * 200);
|
||||
inc = 1 / precision;
|
||||
precision += 2;
|
||||
threshold = 5 / precision;
|
||||
prevX = _round(x + inc * width);
|
||||
prevY = _round(y + ease(inc) * -height);
|
||||
slope = (prevY - y) / (prevX - x);
|
||||
|
||||
for (i = 2; i < precision; i++) {
|
||||
tx = _round(x + i * inc * width);
|
||||
ty = _round(y + ease(i * inc) * -height);
|
||||
|
||||
if (Math.abs((ty - prevY) / (tx - prevX) - slope) > threshold || i === precision - 1) {
|
||||
//only add points when the slope changes beyond the threshold
|
||||
a.push(prevX, prevY);
|
||||
slope = (ty - prevY) / (tx - prevX);
|
||||
}
|
||||
|
||||
prevX = tx;
|
||||
prevY = ty;
|
||||
}
|
||||
|
||||
a = "M" + a.join(",");
|
||||
}
|
||||
|
||||
e && e.setAttribute("d", a);
|
||||
return a;
|
||||
};
|
||||
|
||||
return CustomEase;
|
||||
}();
|
||||
CustomEase.version = "3.14.2";
|
||||
CustomEase.headless = true;
|
||||
_getGSAP() && gsap.registerPlugin(CustomEase);
|
||||
export { CustomEase as default };
|
||||
+161
@@ -0,0 +1,161 @@
|
||||
/*!
|
||||
* CustomWiggle 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
|
||||
*/
|
||||
|
||||
/* eslint-disable */
|
||||
var gsap,
|
||||
_coreInitted,
|
||||
createCustomEase,
|
||||
_getGSAP = function _getGSAP() {
|
||||
return gsap || typeof window !== "undefined" && (gsap = window.gsap) && gsap.registerPlugin && gsap;
|
||||
},
|
||||
_eases = {
|
||||
easeOut: "M0,1,C0.7,1,0.6,0,1,0",
|
||||
easeInOut: "M0,0,C0.1,0,0.24,1,0.444,1,0.644,1,0.6,0,1,0",
|
||||
anticipate: "M0,0,C0,0.222,0.024,0.386,0,0.4,0.18,0.455,0.65,0.646,0.7,0.67,0.9,0.76,1,0.846,1,1",
|
||||
uniform: "M0,0,C0,0.95,0,1,0,1,0,1,1,1,1,1,1,1,1,0,1,0"
|
||||
},
|
||||
_linearEase = function _linearEase(p) {
|
||||
return p;
|
||||
},
|
||||
_initCore = function _initCore(required) {
|
||||
if (!_coreInitted) {
|
||||
gsap = _getGSAP();
|
||||
createCustomEase = gsap && gsap.parseEase("_CE");
|
||||
|
||||
if (createCustomEase) {
|
||||
for (var p in _eases) {
|
||||
_eases[p] = createCustomEase("", _eases[p]);
|
||||
}
|
||||
|
||||
_coreInitted = 1;
|
||||
|
||||
_create("wiggle").config = function (vars) {
|
||||
return typeof vars === "object" ? _create("", vars) : _create("wiggle(" + vars + ")", {
|
||||
wiggles: +vars
|
||||
});
|
||||
};
|
||||
} else {
|
||||
required && console.warn("Please gsap.registerPlugin(CustomEase, CustomWiggle)");
|
||||
}
|
||||
}
|
||||
},
|
||||
_parseEase = function _parseEase(ease, invertNonCustomEases) {
|
||||
if (typeof ease !== "function") {
|
||||
ease = gsap.parseEase(ease) || createCustomEase("", ease);
|
||||
}
|
||||
|
||||
return ease.custom || !invertNonCustomEases ? ease : function (p) {
|
||||
return 1 - ease(p);
|
||||
};
|
||||
},
|
||||
_bonusValidated = 1,
|
||||
//<name>CustomWiggle</name>
|
||||
_create = function _create(id, vars) {
|
||||
if (!_coreInitted) {
|
||||
_initCore(1);
|
||||
}
|
||||
|
||||
vars = vars || {};
|
||||
var wiggles = (vars.wiggles || 10) | 0,
|
||||
inc = 1 / wiggles,
|
||||
x = inc / 2,
|
||||
anticipate = vars.type === "anticipate",
|
||||
yEase = _eases[vars.type] || _eases.easeOut,
|
||||
xEase = _linearEase,
|
||||
rnd = 1000,
|
||||
nextX,
|
||||
nextY,
|
||||
angle,
|
||||
handleX,
|
||||
handleY,
|
||||
easedX,
|
||||
y,
|
||||
path,
|
||||
i;
|
||||
|
||||
if (_bonusValidated) {
|
||||
if (anticipate) {
|
||||
//the anticipate ease is actually applied on the x-axis (timing) and uses easeOut for amplitude.
|
||||
xEase = yEase;
|
||||
yEase = _eases.easeOut;
|
||||
}
|
||||
|
||||
if (vars.timingEase) {
|
||||
xEase = _parseEase(vars.timingEase);
|
||||
}
|
||||
|
||||
if (vars.amplitudeEase) {
|
||||
yEase = _parseEase(vars.amplitudeEase, true);
|
||||
}
|
||||
|
||||
easedX = xEase(x);
|
||||
y = anticipate ? -yEase(x) : yEase(x);
|
||||
path = [0, 0, easedX / 4, 0, easedX / 2, y, easedX, y];
|
||||
|
||||
if (vars.type === "random") {
|
||||
//if we just select random values on the y-axis and plug them into the "normal" algorithm, since the control points are always straight horizontal, it creates a bit of a slowdown at each anchor which just didn't seem as desirable, so we switched to an algorithm that bends the control points to be more in line with their context.
|
||||
path.length = 4;
|
||||
nextX = xEase(inc);
|
||||
nextY = Math.random() * 2 - 1;
|
||||
|
||||
for (i = 2; i < wiggles; i++) {
|
||||
x = nextX;
|
||||
y = nextY;
|
||||
nextX = xEase(inc * i);
|
||||
nextY = Math.random() * 2 - 1;
|
||||
angle = Math.atan2(nextY - path[path.length - 3], nextX - path[path.length - 4]);
|
||||
handleX = Math.cos(angle) * inc;
|
||||
handleY = Math.sin(angle) * inc;
|
||||
path.push(x - handleX, y - handleY, x, y, x + handleX, y + handleY);
|
||||
}
|
||||
|
||||
path.push(nextX, 0, 1, 0);
|
||||
} else {
|
||||
for (i = 1; i < wiggles; i++) {
|
||||
path.push(xEase(x + inc / 2), y);
|
||||
x += inc;
|
||||
y = (y > 0 ? -1 : 1) * yEase(i * inc);
|
||||
easedX = xEase(x);
|
||||
path.push(xEase(x - inc / 2), y, easedX, y);
|
||||
}
|
||||
|
||||
path.push(xEase(x + inc / 4), y, xEase(x + inc / 4), 0, 1, 0);
|
||||
}
|
||||
|
||||
i = path.length;
|
||||
|
||||
while (--i > -1) {
|
||||
path[i] = ~~(path[i] * rnd) / rnd; //round values to avoid odd strings for super tiny values
|
||||
}
|
||||
|
||||
path[2] = "C" + path[2];
|
||||
return createCustomEase(id, "M" + path.join(","));
|
||||
}
|
||||
};
|
||||
|
||||
export var CustomWiggle = /*#__PURE__*/function () {
|
||||
function CustomWiggle(id, vars) {
|
||||
this.ease = _create(id, vars);
|
||||
}
|
||||
|
||||
CustomWiggle.create = function create(id, vars) {
|
||||
return _create(id, vars);
|
||||
};
|
||||
|
||||
CustomWiggle.register = function register(core) {
|
||||
gsap = core;
|
||||
|
||||
_initCore();
|
||||
};
|
||||
|
||||
return CustomWiggle;
|
||||
}();
|
||||
_getGSAP() && gsap.registerPlugin(CustomWiggle);
|
||||
CustomWiggle.version = "3.14.2";
|
||||
export { CustomWiggle as default };
|
||||
+2712
File diff suppressed because it is too large.
Load diff
+314
@@ -0,0 +1,314 @@
|
||||
/*!
|
||||
* DrawSVGPlugin 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
|
||||
*/
|
||||
|
||||
/* eslint-disable */
|
||||
var gsap,
|
||||
_toArray,
|
||||
_doc,
|
||||
_win,
|
||||
_isEdge,
|
||||
_coreInitted,
|
||||
_warned,
|
||||
_getStyleSaver,
|
||||
_reverting,
|
||||
_windowExists = function _windowExists() {
|
||||
return typeof window !== "undefined";
|
||||
},
|
||||
_getGSAP = function _getGSAP() {
|
||||
return gsap || _windowExists() && (gsap = window.gsap) && gsap.registerPlugin && gsap;
|
||||
},
|
||||
_numExp = /[-+=\.]*\d+[\.e\-\+]*\d*[e\-\+]*\d*/gi,
|
||||
//finds any numbers, including ones that start with += or -=, negative numbers, and ones in scientific notation like 1e-8.
|
||||
_types = {
|
||||
rect: ["width", "height"],
|
||||
circle: ["r", "r"],
|
||||
ellipse: ["rx", "ry"],
|
||||
line: ["x2", "y2"]
|
||||
},
|
||||
_round = function _round(value) {
|
||||
return Math.round(value * 10000) / 10000;
|
||||
},
|
||||
_parseNum = function _parseNum(value) {
|
||||
return parseFloat(value) || 0;
|
||||
},
|
||||
_parseSingleVal = function _parseSingleVal(value, length) {
|
||||
var num = _parseNum(value);
|
||||
|
||||
return ~value.indexOf("%") ? num / 100 * length : num;
|
||||
},
|
||||
_getAttributeAsNumber = function _getAttributeAsNumber(target, attr) {
|
||||
return _parseNum(target.getAttribute(attr));
|
||||
},
|
||||
_sqrt = Math.sqrt,
|
||||
_getDistance = function _getDistance(x1, y1, x2, y2, scaleX, scaleY) {
|
||||
return _sqrt(Math.pow((_parseNum(x2) - _parseNum(x1)) * scaleX, 2) + Math.pow((_parseNum(y2) - _parseNum(y1)) * scaleY, 2));
|
||||
},
|
||||
_warn = function _warn(message) {
|
||||
return console.warn(message);
|
||||
},
|
||||
_hasNonScalingStroke = function _hasNonScalingStroke(target) {
|
||||
return target.getAttribute("vector-effect") === "non-scaling-stroke";
|
||||
},
|
||||
_bonusValidated = 1,
|
||||
//<name>DrawSVGPlugin</name>
|
||||
//accepts values like "100%" or "20% 80%" or "20 50" and parses it into an absolute start and end position on the line/stroke based on its length. Returns an an array with the start and end values, like [0, 243]
|
||||
_parse = function _parse(value, length, defaultStart) {
|
||||
var i = value.indexOf(" "),
|
||||
s,
|
||||
e;
|
||||
|
||||
if (i < 0) {
|
||||
s = defaultStart !== undefined ? defaultStart + "" : value;
|
||||
e = value;
|
||||
} else {
|
||||
s = value.substr(0, i);
|
||||
e = value.substr(i + 1);
|
||||
}
|
||||
|
||||
s = _parseSingleVal(s, length);
|
||||
e = _parseSingleVal(e, length);
|
||||
return s > e ? [e, s] : [s, e];
|
||||
},
|
||||
_getLength = function _getLength(target) {
|
||||
target = _toArray(target)[0];
|
||||
|
||||
if (!target) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
var type = target.tagName.toLowerCase(),
|
||||
style = target.style,
|
||||
scaleX = 1,
|
||||
scaleY = 1,
|
||||
length,
|
||||
bbox,
|
||||
points,
|
||||
prevPoint,
|
||||
i,
|
||||
rx,
|
||||
ry;
|
||||
|
||||
if (_hasNonScalingStroke(target)) {
|
||||
//non-scaling-stroke basically scales the shape and then strokes it at the screen-level (after transforms), thus we need to adjust the length accordingly.
|
||||
scaleY = target.getScreenCTM();
|
||||
scaleX = _sqrt(scaleY.a * scaleY.a + scaleY.b * scaleY.b);
|
||||
scaleY = _sqrt(scaleY.d * scaleY.d + scaleY.c * scaleY.c);
|
||||
}
|
||||
|
||||
try {
|
||||
//IE bug: calling <path>.getTotalLength() locks the repaint area of the stroke to whatever its current dimensions are on that frame/tick. To work around that, we must call getBBox() to force IE to recalculate things.
|
||||
bbox = target.getBBox(); //solely for fixing bug in IE - we don't actually use the bbox.
|
||||
} catch (e) {
|
||||
//firefox has a bug that throws an error if the element isn't visible.
|
||||
_warn("Some browsers won't measure invisible elements (like display:none or masks inside defs).");
|
||||
}
|
||||
|
||||
var _ref = bbox || {
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: 0,
|
||||
height: 0
|
||||
},
|
||||
x = _ref.x,
|
||||
y = _ref.y,
|
||||
width = _ref.width,
|
||||
height = _ref.height;
|
||||
|
||||
if ((!bbox || !width && !height) && _types[type]) {
|
||||
//if the element isn't visible, try to discern width/height using its attributes.
|
||||
width = _getAttributeAsNumber(target, _types[type][0]);
|
||||
height = _getAttributeAsNumber(target, _types[type][1]);
|
||||
|
||||
if (type !== "rect" && type !== "line") {
|
||||
//double the radius for circles and ellipses
|
||||
width *= 2;
|
||||
height *= 2;
|
||||
}
|
||||
|
||||
if (type === "line") {
|
||||
x = _getAttributeAsNumber(target, "x1");
|
||||
y = _getAttributeAsNumber(target, "y1");
|
||||
width = Math.abs(width - x);
|
||||
height = Math.abs(height - y);
|
||||
}
|
||||
}
|
||||
|
||||
if (type === "path") {
|
||||
prevPoint = style.strokeDasharray;
|
||||
style.strokeDasharray = "none";
|
||||
length = target.getTotalLength() || 0;
|
||||
_round(scaleX) !== _round(scaleY) && !_warned && (_warned = 1) && _warn("Warning: <path> length cannot be measured when vector-effect is non-scaling-stroke and the element isn't proportionally scaled.");
|
||||
length *= (scaleX + scaleY) / 2;
|
||||
style.strokeDasharray = prevPoint;
|
||||
} else if (type === "rect") {
|
||||
length = width * 2 * scaleX + height * 2 * scaleY;
|
||||
} else if (type === "line") {
|
||||
length = _getDistance(x, y, x + width, y + height, scaleX, scaleY);
|
||||
} else if (type === "polyline" || type === "polygon") {
|
||||
points = target.getAttribute("points").match(_numExp) || [];
|
||||
type === "polygon" && points.push(points[0], points[1]);
|
||||
length = 0;
|
||||
|
||||
for (i = 2; i < points.length; i += 2) {
|
||||
length += _getDistance(points[i - 2], points[i - 1], points[i], points[i + 1], scaleX, scaleY) || 0;
|
||||
}
|
||||
} else if (type === "circle" || type === "ellipse") {
|
||||
rx = width / 2 * scaleX;
|
||||
ry = height / 2 * scaleY;
|
||||
length = Math.PI * (3 * (rx + ry) - _sqrt((3 * rx + ry) * (rx + 3 * ry)));
|
||||
}
|
||||
|
||||
return length || 0;
|
||||
},
|
||||
_getPosition = function _getPosition(target, length) {
|
||||
target = _toArray(target)[0];
|
||||
|
||||
if (!target) {
|
||||
return [0, 0];
|
||||
}
|
||||
|
||||
length || (length = _getLength(target) + 1);
|
||||
|
||||
var cs = _win.getComputedStyle(target),
|
||||
dash = cs.strokeDasharray || "",
|
||||
offset = _parseNum(cs.strokeDashoffset),
|
||||
i = dash.indexOf(",");
|
||||
|
||||
i < 0 && (i = dash.indexOf(" "));
|
||||
dash = i < 0 ? length : _parseNum(dash.substr(0, i));
|
||||
dash > length && (dash = length);
|
||||
return [-offset || 0, dash - offset || 0];
|
||||
},
|
||||
_initCore = function _initCore() {
|
||||
if (_windowExists()) {
|
||||
_doc = document;
|
||||
_win = window;
|
||||
_coreInitted = gsap = _getGSAP();
|
||||
_toArray = gsap.utils.toArray;
|
||||
_getStyleSaver = gsap.core.getStyleSaver;
|
||||
|
||||
_reverting = gsap.core.reverting || function () {};
|
||||
|
||||
_isEdge = ((_win.navigator || {}).userAgent || "").indexOf("Edge") !== -1; //Microsoft Edge has a bug that causes it not to redraw the path correctly if the stroke-linecap is anything other than "butt" (like "round") and it doesn't match the stroke-linejoin. A way to trigger it is to change the stroke-miterlimit, so we'll only do that if/when we have to (to maximize performance)
|
||||
}
|
||||
};
|
||||
|
||||
export var DrawSVGPlugin = {
|
||||
version: "3.14.2",
|
||||
name: "drawSVG",
|
||||
register: function register(core) {
|
||||
gsap = core;
|
||||
|
||||
_initCore();
|
||||
},
|
||||
init: function init(target, value, tween, index, targets) {
|
||||
if (!target.getBBox) {
|
||||
return false;
|
||||
}
|
||||
|
||||
_coreInitted || _initCore();
|
||||
|
||||
var length = _getLength(target),
|
||||
start,
|
||||
end,
|
||||
cs;
|
||||
|
||||
this.styles = _getStyleSaver && _getStyleSaver(target, "strokeDashoffset,strokeDasharray,strokeMiterlimit");
|
||||
this.tween = tween;
|
||||
this._style = target.style;
|
||||
this._target = target;
|
||||
|
||||
if (value + "" === "true") {
|
||||
value = "0 100%";
|
||||
} else if (!value) {
|
||||
value = "0 0";
|
||||
} else if ((value + "").indexOf(" ") === -1) {
|
||||
value = "0 " + value;
|
||||
}
|
||||
|
||||
start = _getPosition(target, length);
|
||||
end = _parse(value, length, start[0]);
|
||||
this._length = _round(length);
|
||||
this._dash = _round(start[1] - start[0]); //some browsers render artifacts if dash is 0, so we use a very small number in that case.
|
||||
|
||||
this._offset = _round(-start[0]);
|
||||
this._dashPT = this.add(this, "_dash", this._dash, _round(end[1] - end[0]), 0, 0, 0, 0, 0, 1);
|
||||
this._offsetPT = this.add(this, "_offset", this._offset, _round(-end[0]), 0, 0, 0, 0, 0, 1);
|
||||
|
||||
if (_isEdge) {
|
||||
//to work around a bug in Microsoft Edge, animate the stroke-miterlimit by 0.0001 just to trigger the repaint (unnecessary if it's "round" and stroke-linejoin is also "round"). Imperceptible, relatively high-performance, and effective. Another option was to set the "d" <path> attribute to its current value on every tick, but that seems like it'd be much less performant.
|
||||
cs = _win.getComputedStyle(target);
|
||||
|
||||
if (cs.strokeLinecap !== cs.strokeLinejoin) {
|
||||
end = _parseNum(cs.strokeMiterlimit);
|
||||
this.add(target.style, "strokeMiterlimit", end, end + 0.01);
|
||||
}
|
||||
}
|
||||
|
||||
this._live = _hasNonScalingStroke(target) || ~(value + "").indexOf("live");
|
||||
this._nowrap = ~(value + "").indexOf("nowrap");
|
||||
|
||||
this._props.push("drawSVG");
|
||||
|
||||
return _bonusValidated;
|
||||
},
|
||||
render: function render(ratio, data) {
|
||||
if (data.tween._time || !_reverting()) {
|
||||
var pt = data._pt,
|
||||
style = data._style,
|
||||
length,
|
||||
lengthRatio,
|
||||
dash,
|
||||
offset;
|
||||
|
||||
if (pt) {
|
||||
//when the element has vector-effect="non-scaling-stroke" and the SVG is resized (like on a window resize), it actually changes the length of the stroke! So we must sense that and make the proper adjustments.
|
||||
if (data._live) {
|
||||
length = _getLength(data._target);
|
||||
|
||||
if (length !== data._length) {
|
||||
lengthRatio = length / data._length;
|
||||
data._length = length;
|
||||
|
||||
if (data._offsetPT) {
|
||||
data._offsetPT.s *= lengthRatio;
|
||||
data._offsetPT.c *= lengthRatio;
|
||||
}
|
||||
|
||||
if (data._dashPT) {
|
||||
data._dashPT.s *= lengthRatio;
|
||||
data._dashPT.c *= lengthRatio;
|
||||
} else {
|
||||
data._dash *= lengthRatio;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (pt) {
|
||||
pt.r(ratio, pt.d);
|
||||
pt = pt._next;
|
||||
}
|
||||
|
||||
dash = data._dash || ratio && ratio !== 1 && 0.0001 || 0; // only let it be zero if it's at the start or end of the tween.
|
||||
|
||||
length = data._length - dash + 0.1;
|
||||
offset = data._offset;
|
||||
dash && offset && dash + Math.abs(offset % data._length) > data._length - 0.05 && (offset += offset < 0 ? 0.005 : -0.005) && (length += 0.005);
|
||||
style.strokeDashoffset = dash ? offset : offset + 0.001;
|
||||
style.strokeDasharray = length < 0.1 ? "none" : dash ? dash + "px," + (data._nowrap ? 999999 : length) + "px" : "0px, 999999px";
|
||||
}
|
||||
} else {
|
||||
data.styles.revert();
|
||||
}
|
||||
},
|
||||
getLength: _getLength,
|
||||
getPosition: _getPosition
|
||||
};
|
||||
_getGSAP() && gsap.registerPlugin(DrawSVGPlugin);
|
||||
export { DrawSVGPlugin as default };
|
||||
+211
@@ -0,0 +1,211 @@
|
||||
/*!
|
||||
* EasePack 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
|
||||
*/
|
||||
|
||||
/* eslint-disable */
|
||||
var gsap,
|
||||
_coreInitted,
|
||||
_registerEase,
|
||||
_getGSAP = function _getGSAP() {
|
||||
return gsap || typeof window !== "undefined" && (gsap = window.gsap) && gsap.registerPlugin && gsap;
|
||||
},
|
||||
_boolean = function _boolean(value, defaultValue) {
|
||||
return !!(typeof value === "undefined" ? defaultValue : value && !~(value + "").indexOf("false"));
|
||||
},
|
||||
_initCore = function _initCore(core) {
|
||||
gsap = core || _getGSAP();
|
||||
|
||||
if (gsap) {
|
||||
_registerEase = gsap.registerEase; //add weighted ease capabilities to standard eases so users can do "power2.inOut(0.8)" for example to push everything toward the "out", or (-0.8) to push it toward the "in" (0 is neutral)
|
||||
|
||||
var eases = gsap.parseEase(),
|
||||
createConfig = function createConfig(ease) {
|
||||
return function (ratio) {
|
||||
var y = 0.5 + ratio / 2;
|
||||
|
||||
ease.config = function (p) {
|
||||
return ease(2 * (1 - p) * p * y + p * p);
|
||||
};
|
||||
};
|
||||
},
|
||||
p;
|
||||
|
||||
for (p in eases) {
|
||||
if (!eases[p].config) {
|
||||
createConfig(eases[p]);
|
||||
}
|
||||
}
|
||||
|
||||
_registerEase("slow", SlowMo);
|
||||
|
||||
_registerEase("expoScale", ExpoScaleEase);
|
||||
|
||||
_registerEase("rough", RoughEase);
|
||||
|
||||
for (p in EasePack) {
|
||||
p !== "version" && gsap.core.globals(p, EasePack[p]);
|
||||
}
|
||||
|
||||
_coreInitted = 1;
|
||||
}
|
||||
},
|
||||
_createSlowMo = function _createSlowMo(linearRatio, power, yoyoMode) {
|
||||
linearRatio = Math.min(1, linearRatio || 0.7);
|
||||
|
||||
var pow = linearRatio < 1 ? power || power === 0 ? power : 0.7 : 0,
|
||||
p1 = (1 - linearRatio) / 2,
|
||||
p3 = p1 + linearRatio,
|
||||
calcEnd = _boolean(yoyoMode);
|
||||
|
||||
return function (p) {
|
||||
var r = p + (0.5 - p) * pow;
|
||||
return p < p1 ? calcEnd ? 1 - (p = 1 - p / p1) * p : r - (p = 1 - p / p1) * p * p * p * r : p > p3 ? calcEnd ? p === 1 ? 0 : 1 - (p = (p - p3) / p1) * p : r + (p - r) * (p = (p - p3) / p1) * p * p * p : calcEnd ? 1 : r;
|
||||
};
|
||||
},
|
||||
_createExpoScale = function _createExpoScale(start, end, ease) {
|
||||
var p1 = Math.log(end / start),
|
||||
p2 = end - start;
|
||||
ease && (ease = gsap.parseEase(ease));
|
||||
return function (p) {
|
||||
return (start * Math.exp(p1 * (ease ? ease(p) : p)) - start) / p2;
|
||||
};
|
||||
},
|
||||
EasePoint = function EasePoint(time, value, next) {
|
||||
this.t = time;
|
||||
this.v = value;
|
||||
|
||||
if (next) {
|
||||
this.next = next;
|
||||
next.prev = this;
|
||||
this.c = next.v - value;
|
||||
this.gap = next.t - time;
|
||||
}
|
||||
},
|
||||
_createRoughEase = function _createRoughEase(vars) {
|
||||
if (typeof vars !== "object") {
|
||||
//users may pass in via a string, like "rough(30)"
|
||||
vars = {
|
||||
points: +vars || 20
|
||||
};
|
||||
}
|
||||
|
||||
var taper = vars.taper || "none",
|
||||
a = [],
|
||||
cnt = 0,
|
||||
points = (+vars.points || 20) | 0,
|
||||
i = points,
|
||||
randomize = _boolean(vars.randomize, true),
|
||||
clamp = _boolean(vars.clamp),
|
||||
template = gsap ? gsap.parseEase(vars.template) : 0,
|
||||
strength = (+vars.strength || 1) * 0.4,
|
||||
x,
|
||||
y,
|
||||
bump,
|
||||
invX,
|
||||
obj,
|
||||
pnt,
|
||||
recent;
|
||||
|
||||
while (--i > -1) {
|
||||
x = randomize ? Math.random() : 1 / points * i;
|
||||
y = template ? template(x) : x;
|
||||
|
||||
if (taper === "none") {
|
||||
bump = strength;
|
||||
} else if (taper === "out") {
|
||||
invX = 1 - x;
|
||||
bump = invX * invX * strength;
|
||||
} else if (taper === "in") {
|
||||
bump = x * x * strength;
|
||||
} else if (x < 0.5) {
|
||||
//"both" (start)
|
||||
invX = x * 2;
|
||||
bump = invX * invX * 0.5 * strength;
|
||||
} else {
|
||||
//"both" (end)
|
||||
invX = (1 - x) * 2;
|
||||
bump = invX * invX * 0.5 * strength;
|
||||
}
|
||||
|
||||
if (randomize) {
|
||||
y += Math.random() * bump - bump * 0.5;
|
||||
} else if (i % 2) {
|
||||
y += bump * 0.5;
|
||||
} else {
|
||||
y -= bump * 0.5;
|
||||
}
|
||||
|
||||
if (clamp) {
|
||||
if (y > 1) {
|
||||
y = 1;
|
||||
} else if (y < 0) {
|
||||
y = 0;
|
||||
}
|
||||
}
|
||||
|
||||
a[cnt++] = {
|
||||
x: x,
|
||||
y: y
|
||||
};
|
||||
}
|
||||
|
||||
a.sort(function (a, b) {
|
||||
return a.x - b.x;
|
||||
});
|
||||
pnt = new EasePoint(1, 1, null);
|
||||
i = points;
|
||||
|
||||
while (i--) {
|
||||
obj = a[i];
|
||||
pnt = new EasePoint(obj.x, obj.y, pnt);
|
||||
}
|
||||
|
||||
recent = new EasePoint(0, 0, pnt.t ? pnt : pnt.next);
|
||||
return function (p) {
|
||||
var pnt = recent;
|
||||
|
||||
if (p > pnt.t) {
|
||||
while (pnt.next && p >= pnt.t) {
|
||||
pnt = pnt.next;
|
||||
}
|
||||
|
||||
pnt = pnt.prev;
|
||||
} else {
|
||||
while (pnt.prev && p <= pnt.t) {
|
||||
pnt = pnt.prev;
|
||||
}
|
||||
}
|
||||
|
||||
recent = pnt;
|
||||
return pnt.v + (p - pnt.t) / pnt.gap * pnt.c;
|
||||
};
|
||||
};
|
||||
|
||||
export var SlowMo = _createSlowMo(0.7);
|
||||
SlowMo.ease = SlowMo; //for backward compatibility
|
||||
|
||||
SlowMo.config = _createSlowMo;
|
||||
export var ExpoScaleEase = _createExpoScale(1, 2);
|
||||
ExpoScaleEase.config = _createExpoScale;
|
||||
export var RoughEase = _createRoughEase();
|
||||
RoughEase.ease = RoughEase; //for backward compatibility
|
||||
|
||||
RoughEase.config = _createRoughEase;
|
||||
export var EasePack = {
|
||||
SlowMo: SlowMo,
|
||||
RoughEase: RoughEase,
|
||||
ExpoScaleEase: ExpoScaleEase
|
||||
};
|
||||
|
||||
for (var p in EasePack) {
|
||||
EasePack[p].register = _initCore;
|
||||
EasePack[p].version = "3.14.2";
|
||||
}
|
||||
|
||||
_getGSAP() && gsap.registerPlugin(SlowMo);
|
||||
export { EasePack as default };
|
||||
+340
@@ -0,0 +1,340 @@
|
||||
/*!
|
||||
* EaselPlugin 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
|
||||
*/
|
||||
|
||||
/* eslint-disable */
|
||||
var gsap,
|
||||
_coreInitted,
|
||||
_win,
|
||||
_createJS,
|
||||
_ColorFilter,
|
||||
_ColorMatrixFilter,
|
||||
_colorProps = "redMultiplier,greenMultiplier,blueMultiplier,alphaMultiplier,redOffset,greenOffset,blueOffset,alphaOffset".split(","),
|
||||
_windowExists = function _windowExists() {
|
||||
return typeof window !== "undefined";
|
||||
},
|
||||
_getGSAP = function _getGSAP() {
|
||||
return gsap || _windowExists() && (gsap = window.gsap) && gsap.registerPlugin && gsap;
|
||||
},
|
||||
_getCreateJS = function _getCreateJS() {
|
||||
return _createJS || _win && _win.createjs || _win || {};
|
||||
},
|
||||
_warn = function _warn(message) {
|
||||
return console.warn(message);
|
||||
},
|
||||
_cache = function _cache(target) {
|
||||
var b = target.getBounds && target.getBounds();
|
||||
|
||||
if (!b) {
|
||||
b = target.nominalBounds || {
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: 100,
|
||||
height: 100
|
||||
};
|
||||
target.setBounds && target.setBounds(b.x, b.y, b.width, b.height);
|
||||
}
|
||||
|
||||
target.cache && target.cache(b.x, b.y, b.width, b.height);
|
||||
|
||||
_warn("EaselPlugin: for filters to display in EaselJS, you must call the object's cache() method first. GSAP attempted to use the target's getBounds() for the cache but that may not be completely accurate. " + target);
|
||||
},
|
||||
_parseColorFilter = function _parseColorFilter(target, v, plugin) {
|
||||
if (!_ColorFilter) {
|
||||
_ColorFilter = _getCreateJS().ColorFilter;
|
||||
|
||||
if (!_ColorFilter) {
|
||||
_warn("EaselPlugin error: The EaselJS ColorFilter JavaScript file wasn't loaded.");
|
||||
}
|
||||
}
|
||||
|
||||
var filters = target.filters || [],
|
||||
i = filters.length,
|
||||
c,
|
||||
s,
|
||||
e,
|
||||
a,
|
||||
p,
|
||||
pt;
|
||||
|
||||
while (i--) {
|
||||
if (filters[i] instanceof _ColorFilter) {
|
||||
s = filters[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!s) {
|
||||
s = new _ColorFilter();
|
||||
filters.push(s);
|
||||
target.filters = filters;
|
||||
}
|
||||
|
||||
e = s.clone();
|
||||
|
||||
if (v.tint != null) {
|
||||
c = gsap.utils.splitColor(v.tint);
|
||||
a = v.tintAmount != null ? +v.tintAmount : 1;
|
||||
e.redOffset = +c[0] * a;
|
||||
e.greenOffset = +c[1] * a;
|
||||
e.blueOffset = +c[2] * a;
|
||||
e.redMultiplier = e.greenMultiplier = e.blueMultiplier = 1 - a;
|
||||
} else {
|
||||
for (p in v) {
|
||||
if (p !== "exposure") if (p !== "brightness") {
|
||||
e[p] = +v[p];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (v.exposure != null) {
|
||||
e.redOffset = e.greenOffset = e.blueOffset = 255 * (+v.exposure - 1);
|
||||
e.redMultiplier = e.greenMultiplier = e.blueMultiplier = 1;
|
||||
} else if (v.brightness != null) {
|
||||
a = +v.brightness - 1;
|
||||
e.redOffset = e.greenOffset = e.blueOffset = a > 0 ? a * 255 : 0;
|
||||
e.redMultiplier = e.greenMultiplier = e.blueMultiplier = 1 - Math.abs(a);
|
||||
}
|
||||
|
||||
i = 8;
|
||||
|
||||
while (i--) {
|
||||
p = _colorProps[i];
|
||||
|
||||
if (s[p] !== e[p]) {
|
||||
pt = plugin.add(s, p, s[p], e[p], 0, 0, 0, 0, 0, 1);
|
||||
|
||||
if (pt) {
|
||||
pt.op = "easel_colorFilter";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
plugin._props.push("easel_colorFilter");
|
||||
|
||||
if (!target.cacheID) {
|
||||
_cache(target);
|
||||
}
|
||||
},
|
||||
_idMatrix = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0],
|
||||
_lumR = 0.212671,
|
||||
_lumG = 0.715160,
|
||||
_lumB = 0.072169,
|
||||
_applyMatrix = function _applyMatrix(m, m2) {
|
||||
if (!(m instanceof Array) || !(m2 instanceof Array)) {
|
||||
return m2;
|
||||
}
|
||||
|
||||
var temp = [],
|
||||
i = 0,
|
||||
z = 0,
|
||||
y,
|
||||
x;
|
||||
|
||||
for (y = 0; y < 4; y++) {
|
||||
for (x = 0; x < 5; x++) {
|
||||
z = x === 4 ? m[i + 4] : 0;
|
||||
temp[i + x] = m[i] * m2[x] + m[i + 1] * m2[x + 5] + m[i + 2] * m2[x + 10] + m[i + 3] * m2[x + 15] + z;
|
||||
}
|
||||
|
||||
i += 5;
|
||||
}
|
||||
|
||||
return temp;
|
||||
},
|
||||
_setSaturation = function _setSaturation(m, n) {
|
||||
if (isNaN(n)) {
|
||||
return m;
|
||||
}
|
||||
|
||||
var inv = 1 - n,
|
||||
r = inv * _lumR,
|
||||
g = inv * _lumG,
|
||||
b = inv * _lumB;
|
||||
return _applyMatrix([r + n, g, b, 0, 0, r, g + n, b, 0, 0, r, g, b + n, 0, 0, 0, 0, 0, 1, 0], m);
|
||||
},
|
||||
_colorize = function _colorize(m, color, amount) {
|
||||
if (isNaN(amount)) {
|
||||
amount = 1;
|
||||
}
|
||||
|
||||
var c = gsap.utils.splitColor(color),
|
||||
r = c[0] / 255,
|
||||
g = c[1] / 255,
|
||||
b = c[2] / 255,
|
||||
inv = 1 - amount;
|
||||
return _applyMatrix([inv + amount * r * _lumR, amount * r * _lumG, amount * r * _lumB, 0, 0, amount * g * _lumR, inv + amount * g * _lumG, amount * g * _lumB, 0, 0, amount * b * _lumR, amount * b * _lumG, inv + amount * b * _lumB, 0, 0, 0, 0, 0, 1, 0], m);
|
||||
},
|
||||
_setHue = function _setHue(m, n) {
|
||||
if (isNaN(n)) {
|
||||
return m;
|
||||
}
|
||||
|
||||
n *= Math.PI / 180;
|
||||
var c = Math.cos(n),
|
||||
s = Math.sin(n);
|
||||
return _applyMatrix([_lumR + c * (1 - _lumR) + s * -_lumR, _lumG + c * -_lumG + s * -_lumG, _lumB + c * -_lumB + s * (1 - _lumB), 0, 0, _lumR + c * -_lumR + s * 0.143, _lumG + c * (1 - _lumG) + s * 0.14, _lumB + c * -_lumB + s * -0.283, 0, 0, _lumR + c * -_lumR + s * -(1 - _lumR), _lumG + c * -_lumG + s * _lumG, _lumB + c * (1 - _lumB) + s * _lumB, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1], m);
|
||||
},
|
||||
_setContrast = function _setContrast(m, n) {
|
||||
if (isNaN(n)) {
|
||||
return m;
|
||||
}
|
||||
|
||||
n += 0.01;
|
||||
return _applyMatrix([n, 0, 0, 0, 128 * (1 - n), 0, n, 0, 0, 128 * (1 - n), 0, 0, n, 0, 128 * (1 - n), 0, 0, 0, 1, 0], m);
|
||||
},
|
||||
_parseColorMatrixFilter = function _parseColorMatrixFilter(target, v, plugin) {
|
||||
if (!_ColorMatrixFilter) {
|
||||
_ColorMatrixFilter = _getCreateJS().ColorMatrixFilter;
|
||||
|
||||
if (!_ColorMatrixFilter) {
|
||||
_warn("EaselPlugin: The EaselJS ColorMatrixFilter JavaScript file wasn't loaded.");
|
||||
}
|
||||
}
|
||||
|
||||
var filters = target.filters || [],
|
||||
i = filters.length,
|
||||
matrix,
|
||||
startMatrix,
|
||||
s,
|
||||
pg;
|
||||
|
||||
while (--i > -1) {
|
||||
if (filters[i] instanceof _ColorMatrixFilter) {
|
||||
s = filters[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!s) {
|
||||
s = new _ColorMatrixFilter(_idMatrix.slice());
|
||||
filters.push(s);
|
||||
target.filters = filters;
|
||||
}
|
||||
|
||||
startMatrix = s.matrix;
|
||||
matrix = _idMatrix.slice();
|
||||
|
||||
if (v.colorize != null) {
|
||||
matrix = _colorize(matrix, v.colorize, Number(v.colorizeAmount));
|
||||
}
|
||||
|
||||
if (v.contrast != null) {
|
||||
matrix = _setContrast(matrix, Number(v.contrast));
|
||||
}
|
||||
|
||||
if (v.hue != null) {
|
||||
matrix = _setHue(matrix, Number(v.hue));
|
||||
}
|
||||
|
||||
if (v.saturation != null) {
|
||||
matrix = _setSaturation(matrix, Number(v.saturation));
|
||||
}
|
||||
|
||||
i = matrix.length;
|
||||
|
||||
while (--i > -1) {
|
||||
if (matrix[i] !== startMatrix[i]) {
|
||||
pg = plugin.add(startMatrix, i, startMatrix[i], matrix[i], 0, 0, 0, 0, 0, 1);
|
||||
|
||||
if (pg) {
|
||||
pg.op = "easel_colorMatrixFilter";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
plugin._props.push("easel_colorMatrixFilter");
|
||||
|
||||
if (!target.cacheID) {
|
||||
_cache();
|
||||
}
|
||||
|
||||
plugin._matrix = startMatrix;
|
||||
},
|
||||
_initCore = function _initCore(core) {
|
||||
gsap = core || _getGSAP();
|
||||
|
||||
if (_windowExists()) {
|
||||
_win = window;
|
||||
}
|
||||
|
||||
if (gsap) {
|
||||
_coreInitted = 1;
|
||||
}
|
||||
};
|
||||
|
||||
export var EaselPlugin = {
|
||||
version: "3.14.2",
|
||||
name: "easel",
|
||||
init: function init(target, value, tween, index, targets) {
|
||||
if (!_coreInitted) {
|
||||
_initCore();
|
||||
|
||||
if (!gsap) {
|
||||
_warn("Please gsap.registerPlugin(EaselPlugin)");
|
||||
}
|
||||
}
|
||||
|
||||
this.target = target;
|
||||
var p, pt, tint, colorMatrix, end, labels, i;
|
||||
|
||||
for (p in value) {
|
||||
end = value[p];
|
||||
|
||||
if (p === "colorFilter" || p === "tint" || p === "tintAmount" || p === "exposure" || p === "brightness") {
|
||||
if (!tint) {
|
||||
_parseColorFilter(target, value.colorFilter || value, this);
|
||||
|
||||
tint = true;
|
||||
}
|
||||
} else if (p === "saturation" || p === "contrast" || p === "hue" || p === "colorize" || p === "colorizeAmount") {
|
||||
if (!colorMatrix) {
|
||||
_parseColorMatrixFilter(target, value.colorMatrixFilter || value, this);
|
||||
|
||||
colorMatrix = true;
|
||||
}
|
||||
} else if (p === "frame") {
|
||||
if (typeof end === "string" && end.charAt(1) !== "=" && (labels = target.labels)) {
|
||||
for (i = 0; i < labels.length; i++) {
|
||||
if (labels[i].label === end) {
|
||||
end = labels[i].position;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pt = this.add(target, "gotoAndStop", target.currentFrame, end, index, targets, Math.round, 0, 0, 1);
|
||||
|
||||
if (pt) {
|
||||
pt.op = p;
|
||||
}
|
||||
} else if (target[p] != null) {
|
||||
this.add(target, p, "get", end);
|
||||
}
|
||||
}
|
||||
},
|
||||
render: function render(ratio, data) {
|
||||
var pt = data._pt;
|
||||
|
||||
while (pt) {
|
||||
pt.r(ratio, pt.d);
|
||||
pt = pt._next;
|
||||
}
|
||||
|
||||
if (data.target.cacheID) {
|
||||
data.target.updateCache();
|
||||
}
|
||||
},
|
||||
register: _initCore
|
||||
};
|
||||
|
||||
EaselPlugin.registerCreateJS = function (createjs) {
|
||||
_createJS = createjs;
|
||||
};
|
||||
|
||||
_getGSAP() && gsap.registerPlugin(EaselPlugin);
|
||||
export { EaselPlugin as default };
|
||||
+1562
File diff suppressed because it is too large.
Load diff
+1573
File diff suppressed because it is too large.
Load diff
+478
@@ -0,0 +1,478 @@
|
||||
/*!
|
||||
* InertiaPlugin 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
|
||||
*/
|
||||
|
||||
/* eslint-disable */
|
||||
import { VelocityTracker } from "./utils/VelocityTracker.js";
|
||||
|
||||
var gsap,
|
||||
_coreInitted,
|
||||
_parseEase,
|
||||
_toArray,
|
||||
_power3,
|
||||
_config,
|
||||
_getUnit,
|
||||
PropTween,
|
||||
_getCache,
|
||||
_checkPointRatio,
|
||||
_clamp,
|
||||
_processingVars,
|
||||
_getStyleSaver,
|
||||
_reverting,
|
||||
_getTracker = VelocityTracker.getByTarget,
|
||||
_getGSAP = function _getGSAP() {
|
||||
return gsap || typeof window !== "undefined" && (gsap = window.gsap) && gsap.registerPlugin && gsap;
|
||||
},
|
||||
_isString = function _isString(value) {
|
||||
return typeof value === "string";
|
||||
},
|
||||
_isNumber = function _isNumber(value) {
|
||||
return typeof value === "number";
|
||||
},
|
||||
_isObject = function _isObject(value) {
|
||||
return typeof value === "object";
|
||||
},
|
||||
_isFunction = function _isFunction(value) {
|
||||
return typeof value === "function";
|
||||
},
|
||||
_bonusValidated = 1,
|
||||
//<name>InertiaPlugin</name>
|
||||
_isArray = Array.isArray,
|
||||
_emptyFunc = function _emptyFunc(p) {
|
||||
return p;
|
||||
},
|
||||
_bigNum = 1e10,
|
||||
_tinyNum = 1 / _bigNum,
|
||||
_checkPoint = 0.05,
|
||||
_round = function _round(value) {
|
||||
return Math.round(value * 10000) / 10000;
|
||||
},
|
||||
_extend = function _extend(obj, defaults, exclude) {
|
||||
for (var p in defaults) {
|
||||
if (!(p in obj) && p !== exclude) {
|
||||
obj[p] = defaults[p];
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
},
|
||||
_deepClone = function _deepClone(obj) {
|
||||
var copy = {},
|
||||
p,
|
||||
v;
|
||||
|
||||
for (p in obj) {
|
||||
copy[p] = _isObject(v = obj[p]) && !_isArray(v) ? _deepClone(v) : v;
|
||||
}
|
||||
|
||||
return copy;
|
||||
},
|
||||
_getClosest = function _getClosest(n, values, max, min, radius) {
|
||||
var i = values.length,
|
||||
closest = 0,
|
||||
absDif = _bigNum,
|
||||
val,
|
||||
dif,
|
||||
p,
|
||||
dist;
|
||||
|
||||
if (_isObject(n)) {
|
||||
while (i--) {
|
||||
val = values[i];
|
||||
dif = 0;
|
||||
|
||||
for (p in n) {
|
||||
dist = val[p] - n[p];
|
||||
dif += dist * dist;
|
||||
}
|
||||
|
||||
if (dif < absDif) {
|
||||
closest = i;
|
||||
absDif = dif;
|
||||
}
|
||||
}
|
||||
|
||||
if ((radius || _bigNum) < _bigNum && radius < Math.sqrt(absDif)) {
|
||||
return n;
|
||||
}
|
||||
} else {
|
||||
while (i--) {
|
||||
val = values[i];
|
||||
dif = val - n;
|
||||
|
||||
if (dif < 0) {
|
||||
dif = -dif;
|
||||
}
|
||||
|
||||
if (dif < absDif && val >= min && val <= max) {
|
||||
closest = i;
|
||||
absDif = dif;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return values[closest];
|
||||
},
|
||||
_parseEnd = function _parseEnd(curProp, end, max, min, name, radius, velocity) {
|
||||
if (curProp.end === "auto") {
|
||||
return curProp;
|
||||
}
|
||||
|
||||
var endVar = curProp.end,
|
||||
adjustedEnd,
|
||||
p;
|
||||
max = isNaN(max) ? _bigNum : max;
|
||||
min = isNaN(min) ? -_bigNum : min;
|
||||
|
||||
if (_isObject(end)) {
|
||||
//for objects, like {x, y} where they're linked and we must pass an object to the function or find the closest value in an array.
|
||||
adjustedEnd = end.calculated ? end : (_isFunction(endVar) ? endVar(end, velocity) : _getClosest(end, endVar, max, min, radius)) || end;
|
||||
|
||||
if (!end.calculated) {
|
||||
for (p in adjustedEnd) {
|
||||
end[p] = adjustedEnd[p];
|
||||
}
|
||||
|
||||
end.calculated = true;
|
||||
}
|
||||
|
||||
adjustedEnd = adjustedEnd[name];
|
||||
} else {
|
||||
adjustedEnd = _isFunction(endVar) ? endVar(end, velocity) : _isArray(endVar) ? _getClosest(end, endVar, max, min, radius) : parseFloat(endVar);
|
||||
}
|
||||
|
||||
if (adjustedEnd > max) {
|
||||
adjustedEnd = max;
|
||||
} else if (adjustedEnd < min) {
|
||||
adjustedEnd = min;
|
||||
}
|
||||
|
||||
return {
|
||||
max: adjustedEnd,
|
||||
min: adjustedEnd,
|
||||
unitFactor: curProp.unitFactor
|
||||
};
|
||||
},
|
||||
_getNumOrDefault = function _getNumOrDefault(vars, property, defaultValue) {
|
||||
return isNaN(vars[property]) ? defaultValue : +vars[property];
|
||||
},
|
||||
_calculateChange = function _calculateChange(velocity, duration) {
|
||||
return duration * _checkPoint * velocity / _checkPointRatio;
|
||||
},
|
||||
_calculateDuration = function _calculateDuration(start, end, velocity) {
|
||||
return Math.abs((end - start) * _checkPointRatio / velocity / _checkPoint);
|
||||
},
|
||||
_reservedProps = {
|
||||
resistance: 1,
|
||||
checkpoint: 1,
|
||||
preventOvershoot: 1,
|
||||
linkedProps: 1,
|
||||
radius: 1,
|
||||
duration: 1
|
||||
},
|
||||
_processLinkedProps = function _processLinkedProps(target, vars, getVal, resistance) {
|
||||
if (vars.linkedProps) {
|
||||
//when there are linkedProps (typically "x,y" where snapping has to factor in multiple properties, we must first populate an object with all of those end values, then feed it to the function that make any necessary alterations. So the point of this first loop is to simply build an object (like {x:100, y:204.5}) for feeding into that function which we'll do later in the "real" loop.
|
||||
var linkedPropNames = vars.linkedProps.split(","),
|
||||
linkedProps = {},
|
||||
i,
|
||||
p,
|
||||
curProp,
|
||||
curVelocity,
|
||||
tracker,
|
||||
curDuration;
|
||||
|
||||
for (i = 0; i < linkedPropNames.length; i++) {
|
||||
p = linkedPropNames[i];
|
||||
curProp = vars[p];
|
||||
|
||||
if (curProp) {
|
||||
if (_isNumber(curProp.velocity)) {
|
||||
curVelocity = curProp.velocity;
|
||||
} else {
|
||||
tracker = tracker || _getTracker(target);
|
||||
curVelocity = tracker && tracker.isTracking(p) ? tracker.get(p) : 0;
|
||||
}
|
||||
|
||||
curDuration = Math.abs(curVelocity / _getNumOrDefault(curProp, "resistance", resistance));
|
||||
linkedProps[p] = parseFloat(getVal(target, p)) + _calculateChange(curVelocity, curDuration);
|
||||
}
|
||||
}
|
||||
|
||||
return linkedProps;
|
||||
}
|
||||
},
|
||||
_calculateTweenDuration = function _calculateTweenDuration(target, vars, maxDuration, minDuration, overshootTolerance, recordEnd) {
|
||||
if (maxDuration === void 0) {
|
||||
maxDuration = 10;
|
||||
}
|
||||
|
||||
if (minDuration === void 0) {
|
||||
minDuration = 0.2;
|
||||
}
|
||||
|
||||
if (overshootTolerance === void 0) {
|
||||
overshootTolerance = 1;
|
||||
}
|
||||
|
||||
if (recordEnd === void 0) {
|
||||
recordEnd = 0;
|
||||
}
|
||||
|
||||
_isString(target) && (target = _toArray(target)[0]);
|
||||
|
||||
if (!target) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
var duration = 0,
|
||||
clippedDuration = _bigNum,
|
||||
inertiaVars = vars.inertia || vars,
|
||||
getVal = _getCache(target).get,
|
||||
resistance = _getNumOrDefault(inertiaVars, "resistance", _config.resistance),
|
||||
p,
|
||||
curProp,
|
||||
curDuration,
|
||||
curVelocity,
|
||||
curVal,
|
||||
end,
|
||||
curClippedDuration,
|
||||
tracker,
|
||||
unitFactor,
|
||||
linkedProps; //when there are linkedProps (typically "x,y" where snapping has to factor in multiple properties, we must first populate an object with all of those end values, then feed it to the function that make any necessary alterations. So the point of this first loop is to simply build an object (like {x:100, y:204.5}) for feeding into that function which we'll do later in the "real" loop.
|
||||
|
||||
|
||||
linkedProps = _processLinkedProps(target, inertiaVars, getVal, resistance);
|
||||
|
||||
for (p in inertiaVars) {
|
||||
if (!_reservedProps[p]) {
|
||||
curProp = inertiaVars[p];
|
||||
|
||||
if (!_isObject(curProp)) {
|
||||
tracker = tracker || _getTracker(target);
|
||||
|
||||
if (tracker && tracker.isTracking(p)) {
|
||||
curProp = _isNumber(curProp) ? {
|
||||
velocity: curProp
|
||||
} : {
|
||||
velocity: tracker.get(p)
|
||||
}; //if we're tracking this property, we should use the tracking velocity and then use the numeric value that was passed in as the min and max so that it tweens exactly there.
|
||||
} else {
|
||||
curVelocity = +curProp || 0;
|
||||
curDuration = Math.abs(curVelocity / resistance);
|
||||
}
|
||||
}
|
||||
|
||||
if (_isObject(curProp)) {
|
||||
if (_isNumber(curProp.velocity)) {
|
||||
curVelocity = curProp.velocity;
|
||||
} else {
|
||||
tracker = tracker || _getTracker(target);
|
||||
curVelocity = tracker && tracker.isTracking(p) ? tracker.get(p) : 0;
|
||||
}
|
||||
|
||||
curDuration = _clamp(minDuration, maxDuration, Math.abs(curVelocity / _getNumOrDefault(curProp, "resistance", resistance)));
|
||||
curVal = parseFloat(getVal(target, p)) || 0;
|
||||
end = curVal + _calculateChange(curVelocity, curDuration);
|
||||
|
||||
if ("end" in curProp) {
|
||||
curProp = _parseEnd(curProp, linkedProps && p in linkedProps ? linkedProps : end, curProp.max, curProp.min, p, inertiaVars.radius, curVelocity);
|
||||
|
||||
if (recordEnd) {
|
||||
_processingVars === vars && (_processingVars = inertiaVars = _deepClone(vars));
|
||||
inertiaVars[p] = _extend(curProp, inertiaVars[p], "end");
|
||||
}
|
||||
}
|
||||
|
||||
if ("max" in curProp && end > +curProp.max + _tinyNum) {
|
||||
unitFactor = curProp.unitFactor || _config.unitFactors[p] || 1; //some values are measured in special units like radians in which case our thresholds need to be adjusted accordingly.
|
||||
//if the value is already exceeding the max or the velocity is too low, the duration can end up being uncomfortably long but in most situations, users want the snapping to occur relatively quickly (0.75 seconds), so we implement a cap here to make things more intuitive. If the max and min match, it means we're animating to a particular value and we don't want to shorten the time unless the velocity is really slow. Example: a rotation where the start and natural end value are less than the snapping spot, but the natural end is pretty close to the snap.
|
||||
|
||||
curClippedDuration = curVal > curProp.max && curProp.min !== curProp.max || curVelocity * unitFactor > -15 && curVelocity * unitFactor < 45 ? minDuration + (maxDuration - minDuration) * 0.1 : _calculateDuration(curVal, curProp.max, curVelocity);
|
||||
|
||||
if (curClippedDuration + overshootTolerance < clippedDuration) {
|
||||
clippedDuration = curClippedDuration + overshootTolerance;
|
||||
}
|
||||
} else if ("min" in curProp && end < +curProp.min - _tinyNum) {
|
||||
unitFactor = curProp.unitFactor || _config.unitFactors[p] || 1; //some values are measured in special units like radians in which case our thresholds need to be adjusted accordingly.
|
||||
//if the value is already exceeding the min or if the velocity is too low, the duration can end up being uncomfortably long but in most situations, users want the snapping to occur relatively quickly (0.75 seconds), so we implement a cap here to make things more intuitive.
|
||||
|
||||
curClippedDuration = curVal < curProp.min && curProp.min !== curProp.max || curVelocity * unitFactor > -45 && curVelocity * unitFactor < 15 ? minDuration + (maxDuration - minDuration) * 0.1 : _calculateDuration(curVal, curProp.min, curVelocity);
|
||||
|
||||
if (curClippedDuration + overshootTolerance < clippedDuration) {
|
||||
clippedDuration = curClippedDuration + overshootTolerance;
|
||||
}
|
||||
}
|
||||
|
||||
curClippedDuration > duration && (duration = curClippedDuration);
|
||||
}
|
||||
|
||||
curDuration > duration && (duration = curDuration);
|
||||
}
|
||||
}
|
||||
|
||||
duration > clippedDuration && (duration = clippedDuration);
|
||||
return duration > maxDuration ? maxDuration : duration < minDuration ? minDuration : duration;
|
||||
},
|
||||
_initCore = function _initCore() {
|
||||
gsap = _getGSAP();
|
||||
|
||||
if (gsap) {
|
||||
_parseEase = gsap.parseEase;
|
||||
_toArray = gsap.utils.toArray;
|
||||
_getUnit = gsap.utils.getUnit;
|
||||
_getCache = gsap.core.getCache;
|
||||
_clamp = gsap.utils.clamp;
|
||||
_getStyleSaver = gsap.core.getStyleSaver;
|
||||
|
||||
_reverting = gsap.core.reverting || function () {};
|
||||
|
||||
_power3 = _parseEase("power3");
|
||||
_checkPointRatio = _power3(0.05);
|
||||
PropTween = gsap.core.PropTween;
|
||||
gsap.config({
|
||||
resistance: 100,
|
||||
unitFactors: {
|
||||
time: 1000,
|
||||
totalTime: 1000,
|
||||
progress: 1000,
|
||||
totalProgress: 1000
|
||||
}
|
||||
});
|
||||
_config = gsap.config();
|
||||
gsap.registerPlugin(VelocityTracker);
|
||||
_coreInitted = 1;
|
||||
}
|
||||
};
|
||||
|
||||
export var InertiaPlugin = {
|
||||
version: "3.14.2",
|
||||
name: "inertia",
|
||||
register: function register(core) {
|
||||
gsap = core;
|
||||
|
||||
_initCore();
|
||||
},
|
||||
init: function init(target, vars, tween, index, targets) {
|
||||
_coreInitted || _initCore();
|
||||
|
||||
var tracker = _getTracker(target);
|
||||
|
||||
if (vars === "auto") {
|
||||
if (!tracker) {
|
||||
console.warn("No inertia tracking on " + target + ". InertiaPlugin.track(target) first.");
|
||||
return;
|
||||
}
|
||||
|
||||
vars = tracker.getAll();
|
||||
}
|
||||
|
||||
this.styles = _getStyleSaver && typeof target.style === "object" && _getStyleSaver(target);
|
||||
this.target = target;
|
||||
this.tween = tween;
|
||||
_processingVars = vars; // gets swapped inside _calculateTweenDuration() if there's a function-based value encountered (to avoid double-calling it)
|
||||
|
||||
var cache = target._gsap,
|
||||
getVal = cache.get,
|
||||
dur = vars.duration,
|
||||
durIsObj = _isObject(dur),
|
||||
preventOvershoot = vars.preventOvershoot || durIsObj && dur.overshoot === 0,
|
||||
resistance = _getNumOrDefault(vars, "resistance", _config.resistance),
|
||||
duration = _isNumber(dur) ? dur : _calculateTweenDuration(target, vars, durIsObj && dur.max || 10, durIsObj && dur.min || 0.2, durIsObj && "overshoot" in dur ? +dur.overshoot : preventOvershoot ? 0 : 1, true),
|
||||
p,
|
||||
curProp,
|
||||
curVal,
|
||||
unit,
|
||||
velocity,
|
||||
change1,
|
||||
end,
|
||||
change2,
|
||||
linkedProps;
|
||||
|
||||
vars = _processingVars;
|
||||
_processingVars = 0; //when there are linkedProps (typically "x,y" where snapping has to factor in multiple properties, we must first populate an object with all of those end values, then feed it to the function that make any necessary alterations. So the point of this first loop is to simply build an object (like {x:100, y:204.5}) for feeding into that function which we'll do later in the "real" loop.
|
||||
|
||||
linkedProps = _processLinkedProps(target, vars, getVal, resistance);
|
||||
|
||||
for (p in vars) {
|
||||
if (!_reservedProps[p]) {
|
||||
curProp = vars[p];
|
||||
_isFunction(curProp) && (curProp = curProp(index, target, targets));
|
||||
|
||||
if (_isNumber(curProp)) {
|
||||
velocity = curProp;
|
||||
} else if (_isObject(curProp) && !isNaN(curProp.velocity)) {
|
||||
velocity = +curProp.velocity;
|
||||
} else {
|
||||
if (tracker && tracker.isTracking(p)) {
|
||||
velocity = tracker.get(p);
|
||||
} else {
|
||||
console.warn("ERROR: No velocity was defined for " + target + " property: " + p);
|
||||
}
|
||||
}
|
||||
|
||||
change1 = _calculateChange(velocity, duration);
|
||||
change2 = 0;
|
||||
curVal = getVal(target, p);
|
||||
unit = _getUnit(curVal);
|
||||
curVal = parseFloat(curVal);
|
||||
|
||||
if (_isObject(curProp)) {
|
||||
end = curVal + change1;
|
||||
|
||||
if ("end" in curProp) {
|
||||
curProp = _parseEnd(curProp, linkedProps && p in linkedProps ? linkedProps : end, curProp.max, curProp.min, p, vars.radius, velocity);
|
||||
}
|
||||
|
||||
if ("max" in curProp && +curProp.max < end) {
|
||||
if (preventOvershoot || curProp.preventOvershoot) {
|
||||
change1 = curProp.max - curVal;
|
||||
} else {
|
||||
change2 = curProp.max - curVal - change1;
|
||||
}
|
||||
} else if ("min" in curProp && +curProp.min > end) {
|
||||
if (preventOvershoot || curProp.preventOvershoot) {
|
||||
change1 = curProp.min - curVal;
|
||||
} else {
|
||||
change2 = curProp.min - curVal - change1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this._props.push(p);
|
||||
|
||||
this.styles && this.styles.save(p);
|
||||
this._pt = new PropTween(this._pt, target, p, curVal, 0, _emptyFunc, 0, cache.set(target, p, this));
|
||||
this._pt.u = unit || 0;
|
||||
this._pt.c1 = change1;
|
||||
this._pt.c2 = change2;
|
||||
}
|
||||
}
|
||||
|
||||
tween.duration(duration);
|
||||
return _bonusValidated;
|
||||
},
|
||||
render: function render(ratio, data) {
|
||||
var pt = data._pt;
|
||||
ratio = _power3(data.tween._time / data.tween._dur);
|
||||
|
||||
if (ratio || !_reverting()) {
|
||||
while (pt) {
|
||||
pt.set(pt.t, pt.p, _round(pt.s + pt.c1 * ratio + pt.c2 * ratio * ratio) + pt.u, pt.d, ratio);
|
||||
pt = pt._next;
|
||||
}
|
||||
} else {
|
||||
data.styles.revert();
|
||||
}
|
||||
}
|
||||
};
|
||||
"track,untrack,isTracking,getVelocity,getByTarget".split(",").forEach(function (name) {
|
||||
return InertiaPlugin[name] = VelocityTracker[name];
|
||||
});
|
||||
_getGSAP() && gsap.registerPlugin(InertiaPlugin);
|
||||
export { InertiaPlugin as default, VelocityTracker };
|
||||
+1150
File diff suppressed because it is too large.
Load diff
+380
@@ -0,0 +1,380 @@
|
||||
/*!
|
||||
* MotionPathHelper 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
|
||||
*/
|
||||
|
||||
/* eslint-disable */
|
||||
import PathEditor from "./utils/PathEditor.js";
|
||||
|
||||
var gsap,
|
||||
_win,
|
||||
_doc,
|
||||
_docEl,
|
||||
_body,
|
||||
MotionPathPlugin,
|
||||
_arrayToRawPath,
|
||||
_rawPathToString,
|
||||
_context,
|
||||
_bonusValidated = 1,
|
||||
//<name>MotionPathHelper</name>
|
||||
_selectorExp = /(^[#\.][a-z]|[a-y][a-z])/i,
|
||||
_isString = function _isString(value) {
|
||||
return typeof value === "string";
|
||||
},
|
||||
_createElement = function _createElement(type, ns) {
|
||||
var e = _doc.createElementNS ? _doc.createElementNS((ns || "http://www.w3.org/1999/xhtml").replace(/^https/, "http"), type) : _doc.createElement(type); //some servers swap in https for http in the namespace which can break things, making "style" inaccessible.
|
||||
|
||||
return e.style ? e : _doc.createElement(type); //some environments won't allow access to the element's style when created with a namespace in which case we default to the standard createElement() to work around the issue. Also note that when GSAP is embedded directly inside an SVG file, createElement() won't allow access to the style object in Firefox (see https://gsap.com/forums/topic/20215-problem-using-tweenmax-in-standalone-self-containing-svg-file-err-cannot-set-property-csstext-of-undefined/).
|
||||
},
|
||||
_getPositionOnPage = function _getPositionOnPage(target) {
|
||||
var bounds = target.getBoundingClientRect(),
|
||||
windowOffsetY = _docEl.clientTop - (_win.pageYOffset || _docEl.scrollTop || _body.scrollTop || 0),
|
||||
windowOffsetX = _docEl.clientLeft - (_win.pageXOffset || _docEl.scrollLeft || _body.scrollLeft || 0);
|
||||
return {
|
||||
left: bounds.left + windowOffsetX,
|
||||
top: bounds.top + windowOffsetY,
|
||||
right: bounds.right + windowOffsetX,
|
||||
bottom: bounds.bottom + windowOffsetY
|
||||
};
|
||||
},
|
||||
_getInitialPath = function _getInitialPath(x, y) {
|
||||
var coordinates = [0, 31, 8, 58, 24, 75, 40, 90, 69, 100, 100, 100],
|
||||
i;
|
||||
|
||||
for (i = 0; i < coordinates.length; i += 2) {
|
||||
coordinates[i] += x;
|
||||
coordinates[i + 1] += y;
|
||||
}
|
||||
|
||||
return "M" + x + "," + y + "C" + coordinates.join(",");
|
||||
},
|
||||
_getGlobalTime = function _getGlobalTime(animation) {
|
||||
var time = animation.totalTime();
|
||||
|
||||
while (animation) {
|
||||
time = animation.startTime() + time / (animation.timeScale() || 1);
|
||||
animation = animation.parent;
|
||||
}
|
||||
|
||||
return time;
|
||||
},
|
||||
_copyElement,
|
||||
_initCopyToClipboard = function _initCopyToClipboard() {
|
||||
_copyElement = _createElement("textarea");
|
||||
_copyElement.style.display = "none";
|
||||
|
||||
_body.appendChild(_copyElement);
|
||||
},
|
||||
_parsePath = function _parsePath(path, target, vars) {
|
||||
return _isString(path) && _selectorExp.test(path) ? _doc.querySelector(path) : Array.isArray(path) ? _rawPathToString(_arrayToRawPath([{
|
||||
x: gsap.getProperty(target, "x"),
|
||||
y: gsap.getProperty(target, "y")
|
||||
}].concat(path), vars)) : _isString(path) || path && (path.tagName + "").toLowerCase() === "path" ? path : 0;
|
||||
},
|
||||
_addCopyToClipboard = function _addCopyToClipboard(target, getter, onComplete) {
|
||||
target.addEventListener('click', function (e) {
|
||||
if (e.target._gsHelper) {
|
||||
var c = getter(e.target);
|
||||
_copyElement.value = c;
|
||||
|
||||
if (c && _copyElement.select) {
|
||||
console.log(c);
|
||||
_copyElement.style.display = "block";
|
||||
|
||||
_copyElement.select();
|
||||
|
||||
try {
|
||||
_doc.execCommand('copy');
|
||||
|
||||
_copyElement.blur();
|
||||
|
||||
onComplete && onComplete(target);
|
||||
} catch (err) {
|
||||
console.warn("Copy didn't work; this browser doesn't permit that.");
|
||||
}
|
||||
|
||||
_copyElement.style.display = "none";
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
_identityMatrixObject = {
|
||||
matrix: {
|
||||
a: 1,
|
||||
b: 0,
|
||||
c: 0,
|
||||
d: 1,
|
||||
e: 0,
|
||||
f: 0
|
||||
}
|
||||
},
|
||||
_getConsolidatedMatrix = function _getConsolidatedMatrix(target) {
|
||||
return (target.transform.baseVal.consolidate() || _identityMatrixObject).matrix;
|
||||
},
|
||||
_findMotionPathTween = function _findMotionPathTween(target) {
|
||||
var tweens = gsap.getTweensOf(target),
|
||||
i = 0;
|
||||
|
||||
for (; i < tweens.length; i++) {
|
||||
if (tweens[i].vars.motionPath) {
|
||||
return tweens[i];
|
||||
} else if (tweens[i].timeline) {
|
||||
tweens.push.apply(tweens, tweens[i].timeline.getChildren());
|
||||
}
|
||||
}
|
||||
},
|
||||
_initCore = function _initCore(core, required) {
|
||||
var message = "Please gsap.registerPlugin(MotionPathPlugin)";
|
||||
_win = window;
|
||||
gsap = gsap || core || _win.gsap || console.warn(message);
|
||||
gsap && PathEditor.register(gsap);
|
||||
_doc = document;
|
||||
_body = _doc.body;
|
||||
_docEl = _doc.documentElement;
|
||||
|
||||
if (gsap) {
|
||||
MotionPathPlugin = gsap.plugins.motionPath;
|
||||
MotionPathHelper.PathEditor = PathEditor;
|
||||
|
||||
_context = gsap.core.context || function () {};
|
||||
}
|
||||
|
||||
if (!MotionPathPlugin) {
|
||||
required === true && console.warn(message);
|
||||
} else {
|
||||
_initCopyToClipboard();
|
||||
|
||||
_arrayToRawPath = MotionPathPlugin.arrayToRawPath;
|
||||
_rawPathToString = MotionPathPlugin.rawPathToString;
|
||||
}
|
||||
};
|
||||
|
||||
export var MotionPathHelper = /*#__PURE__*/function () {
|
||||
function MotionPathHelper(targetOrTween, vars) {
|
||||
var _this = this;
|
||||
|
||||
if (vars === void 0) {
|
||||
vars = {};
|
||||
}
|
||||
|
||||
if (!MotionPathPlugin) {
|
||||
_initCore(vars.gsap, 1);
|
||||
}
|
||||
|
||||
var copyButton = _createElement("div"),
|
||||
self = this,
|
||||
offset = {
|
||||
x: 0,
|
||||
y: 0
|
||||
},
|
||||
target,
|
||||
path,
|
||||
isSVG,
|
||||
startX,
|
||||
startY,
|
||||
position,
|
||||
svg,
|
||||
animation,
|
||||
svgNamespace,
|
||||
temp,
|
||||
matrix,
|
||||
refreshPath,
|
||||
animationToScrub,
|
||||
createdSVG;
|
||||
|
||||
if (targetOrTween instanceof gsap.core.Tween) {
|
||||
animation = targetOrTween;
|
||||
target = animation.targets()[0];
|
||||
} else {
|
||||
target = gsap.utils.toArray(targetOrTween)[0];
|
||||
animation = _findMotionPathTween(target);
|
||||
}
|
||||
|
||||
path = _parsePath(vars.path, target, vars);
|
||||
this.offset = offset;
|
||||
position = _getPositionOnPage(target);
|
||||
startX = parseFloat(gsap.getProperty(target, "x", "px"));
|
||||
startY = parseFloat(gsap.getProperty(target, "y", "px"));
|
||||
isSVG = target.getCTM && target.tagName.toLowerCase() !== "svg";
|
||||
|
||||
if (animation && !path) {
|
||||
path = _parsePath(animation.vars.motionPath.path || animation.vars.motionPath, target, animation.vars.motionPath);
|
||||
}
|
||||
|
||||
copyButton.setAttribute("class", "copy-motion-path");
|
||||
copyButton.style.cssText = "border-radius:8px; background-color:rgba(85, 85, 85, 0.7); color:#fff; cursor:pointer; padding:6px 12px; font-family:Signika Negative, Arial, sans-serif; position:fixed; left:50%; transform:translate(-50%, 0); font-size:19px; bottom:10px";
|
||||
copyButton.innerText = "COPY MOTION PATH";
|
||||
copyButton._gsHelper = self;
|
||||
|
||||
(gsap.utils.toArray(vars.container)[0] || _body).appendChild(copyButton);
|
||||
|
||||
_addCopyToClipboard(copyButton, function () {
|
||||
return self.getString();
|
||||
}, function () {
|
||||
return gsap.fromTo(copyButton, {
|
||||
backgroundColor: "white"
|
||||
}, {
|
||||
duration: 0.5,
|
||||
backgroundColor: "rgba(85, 85, 85, 0.6)"
|
||||
});
|
||||
});
|
||||
|
||||
svg = path && path.ownerSVGElement;
|
||||
|
||||
if (!svg) {
|
||||
svgNamespace = isSVG && target.ownerSVGElement && target.ownerSVGElement.getAttribute("xmlns") || "http://www.w3.org/2000/svg";
|
||||
|
||||
if (isSVG) {
|
||||
svg = target.ownerSVGElement;
|
||||
temp = target.getBBox();
|
||||
matrix = _getConsolidatedMatrix(target);
|
||||
startX = matrix.e;
|
||||
startY = matrix.f;
|
||||
offset.x = temp.x;
|
||||
offset.y = temp.y;
|
||||
} else {
|
||||
svg = _createElement("svg", svgNamespace);
|
||||
createdSVG = true;
|
||||
|
||||
_body.appendChild(svg);
|
||||
|
||||
svg.setAttribute("viewBox", "0 0 100 100");
|
||||
svg.setAttribute("class", "motion-path-helper");
|
||||
svg.style.cssText = "overflow:visible; background-color: transparent; position:absolute; z-index:5000; width:100px; height:100px; top:" + (position.top - startY) + "px; left:" + (position.left - startX) + "px;";
|
||||
}
|
||||
|
||||
temp = _isString(path) && !_selectorExp.test(path) ? path : _getInitialPath(startX, startY);
|
||||
path = _createElement("path", svgNamespace);
|
||||
path.setAttribute("d", temp);
|
||||
path.setAttribute("vector-effect", "non-scaling-stroke");
|
||||
path.style.cssText = "fill:transparent; stroke-width:" + (vars.pathWidth || 3) + "; stroke:" + (vars.pathColor || "#555") + "; opacity:" + (vars.pathOpacity || 0.6);
|
||||
svg.appendChild(path);
|
||||
} else {
|
||||
vars.pathColor && gsap.set(path, {
|
||||
stroke: vars.pathColor
|
||||
});
|
||||
vars.pathWidth && gsap.set(path, {
|
||||
strokeWidth: vars.pathWidth
|
||||
});
|
||||
vars.pathOpacity && gsap.set(path, {
|
||||
opacity: vars.pathOpacity
|
||||
});
|
||||
}
|
||||
|
||||
if (offset.x || offset.y) {
|
||||
gsap.set(path, {
|
||||
x: offset.x,
|
||||
y: offset.y
|
||||
});
|
||||
}
|
||||
|
||||
if (!("selected" in vars)) {
|
||||
vars.selected = true;
|
||||
}
|
||||
|
||||
if (!("anchorSnap" in vars)) {
|
||||
vars.anchorSnap = function (p) {
|
||||
if (p.x * p.x + p.y * p.y < 16) {
|
||||
p.x = p.y = 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
animationToScrub = animation && animation.parent && animation.parent.data === "nested" ? animation.parent.parent : animation;
|
||||
|
||||
vars.onPress = function () {
|
||||
animationToScrub.pause(0);
|
||||
};
|
||||
|
||||
refreshPath = function refreshPath() {
|
||||
//let m = _getConsolidatedMatrix(path);
|
||||
//animation.vars.motionPath.offsetX = m.e - offset.x;
|
||||
//animation.vars.motionPath.offsetY = m.f - offset.y;
|
||||
if (_this.editor._anchors.length < 2) {
|
||||
console.warn("A motion path must have at least two anchors.");
|
||||
} else {
|
||||
animation.invalidate();
|
||||
animationToScrub.restart();
|
||||
}
|
||||
};
|
||||
|
||||
vars.onRelease = vars.onDeleteAnchor = refreshPath;
|
||||
this.editor = PathEditor.create(path, vars);
|
||||
|
||||
if (vars.center) {
|
||||
gsap.set(target, {
|
||||
transformOrigin: "50% 50%",
|
||||
xPercent: -50,
|
||||
yPercent: -50
|
||||
});
|
||||
}
|
||||
|
||||
if (animation) {
|
||||
if (animation.vars.motionPath.path) {
|
||||
animation.vars.motionPath.path = path;
|
||||
} else {
|
||||
animation.vars.motionPath = {
|
||||
path: path
|
||||
};
|
||||
}
|
||||
|
||||
if (animationToScrub.parent !== gsap.globalTimeline) {
|
||||
gsap.globalTimeline.add(animationToScrub, _getGlobalTime(animationToScrub) - animationToScrub.delay());
|
||||
}
|
||||
|
||||
animationToScrub.repeat(-1).repeatDelay(1);
|
||||
} else {
|
||||
animation = animationToScrub = gsap.to(target, {
|
||||
motionPath: {
|
||||
path: path,
|
||||
start: vars.start || 0,
|
||||
end: "end" in vars ? vars.end : 1,
|
||||
autoRotate: "autoRotate" in vars ? vars.autoRotate : false,
|
||||
align: path,
|
||||
alignOrigin: vars.alignOrigin
|
||||
},
|
||||
duration: vars.duration || 5,
|
||||
ease: vars.ease || "power1.inOut",
|
||||
repeat: -1,
|
||||
repeatDelay: 1,
|
||||
paused: !vars.path
|
||||
});
|
||||
}
|
||||
|
||||
this.animation = animation;
|
||||
|
||||
_context(this);
|
||||
|
||||
this.kill = this.revert = function () {
|
||||
_this.editor.kill();
|
||||
|
||||
copyButton.parentNode && copyButton.parentNode.removeChild(copyButton);
|
||||
createdSVG && svg.parentNode && svg.parentNode.removeChild(svg);
|
||||
animationToScrub && animationToScrub.revert();
|
||||
};
|
||||
}
|
||||
|
||||
var _proto = MotionPathHelper.prototype;
|
||||
|
||||
_proto.getString = function getString() {
|
||||
return this.editor.getString(true, -this.offset.x, -this.offset.y);
|
||||
};
|
||||
|
||||
return MotionPathHelper;
|
||||
}();
|
||||
MotionPathHelper.register = _initCore;
|
||||
|
||||
MotionPathHelper.create = function (target, vars) {
|
||||
return new MotionPathHelper(target, vars);
|
||||
};
|
||||
|
||||
MotionPathHelper.editPath = function (path, vars) {
|
||||
return PathEditor.create(path, vars);
|
||||
};
|
||||
|
||||
MotionPathHelper.version = "3.14.2";
|
||||
export { MotionPathHelper as default };
|
||||
+369
@@ -0,0 +1,369 @@
|
||||
/*!
|
||||
* MotionPathPlugin 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
|
||||
*/
|
||||
|
||||
/* eslint-disable */
|
||||
import { getRawPath, cacheRawPathMeasurements, getPositionOnPath, pointsToSegment, flatPointsToSegment, sliceRawPath, stringToRawPath, rawPathToString, transformRawPath, convertToPath as _convertToPath } from "./utils/paths.js";
|
||||
import { getGlobalMatrix } from "./utils/matrix.js";
|
||||
|
||||
var _xProps = "x,translateX,left,marginLeft,xPercent".split(","),
|
||||
_yProps = "y,translateY,top,marginTop,yPercent".split(","),
|
||||
_DEG2RAD = Math.PI / 180,
|
||||
gsap,
|
||||
PropTween,
|
||||
_getUnit,
|
||||
_toArray,
|
||||
_getStyleSaver,
|
||||
_reverting,
|
||||
_getGSAP = function _getGSAP() {
|
||||
return gsap || typeof window !== "undefined" && (gsap = window.gsap) && gsap.registerPlugin && gsap;
|
||||
},
|
||||
_populateSegmentFromArray = function _populateSegmentFromArray(segment, values, property, mode) {
|
||||
//mode: 0 = x but don't fill y yet, 1 = y, 2 = x and fill y with 0.
|
||||
var l = values.length,
|
||||
si = mode === 2 ? 0 : mode,
|
||||
i = 0,
|
||||
v;
|
||||
|
||||
for (; i < l; i++) {
|
||||
segment[si] = v = parseFloat(values[i][property]);
|
||||
mode === 2 && (segment[si + 1] = 0);
|
||||
si += 2;
|
||||
}
|
||||
|
||||
return segment;
|
||||
},
|
||||
_getPropNum = function _getPropNum(target, prop, unit) {
|
||||
return parseFloat(target._gsap.get(target, prop, unit || "px")) || 0;
|
||||
},
|
||||
_relativize = function _relativize(segment) {
|
||||
var x = segment[0],
|
||||
y = segment[1],
|
||||
i;
|
||||
|
||||
for (i = 2; i < segment.length; i += 2) {
|
||||
x = segment[i] += x;
|
||||
y = segment[i + 1] += y;
|
||||
}
|
||||
},
|
||||
// feed in an array of quadratic bezier points like [{x: 0, y: 0}, ...] and it'll convert it to cubic bezier
|
||||
// _quadToCubic = points => {
|
||||
// let cubic = [],
|
||||
// l = points.length - 1,
|
||||
// i = 1,
|
||||
// a, b, c;
|
||||
// for (; i < l; i+=2) {
|
||||
// a = points[i-1];
|
||||
// b = points[i];
|
||||
// c = points[i+1];
|
||||
// cubic.push(a, {x: (2 * b.x + a.x) / 3, y: (2 * b.y + a.y) / 3}, {x: (2 * b.x + c.x) / 3, y: (2 * b.y + c.y) / 3});
|
||||
// }
|
||||
// cubic.push(points[l]);
|
||||
// return cubic;
|
||||
// },
|
||||
_segmentToRawPath = function _segmentToRawPath(plugin, segment, target, x, y, slicer, vars, unitX, unitY) {
|
||||
if (vars.type === "cubic") {
|
||||
segment = [segment];
|
||||
} else {
|
||||
vars.fromCurrent !== false && segment.unshift(_getPropNum(target, x, unitX), y ? _getPropNum(target, y, unitY) : 0);
|
||||
vars.relative && _relativize(segment);
|
||||
var pointFunc = y ? pointsToSegment : flatPointsToSegment;
|
||||
segment = [pointFunc(segment, vars.curviness)];
|
||||
}
|
||||
|
||||
segment = slicer(_align(segment, target, vars));
|
||||
|
||||
_addDimensionalPropTween(plugin, target, x, segment, "x", unitX);
|
||||
|
||||
y && _addDimensionalPropTween(plugin, target, y, segment, "y", unitY);
|
||||
return cacheRawPathMeasurements(segment, vars.resolution || (vars.curviness === 0 ? 20 : 12)); //when curviness is 0, it creates control points right on top of the anchors which makes it more sensitive to resolution, thus we change the default accordingly.
|
||||
},
|
||||
_emptyFunc = function _emptyFunc(v) {
|
||||
return v;
|
||||
},
|
||||
_numExp = /[-+\.]*\d+\.?(?:e-|e\+)?\d*/g,
|
||||
_originToPoint = function _originToPoint(element, origin, parentMatrix) {
|
||||
// origin is an array of normalized values (0-1) in relation to the width/height, so [0.5, 0.5] would be the center. It can also be "auto" in which case it will be the top left unless it's a <path>, when it will start at the beginning of the path itself.
|
||||
var m = getGlobalMatrix(element),
|
||||
x = 0,
|
||||
y = 0,
|
||||
svg;
|
||||
|
||||
if ((element.tagName + "").toLowerCase() === "svg") {
|
||||
svg = element.viewBox.baseVal;
|
||||
svg.width || (svg = {
|
||||
width: +element.getAttribute("width"),
|
||||
height: +element.getAttribute("height")
|
||||
});
|
||||
} else {
|
||||
svg = origin && element.getBBox && element.getBBox();
|
||||
}
|
||||
|
||||
if (origin && origin !== "auto") {
|
||||
x = origin.push ? origin[0] * (svg ? svg.width : element.offsetWidth || 0) : origin.x;
|
||||
y = origin.push ? origin[1] * (svg ? svg.height : element.offsetHeight || 0) : origin.y;
|
||||
}
|
||||
|
||||
return parentMatrix.apply(x || y ? m.apply({
|
||||
x: x,
|
||||
y: y
|
||||
}) : {
|
||||
x: m.e,
|
||||
y: m.f
|
||||
});
|
||||
},
|
||||
_getAlignMatrix = function _getAlignMatrix(fromElement, toElement, fromOrigin, toOrigin) {
|
||||
var parentMatrix = getGlobalMatrix(fromElement.parentNode, true, true),
|
||||
m = parentMatrix.clone().multiply(getGlobalMatrix(toElement)),
|
||||
fromPoint = _originToPoint(fromElement, fromOrigin, parentMatrix),
|
||||
_originToPoint2 = _originToPoint(toElement, toOrigin, parentMatrix),
|
||||
x = _originToPoint2.x,
|
||||
y = _originToPoint2.y,
|
||||
p;
|
||||
|
||||
m.e = m.f = 0;
|
||||
|
||||
if (toOrigin === "auto" && toElement.getTotalLength && toElement.tagName.toLowerCase() === "path") {
|
||||
p = toElement.getAttribute("d").match(_numExp) || [];
|
||||
p = m.apply({
|
||||
x: +p[0],
|
||||
y: +p[1]
|
||||
});
|
||||
x += p.x;
|
||||
y += p.y;
|
||||
} //if (p || (toElement.getBBox && fromElement.getBBox && toElement.ownerSVGElement === fromElement.ownerSVGElement)) {
|
||||
|
||||
|
||||
if (p) {
|
||||
p = m.apply(toElement.getBBox());
|
||||
x -= p.x;
|
||||
y -= p.y;
|
||||
}
|
||||
|
||||
m.e = x - fromPoint.x;
|
||||
m.f = y - fromPoint.y;
|
||||
return m;
|
||||
},
|
||||
_align = function _align(rawPath, target, _ref) {
|
||||
var align = _ref.align,
|
||||
matrix = _ref.matrix,
|
||||
offsetX = _ref.offsetX,
|
||||
offsetY = _ref.offsetY,
|
||||
alignOrigin = _ref.alignOrigin;
|
||||
|
||||
var x = rawPath[0][0],
|
||||
y = rawPath[0][1],
|
||||
curX = _getPropNum(target, "x"),
|
||||
curY = _getPropNum(target, "y"),
|
||||
alignTarget,
|
||||
m,
|
||||
p;
|
||||
|
||||
if (!rawPath || !rawPath.length) {
|
||||
return getRawPath("M0,0L0,0");
|
||||
}
|
||||
|
||||
if (align) {
|
||||
if (align === "self" || (alignTarget = _toArray(align)[0] || target) === target) {
|
||||
transformRawPath(rawPath, 1, 0, 0, 1, curX - x, curY - y);
|
||||
} else {
|
||||
if (alignOrigin && alignOrigin[2] !== false) {
|
||||
gsap.set(target, {
|
||||
transformOrigin: alignOrigin[0] * 100 + "% " + alignOrigin[1] * 100 + "%"
|
||||
});
|
||||
} else {
|
||||
alignOrigin = [_getPropNum(target, "xPercent") / -100, _getPropNum(target, "yPercent") / -100];
|
||||
}
|
||||
|
||||
m = _getAlignMatrix(target, alignTarget, alignOrigin, "auto");
|
||||
p = m.apply({
|
||||
x: x,
|
||||
y: y
|
||||
});
|
||||
transformRawPath(rawPath, m.a, m.b, m.c, m.d, curX + m.e - (p.x - m.e), curY + m.f - (p.y - m.f));
|
||||
}
|
||||
}
|
||||
|
||||
if (matrix) {
|
||||
transformRawPath(rawPath, matrix.a, matrix.b, matrix.c, matrix.d, matrix.e, matrix.f);
|
||||
} else if (offsetX || offsetY) {
|
||||
transformRawPath(rawPath, 1, 0, 0, 1, offsetX || 0, offsetY || 0);
|
||||
}
|
||||
|
||||
return rawPath;
|
||||
},
|
||||
_addDimensionalPropTween = function _addDimensionalPropTween(plugin, target, property, rawPath, pathProperty, forceUnit) {
|
||||
var cache = target._gsap,
|
||||
harness = cache.harness,
|
||||
alias = harness && harness.aliases && harness.aliases[property],
|
||||
prop = alias && alias.indexOf(",") < 0 ? alias : property,
|
||||
pt = plugin._pt = new PropTween(plugin._pt, target, prop, 0, 0, _emptyFunc, 0, cache.set(target, prop, plugin));
|
||||
pt.u = _getUnit(cache.get(target, prop, forceUnit)) || 0;
|
||||
pt.path = rawPath;
|
||||
pt.pp = pathProperty;
|
||||
|
||||
plugin._props.push(prop);
|
||||
},
|
||||
_sliceModifier = function _sliceModifier(start, end) {
|
||||
return function (rawPath) {
|
||||
return start || end !== 1 ? sliceRawPath(rawPath, start, end) : rawPath;
|
||||
};
|
||||
};
|
||||
|
||||
export var MotionPathPlugin = {
|
||||
version: "3.14.2",
|
||||
name: "motionPath",
|
||||
register: function register(core, Plugin, propTween) {
|
||||
gsap = core;
|
||||
_getUnit = gsap.utils.getUnit;
|
||||
_toArray = gsap.utils.toArray;
|
||||
_getStyleSaver = gsap.core.getStyleSaver;
|
||||
|
||||
_reverting = gsap.core.reverting || function () {};
|
||||
|
||||
PropTween = propTween;
|
||||
},
|
||||
init: function init(target, vars, tween) {
|
||||
if (!gsap) {
|
||||
console.warn("Please gsap.registerPlugin(MotionPathPlugin)");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(typeof vars === "object" && !vars.style) || !vars.path) {
|
||||
vars = {
|
||||
path: vars
|
||||
};
|
||||
}
|
||||
|
||||
var rawPaths = [],
|
||||
_vars = vars,
|
||||
path = _vars.path,
|
||||
autoRotate = _vars.autoRotate,
|
||||
unitX = _vars.unitX,
|
||||
unitY = _vars.unitY,
|
||||
x = _vars.x,
|
||||
y = _vars.y,
|
||||
firstObj = path[0],
|
||||
slicer = _sliceModifier(vars.start, "end" in vars ? vars.end : 1),
|
||||
rawPath,
|
||||
p;
|
||||
|
||||
this.rawPaths = rawPaths;
|
||||
this.target = target;
|
||||
this.tween = tween;
|
||||
this.styles = _getStyleSaver && _getStyleSaver(target, "transform");
|
||||
|
||||
if (this.rotate = autoRotate || autoRotate === 0) {
|
||||
//get the rotational data FIRST so that the setTransform() method is called in the correct order in the render() loop - rotation gets set last.
|
||||
this.rOffset = parseFloat(autoRotate) || 0;
|
||||
this.radians = !!vars.useRadians;
|
||||
this.rProp = vars.rotation || "rotation"; // rotation property
|
||||
|
||||
this.rSet = target._gsap.set(target, this.rProp, this); // rotation setter
|
||||
|
||||
this.ru = _getUnit(target._gsap.get(target, this.rProp)) || 0; // rotation units
|
||||
}
|
||||
|
||||
if (Array.isArray(path) && !("closed" in path) && typeof firstObj !== "number") {
|
||||
for (p in firstObj) {
|
||||
if (!x && ~_xProps.indexOf(p)) {
|
||||
x = p;
|
||||
} else if (!y && ~_yProps.indexOf(p)) {
|
||||
y = p;
|
||||
}
|
||||
}
|
||||
|
||||
if (x && y) {
|
||||
//correlated values
|
||||
rawPaths.push(_segmentToRawPath(this, _populateSegmentFromArray(_populateSegmentFromArray([], path, x, 0), path, y, 1), target, x, y, slicer, vars, unitX || _getUnit(path[0][x]), unitY || _getUnit(path[0][y])));
|
||||
} else {
|
||||
x = y = 0;
|
||||
}
|
||||
|
||||
for (p in firstObj) {
|
||||
p !== x && p !== y && rawPaths.push(_segmentToRawPath(this, _populateSegmentFromArray([], path, p, 2), target, p, 0, slicer, vars, _getUnit(path[0][p])));
|
||||
}
|
||||
} else {
|
||||
rawPath = slicer(_align(getRawPath(vars.path), target, vars));
|
||||
cacheRawPathMeasurements(rawPath, vars.resolution);
|
||||
rawPaths.push(rawPath);
|
||||
|
||||
_addDimensionalPropTween(this, target, vars.x || "x", rawPath, "x", vars.unitX || "px");
|
||||
|
||||
_addDimensionalPropTween(this, target, vars.y || "y", rawPath, "y", vars.unitY || "px");
|
||||
}
|
||||
|
||||
tween.vars.immediateRender && this.render(tween.progress(), this);
|
||||
},
|
||||
render: function render(ratio, data) {
|
||||
var rawPaths = data.rawPaths,
|
||||
i = rawPaths.length,
|
||||
pt = data._pt;
|
||||
|
||||
if (data.tween._time || !_reverting()) {
|
||||
if (ratio > 1) {
|
||||
ratio = 1;
|
||||
} else if (ratio < 0) {
|
||||
ratio = 0;
|
||||
}
|
||||
|
||||
while (i--) {
|
||||
getPositionOnPath(rawPaths[i], ratio, !i && data.rotate, rawPaths[i]);
|
||||
}
|
||||
|
||||
while (pt) {
|
||||
pt.set(pt.t, pt.p, pt.path[pt.pp] + pt.u, pt.d, ratio);
|
||||
pt = pt._next;
|
||||
}
|
||||
|
||||
data.rotate && data.rSet(data.target, data.rProp, rawPaths[0].angle * (data.radians ? _DEG2RAD : 1) + data.rOffset + data.ru, data, ratio);
|
||||
} else {
|
||||
data.styles.revert();
|
||||
}
|
||||
},
|
||||
getLength: function getLength(path) {
|
||||
return cacheRawPathMeasurements(getRawPath(path)).totalLength;
|
||||
},
|
||||
sliceRawPath: sliceRawPath,
|
||||
getRawPath: getRawPath,
|
||||
pointsToSegment: pointsToSegment,
|
||||
stringToRawPath: stringToRawPath,
|
||||
rawPathToString: rawPathToString,
|
||||
transformRawPath: transformRawPath,
|
||||
getGlobalMatrix: getGlobalMatrix,
|
||||
getPositionOnPath: getPositionOnPath,
|
||||
cacheRawPathMeasurements: cacheRawPathMeasurements,
|
||||
convertToPath: function convertToPath(targets, swap) {
|
||||
return _toArray(targets).map(function (target) {
|
||||
return _convertToPath(target, swap !== false);
|
||||
});
|
||||
},
|
||||
convertCoordinates: function convertCoordinates(fromElement, toElement, point) {
|
||||
var m = getGlobalMatrix(toElement, true, true).multiply(getGlobalMatrix(fromElement));
|
||||
return point ? m.apply(point) : m;
|
||||
},
|
||||
getAlignMatrix: _getAlignMatrix,
|
||||
getRelativePosition: function getRelativePosition(fromElement, toElement, fromOrigin, toOrigin) {
|
||||
var m = _getAlignMatrix(fromElement, toElement, fromOrigin, toOrigin);
|
||||
|
||||
return {
|
||||
x: m.e,
|
||||
y: m.f
|
||||
};
|
||||
},
|
||||
arrayToRawPath: function arrayToRawPath(value, vars) {
|
||||
vars = vars || {};
|
||||
|
||||
var segment = _populateSegmentFromArray(_populateSegmentFromArray([], value, vars.x || "x", 0), value, vars.y || "y", 1);
|
||||
|
||||
vars.relative && _relativize(segment);
|
||||
return [vars.type === "cubic" ? segment : pointsToSegment(segment, vars.curviness)];
|
||||
}
|
||||
};
|
||||
_getGSAP() && gsap.registerPlugin(MotionPathPlugin);
|
||||
export { MotionPathPlugin as default };
|
||||
+708
@@ -0,0 +1,708 @@
|
||||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
||||
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
||||
|
||||
/*!
|
||||
* Observer 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
|
||||
*/
|
||||
|
||||
/* eslint-disable */
|
||||
var gsap,
|
||||
_coreInitted,
|
||||
_clamp,
|
||||
_win,
|
||||
_doc,
|
||||
_docEl,
|
||||
_body,
|
||||
_isTouch,
|
||||
_pointerType,
|
||||
ScrollTrigger,
|
||||
_root,
|
||||
_normalizer,
|
||||
_eventTypes,
|
||||
_context,
|
||||
_getGSAP = function _getGSAP() {
|
||||
return gsap || typeof window !== "undefined" && (gsap = window.gsap) && gsap.registerPlugin && gsap;
|
||||
},
|
||||
_startup = 1,
|
||||
_observers = [],
|
||||
_scrollers = [],
|
||||
_proxies = [],
|
||||
_getTime = Date.now,
|
||||
_bridge = function _bridge(name, value) {
|
||||
return value;
|
||||
},
|
||||
_integrate = function _integrate() {
|
||||
var core = ScrollTrigger.core,
|
||||
data = core.bridge || {},
|
||||
scrollers = core._scrollers,
|
||||
proxies = core._proxies;
|
||||
scrollers.push.apply(scrollers, _scrollers);
|
||||
proxies.push.apply(proxies, _proxies);
|
||||
_scrollers = scrollers;
|
||||
_proxies = proxies;
|
||||
|
||||
_bridge = function _bridge(name, value) {
|
||||
return data[name](value);
|
||||
};
|
||||
},
|
||||
_getProxyProp = function _getProxyProp(element, property) {
|
||||
return ~_proxies.indexOf(element) && _proxies[_proxies.indexOf(element) + 1][property];
|
||||
},
|
||||
_isViewport = function _isViewport(el) {
|
||||
return !!~_root.indexOf(el);
|
||||
},
|
||||
_addListener = function _addListener(element, type, func, passive, capture) {
|
||||
return element.addEventListener(type, func, {
|
||||
passive: passive !== false,
|
||||
capture: !!capture
|
||||
});
|
||||
},
|
||||
_removeListener = function _removeListener(element, type, func, capture) {
|
||||
return element.removeEventListener(type, func, !!capture);
|
||||
},
|
||||
_scrollLeft = "scrollLeft",
|
||||
_scrollTop = "scrollTop",
|
||||
_onScroll = function _onScroll() {
|
||||
return _normalizer && _normalizer.isPressed || _scrollers.cache++;
|
||||
},
|
||||
_scrollCacheFunc = function _scrollCacheFunc(f, doNotCache) {
|
||||
var cachingFunc = function cachingFunc(value) {
|
||||
// since reading the scrollTop/scrollLeft/pageOffsetY/pageOffsetX can trigger a layout, this function allows us to cache the value so it only gets read fresh after a "scroll" event fires (or while we're refreshing because that can lengthen the page and alter the scroll position). when "soft" is true, that means don't actually set the scroll, but cache the new value instead (useful in ScrollSmoother)
|
||||
if (value || value === 0) {
|
||||
_startup && (_win.history.scrollRestoration = "manual"); // otherwise the new position will get overwritten by the browser onload.
|
||||
|
||||
var isNormalizing = _normalizer && _normalizer.isPressed;
|
||||
value = cachingFunc.v = Math.round(value) || (_normalizer && _normalizer.iOS ? 1 : 0); //TODO: iOS Bug: if you allow it to go to 0, Safari can start to report super strange (wildly inaccurate) touch positions!
|
||||
|
||||
f(value);
|
||||
cachingFunc.cacheID = _scrollers.cache;
|
||||
isNormalizing && _bridge("ss", value); // set scroll (notify ScrollTrigger so it can dispatch a "scrollStart" event if necessary
|
||||
} else if (doNotCache || _scrollers.cache !== cachingFunc.cacheID || _bridge("ref")) {
|
||||
cachingFunc.cacheID = _scrollers.cache;
|
||||
cachingFunc.v = f();
|
||||
}
|
||||
|
||||
return cachingFunc.v + cachingFunc.offset;
|
||||
};
|
||||
|
||||
cachingFunc.offset = 0;
|
||||
return f && cachingFunc;
|
||||
},
|
||||
_horizontal = {
|
||||
s: _scrollLeft,
|
||||
p: "left",
|
||||
p2: "Left",
|
||||
os: "right",
|
||||
os2: "Right",
|
||||
d: "width",
|
||||
d2: "Width",
|
||||
a: "x",
|
||||
sc: _scrollCacheFunc(function (value) {
|
||||
return arguments.length ? _win.scrollTo(value, _vertical.sc()) : _win.pageXOffset || _doc[_scrollLeft] || _docEl[_scrollLeft] || _body[_scrollLeft] || 0;
|
||||
})
|
||||
},
|
||||
_vertical = {
|
||||
s: _scrollTop,
|
||||
p: "top",
|
||||
p2: "Top",
|
||||
os: "bottom",
|
||||
os2: "Bottom",
|
||||
d: "height",
|
||||
d2: "Height",
|
||||
a: "y",
|
||||
op: _horizontal,
|
||||
sc: _scrollCacheFunc(function (value) {
|
||||
return arguments.length ? _win.scrollTo(_horizontal.sc(), value) : _win.pageYOffset || _doc[_scrollTop] || _docEl[_scrollTop] || _body[_scrollTop] || 0;
|
||||
})
|
||||
},
|
||||
_getTarget = function _getTarget(t, self) {
|
||||
return (self && self._ctx && self._ctx.selector || gsap.utils.toArray)(t)[0] || (typeof t === "string" && gsap.config().nullTargetWarn !== false ? console.warn("Element not found:", t) : null);
|
||||
},
|
||||
_isWithin = function _isWithin(element, list) {
|
||||
// check if the element is in the list or is a descendant of an element in the list.
|
||||
var i = list.length;
|
||||
|
||||
while (i--) {
|
||||
if (list[i] === element || list[i].contains(element)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
_getScrollFunc = function _getScrollFunc(element, _ref) {
|
||||
var s = _ref.s,
|
||||
sc = _ref.sc;
|
||||
// we store the scroller functions in an alternating sequenced Array like [element, verticalScrollFunc, horizontalScrollFunc, ...] so that we can minimize memory, maximize performance, and we also record the last position as a ".rec" property in order to revert to that after refreshing to ensure things don't shift around.
|
||||
_isViewport(element) && (element = _doc.scrollingElement || _docEl);
|
||||
|
||||
var i = _scrollers.indexOf(element),
|
||||
offset = sc === _vertical.sc ? 1 : 2;
|
||||
|
||||
!~i && (i = _scrollers.push(element) - 1);
|
||||
_scrollers[i + offset] || _addListener(element, "scroll", _onScroll); // clear the cache when a scroll occurs
|
||||
|
||||
var prev = _scrollers[i + offset],
|
||||
func = prev || (_scrollers[i + offset] = _scrollCacheFunc(_getProxyProp(element, s), true) || (_isViewport(element) ? sc : _scrollCacheFunc(function (value) {
|
||||
return arguments.length ? element[s] = value : element[s];
|
||||
})));
|
||||
func.target = element;
|
||||
prev || (func.smooth = gsap.getProperty(element, "scrollBehavior") === "smooth"); // only set it the first time (don't reset every time a scrollFunc is requested because perhaps it happens during a refresh() when it's disabled in ScrollTrigger.
|
||||
|
||||
return func;
|
||||
},
|
||||
_getVelocityProp = function _getVelocityProp(value, minTimeRefresh, useDelta) {
|
||||
var v1 = value,
|
||||
v2 = value,
|
||||
t1 = _getTime(),
|
||||
t2 = t1,
|
||||
min = minTimeRefresh || 50,
|
||||
dropToZeroTime = Math.max(500, min * 3),
|
||||
update = function update(value, force) {
|
||||
var t = _getTime();
|
||||
|
||||
if (force || t - t1 > min) {
|
||||
v2 = v1;
|
||||
v1 = value;
|
||||
t2 = t1;
|
||||
t1 = t;
|
||||
} else if (useDelta) {
|
||||
v1 += value;
|
||||
} else {
|
||||
// not totally necessary, but makes it a bit more accurate by adjusting the v1 value according to the new slope. This way we're not just ignoring the incoming data. Removing for now because it doesn't seem to make much practical difference and it's probably not worth the kb.
|
||||
v1 = v2 + (value - v2) / (t - t2) * (t1 - t2);
|
||||
}
|
||||
},
|
||||
reset = function reset() {
|
||||
v2 = v1 = useDelta ? 0 : v1;
|
||||
t2 = t1 = 0;
|
||||
},
|
||||
getVelocity = function getVelocity(latestValue) {
|
||||
var tOld = t2,
|
||||
vOld = v2,
|
||||
t = _getTime();
|
||||
|
||||
(latestValue || latestValue === 0) && latestValue !== v1 && update(latestValue);
|
||||
return t1 === t2 || t - t2 > dropToZeroTime ? 0 : (v1 + (useDelta ? vOld : -vOld)) / ((useDelta ? t : t1) - tOld) * 1000;
|
||||
};
|
||||
|
||||
return {
|
||||
update: update,
|
||||
reset: reset,
|
||||
getVelocity: getVelocity
|
||||
};
|
||||
},
|
||||
_getEvent = function _getEvent(e, preventDefault) {
|
||||
preventDefault && !e._gsapAllow && e.preventDefault();
|
||||
return e.changedTouches ? e.changedTouches[0] : e;
|
||||
},
|
||||
_getAbsoluteMax = function _getAbsoluteMax(a) {
|
||||
var max = Math.max.apply(Math, a),
|
||||
min = Math.min.apply(Math, a);
|
||||
return Math.abs(max) >= Math.abs(min) ? max : min;
|
||||
},
|
||||
_setScrollTrigger = function _setScrollTrigger() {
|
||||
ScrollTrigger = gsap.core.globals().ScrollTrigger;
|
||||
ScrollTrigger && ScrollTrigger.core && _integrate();
|
||||
},
|
||||
_initCore = function _initCore(core) {
|
||||
gsap = core || _getGSAP();
|
||||
|
||||
if (!_coreInitted && gsap && typeof document !== "undefined" && document.body) {
|
||||
_win = window;
|
||||
_doc = document;
|
||||
_docEl = _doc.documentElement;
|
||||
_body = _doc.body;
|
||||
_root = [_win, _doc, _docEl, _body];
|
||||
_clamp = gsap.utils.clamp;
|
||||
|
||||
_context = gsap.core.context || function () {};
|
||||
|
||||
_pointerType = "onpointerenter" in _body ? "pointer" : "mouse"; // isTouch is 0 if no touch, 1 if ONLY touch, and 2 if it can accommodate touch but also other types like mouse/pointer.
|
||||
|
||||
_isTouch = Observer.isTouch = _win.matchMedia && _win.matchMedia("(hover: none), (pointer: coarse)").matches ? 1 : "ontouchstart" in _win || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0 ? 2 : 0;
|
||||
_eventTypes = Observer.eventTypes = ("ontouchstart" in _docEl ? "touchstart,touchmove,touchcancel,touchend" : !("onpointerdown" in _docEl) ? "mousedown,mousemove,mouseup,mouseup" : "pointerdown,pointermove,pointercancel,pointerup").split(",");
|
||||
setTimeout(function () {
|
||||
return _startup = 0;
|
||||
}, 500);
|
||||
|
||||
_setScrollTrigger();
|
||||
|
||||
_coreInitted = 1;
|
||||
}
|
||||
|
||||
return _coreInitted;
|
||||
};
|
||||
|
||||
_horizontal.op = _vertical;
|
||||
_scrollers.cache = 0;
|
||||
export var Observer = /*#__PURE__*/function () {
|
||||
function Observer(vars) {
|
||||
this.init(vars);
|
||||
}
|
||||
|
||||
var _proto = Observer.prototype;
|
||||
|
||||
_proto.init = function init(vars) {
|
||||
_coreInitted || _initCore(gsap) || console.warn("Please gsap.registerPlugin(Observer)");
|
||||
ScrollTrigger || _setScrollTrigger();
|
||||
var tolerance = vars.tolerance,
|
||||
dragMinimum = vars.dragMinimum,
|
||||
type = vars.type,
|
||||
target = vars.target,
|
||||
lineHeight = vars.lineHeight,
|
||||
debounce = vars.debounce,
|
||||
preventDefault = vars.preventDefault,
|
||||
onStop = vars.onStop,
|
||||
onStopDelay = vars.onStopDelay,
|
||||
ignore = vars.ignore,
|
||||
wheelSpeed = vars.wheelSpeed,
|
||||
event = vars.event,
|
||||
onDragStart = vars.onDragStart,
|
||||
onDragEnd = vars.onDragEnd,
|
||||
onDrag = vars.onDrag,
|
||||
onPress = vars.onPress,
|
||||
onRelease = vars.onRelease,
|
||||
onRight = vars.onRight,
|
||||
onLeft = vars.onLeft,
|
||||
onUp = vars.onUp,
|
||||
onDown = vars.onDown,
|
||||
onChangeX = vars.onChangeX,
|
||||
onChangeY = vars.onChangeY,
|
||||
onChange = vars.onChange,
|
||||
onToggleX = vars.onToggleX,
|
||||
onToggleY = vars.onToggleY,
|
||||
onHover = vars.onHover,
|
||||
onHoverEnd = vars.onHoverEnd,
|
||||
onMove = vars.onMove,
|
||||
ignoreCheck = vars.ignoreCheck,
|
||||
isNormalizer = vars.isNormalizer,
|
||||
onGestureStart = vars.onGestureStart,
|
||||
onGestureEnd = vars.onGestureEnd,
|
||||
onWheel = vars.onWheel,
|
||||
onEnable = vars.onEnable,
|
||||
onDisable = vars.onDisable,
|
||||
onClick = vars.onClick,
|
||||
scrollSpeed = vars.scrollSpeed,
|
||||
capture = vars.capture,
|
||||
allowClicks = vars.allowClicks,
|
||||
lockAxis = vars.lockAxis,
|
||||
onLockAxis = vars.onLockAxis;
|
||||
this.target = target = _getTarget(target) || _docEl;
|
||||
this.vars = vars;
|
||||
ignore && (ignore = gsap.utils.toArray(ignore));
|
||||
tolerance = tolerance || 1e-9;
|
||||
dragMinimum = dragMinimum || 0;
|
||||
wheelSpeed = wheelSpeed || 1;
|
||||
scrollSpeed = scrollSpeed || 1;
|
||||
type = type || "wheel,touch,pointer";
|
||||
debounce = debounce !== false;
|
||||
lineHeight || (lineHeight = parseFloat(_win.getComputedStyle(_body).lineHeight) || 22); // note: browser may report "normal", so default to 22.
|
||||
|
||||
var id,
|
||||
onStopDelayedCall,
|
||||
dragged,
|
||||
moved,
|
||||
wheeled,
|
||||
locked,
|
||||
axis,
|
||||
self = this,
|
||||
prevDeltaX = 0,
|
||||
prevDeltaY = 0,
|
||||
passive = vars.passive || !preventDefault && vars.passive !== false,
|
||||
scrollFuncX = _getScrollFunc(target, _horizontal),
|
||||
scrollFuncY = _getScrollFunc(target, _vertical),
|
||||
scrollX = scrollFuncX(),
|
||||
scrollY = scrollFuncY(),
|
||||
limitToTouch = ~type.indexOf("touch") && !~type.indexOf("pointer") && _eventTypes[0] === "pointerdown",
|
||||
// for devices that accommodate mouse events and touch events, we need to distinguish.
|
||||
isViewport = _isViewport(target),
|
||||
ownerDoc = target.ownerDocument || _doc,
|
||||
deltaX = [0, 0, 0],
|
||||
// wheel, scroll, pointer/touch
|
||||
deltaY = [0, 0, 0],
|
||||
onClickTime = 0,
|
||||
clickCapture = function clickCapture() {
|
||||
return onClickTime = _getTime();
|
||||
},
|
||||
_ignoreCheck = function _ignoreCheck(e, isPointerOrTouch) {
|
||||
return (self.event = e) && ignore && _isWithin(e.target, ignore) || isPointerOrTouch && limitToTouch && e.pointerType !== "touch" || ignoreCheck && ignoreCheck(e, isPointerOrTouch);
|
||||
},
|
||||
onStopFunc = function onStopFunc() {
|
||||
self._vx.reset();
|
||||
|
||||
self._vy.reset();
|
||||
|
||||
onStopDelayedCall.pause();
|
||||
onStop && onStop(self);
|
||||
},
|
||||
update = function update() {
|
||||
var dx = self.deltaX = _getAbsoluteMax(deltaX),
|
||||
dy = self.deltaY = _getAbsoluteMax(deltaY),
|
||||
changedX = Math.abs(dx) >= tolerance,
|
||||
changedY = Math.abs(dy) >= tolerance;
|
||||
|
||||
onChange && (changedX || changedY) && onChange(self, dx, dy, deltaX, deltaY); // in ScrollTrigger.normalizeScroll(), we need to know if it was touch/pointer so we need access to the deltaX/deltaY Arrays before we clear them out.
|
||||
|
||||
if (changedX) {
|
||||
onRight && self.deltaX > 0 && onRight(self);
|
||||
onLeft && self.deltaX < 0 && onLeft(self);
|
||||
onChangeX && onChangeX(self);
|
||||
onToggleX && self.deltaX < 0 !== prevDeltaX < 0 && onToggleX(self);
|
||||
prevDeltaX = self.deltaX;
|
||||
deltaX[0] = deltaX[1] = deltaX[2] = 0;
|
||||
}
|
||||
|
||||
if (changedY) {
|
||||
onDown && self.deltaY > 0 && onDown(self);
|
||||
onUp && self.deltaY < 0 && onUp(self);
|
||||
onChangeY && onChangeY(self);
|
||||
onToggleY && self.deltaY < 0 !== prevDeltaY < 0 && onToggleY(self);
|
||||
prevDeltaY = self.deltaY;
|
||||
deltaY[0] = deltaY[1] = deltaY[2] = 0;
|
||||
}
|
||||
|
||||
if (moved || dragged) {
|
||||
onMove && onMove(self);
|
||||
|
||||
if (dragged) {
|
||||
onDragStart && dragged === 1 && onDragStart(self);
|
||||
onDrag && onDrag(self);
|
||||
dragged = 0;
|
||||
}
|
||||
|
||||
moved = false;
|
||||
}
|
||||
|
||||
locked && !(locked = false) && onLockAxis && onLockAxis(self);
|
||||
|
||||
if (wheeled) {
|
||||
onWheel(self);
|
||||
wheeled = false;
|
||||
}
|
||||
|
||||
id = 0;
|
||||
},
|
||||
onDelta = function onDelta(x, y, index) {
|
||||
deltaX[index] += x;
|
||||
deltaY[index] += y;
|
||||
|
||||
self._vx.update(x);
|
||||
|
||||
self._vy.update(y);
|
||||
|
||||
debounce ? id || (id = requestAnimationFrame(update)) : update();
|
||||
},
|
||||
onTouchOrPointerDelta = function onTouchOrPointerDelta(x, y) {
|
||||
if (lockAxis && !axis) {
|
||||
self.axis = axis = Math.abs(x) > Math.abs(y) ? "x" : "y";
|
||||
locked = true;
|
||||
}
|
||||
|
||||
if (axis !== "y") {
|
||||
deltaX[2] += x;
|
||||
|
||||
self._vx.update(x, true); // update the velocity as frequently as possible instead of in the debounced function so that very quick touch-scrolls (flicks) feel natural. If it's the mouse/touch/pointer, force it so that we get snappy/accurate momentum scroll.
|
||||
|
||||
}
|
||||
|
||||
if (axis !== "x") {
|
||||
deltaY[2] += y;
|
||||
|
||||
self._vy.update(y, true);
|
||||
}
|
||||
|
||||
debounce ? id || (id = requestAnimationFrame(update)) : update();
|
||||
},
|
||||
_onDrag = function _onDrag(e) {
|
||||
if (_ignoreCheck(e, 1)) {
|
||||
return;
|
||||
}
|
||||
|
||||
e = _getEvent(e, preventDefault);
|
||||
var x = e.clientX,
|
||||
y = e.clientY,
|
||||
dx = x - self.x,
|
||||
dy = y - self.y,
|
||||
isDragging = self.isDragging;
|
||||
self.x = x;
|
||||
self.y = y;
|
||||
|
||||
if (isDragging || (dx || dy) && (Math.abs(self.startX - x) >= dragMinimum || Math.abs(self.startY - y) >= dragMinimum)) {
|
||||
dragged || (dragged = isDragging ? 2 : 1); // dragged: 0 = not dragging, 1 = first drag, 2 = normal drag
|
||||
|
||||
isDragging || (self.isDragging = true);
|
||||
onTouchOrPointerDelta(dx, dy);
|
||||
}
|
||||
},
|
||||
_onPress = self.onPress = function (e) {
|
||||
if (_ignoreCheck(e, 1) || e && e.button) {
|
||||
return;
|
||||
}
|
||||
|
||||
self.axis = axis = null;
|
||||
onStopDelayedCall.pause();
|
||||
self.isPressed = true;
|
||||
e = _getEvent(e); // note: may need to preventDefault(?) Won't side-scroll on iOS Safari if we do, though.
|
||||
|
||||
prevDeltaX = prevDeltaY = 0;
|
||||
self.startX = self.x = e.clientX;
|
||||
self.startY = self.y = e.clientY;
|
||||
|
||||
self._vx.reset(); // otherwise the t2 may be stale if the user touches and flicks super fast and releases in less than 2 requestAnimationFrame ticks, causing velocity to be 0.
|
||||
|
||||
|
||||
self._vy.reset();
|
||||
|
||||
_addListener(isNormalizer ? target : ownerDoc, _eventTypes[1], _onDrag, passive, true);
|
||||
|
||||
self.deltaX = self.deltaY = 0;
|
||||
onPress && onPress(self);
|
||||
},
|
||||
_onRelease = self.onRelease = function (e) {
|
||||
if (_ignoreCheck(e, 1)) {
|
||||
return;
|
||||
}
|
||||
|
||||
_removeListener(isNormalizer ? target : ownerDoc, _eventTypes[1], _onDrag, true);
|
||||
|
||||
var isTrackingDrag = !isNaN(self.y - self.startY),
|
||||
wasDragging = self.isDragging,
|
||||
isDragNotClick = wasDragging && (Math.abs(self.x - self.startX) > 3 || Math.abs(self.y - self.startY) > 3),
|
||||
// some touch devices need some wiggle room in terms of sensing clicks - the finger may move a few pixels.
|
||||
eventData = _getEvent(e);
|
||||
|
||||
if (!isDragNotClick && isTrackingDrag) {
|
||||
self._vx.reset();
|
||||
|
||||
self._vy.reset(); //if (preventDefault && allowClicks && self.isPressed) { // check isPressed because in a rare edge case, the inputObserver in ScrollTrigger may stopPropagation() on the press/drag, so the onRelease may get fired without the onPress/onDrag ever getting called, thus it could trigger a click to occur on a link after scroll-dragging it.
|
||||
|
||||
|
||||
if (preventDefault && allowClicks) {
|
||||
gsap.delayedCall(0.08, function () {
|
||||
// some browsers (like Firefox) won't trust script-generated clicks, so if the user tries to click on a video to play it, for example, it simply won't work. Since a regular "click" event will most likely be generated anyway (one that has its isTrusted flag set to true), we must slightly delay our script-generated click so that the "real"/trusted one is prioritized. Remember, when there are duplicate events in quick succession, we suppress all but the first one. Some browsers don't even trigger the "real" one at all, so our synthetic one is a safety valve that ensures that no matter what, a click event does get dispatched.
|
||||
if (_getTime() - onClickTime > 300 && !e.defaultPrevented) {
|
||||
if (e.target.click) {
|
||||
//some browsers (like mobile Safari) don't properly trigger the click event
|
||||
e.target.click();
|
||||
} else if (ownerDoc.createEvent) {
|
||||
var syntheticEvent = ownerDoc.createEvent("MouseEvents");
|
||||
syntheticEvent.initMouseEvent("click", true, true, _win, 1, eventData.screenX, eventData.screenY, eventData.clientX, eventData.clientY, false, false, false, false, 0, null);
|
||||
e.target.dispatchEvent(syntheticEvent);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
self.isDragging = self.isGesturing = self.isPressed = false;
|
||||
onStop && wasDragging && !isNormalizer && onStopDelayedCall.restart(true);
|
||||
dragged && update(); // in case debouncing, we don't want onDrag to fire AFTER onDragEnd().
|
||||
|
||||
onDragEnd && wasDragging && onDragEnd(self);
|
||||
onRelease && onRelease(self, isDragNotClick);
|
||||
},
|
||||
_onGestureStart = function _onGestureStart(e) {
|
||||
return e.touches && e.touches.length > 1 && (self.isGesturing = true) && onGestureStart(e, self.isDragging);
|
||||
},
|
||||
_onGestureEnd = function _onGestureEnd() {
|
||||
return (self.isGesturing = false) || onGestureEnd(self);
|
||||
},
|
||||
onScroll = function onScroll(e) {
|
||||
if (_ignoreCheck(e)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var x = scrollFuncX(),
|
||||
y = scrollFuncY();
|
||||
onDelta((x - scrollX) * scrollSpeed, (y - scrollY) * scrollSpeed, 1);
|
||||
scrollX = x;
|
||||
scrollY = y;
|
||||
onStop && onStopDelayedCall.restart(true);
|
||||
},
|
||||
_onWheel = function _onWheel(e) {
|
||||
if (_ignoreCheck(e)) {
|
||||
return;
|
||||
}
|
||||
|
||||
e = _getEvent(e, preventDefault);
|
||||
onWheel && (wheeled = true);
|
||||
var multiplier = (e.deltaMode === 1 ? lineHeight : e.deltaMode === 2 ? _win.innerHeight : 1) * wheelSpeed;
|
||||
onDelta(e.deltaX * multiplier, e.deltaY * multiplier, 0);
|
||||
onStop && !isNormalizer && onStopDelayedCall.restart(true);
|
||||
},
|
||||
_onMove = function _onMove(e) {
|
||||
if (_ignoreCheck(e)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var x = e.clientX,
|
||||
y = e.clientY,
|
||||
dx = x - self.x,
|
||||
dy = y - self.y;
|
||||
self.x = x;
|
||||
self.y = y;
|
||||
moved = true;
|
||||
onStop && onStopDelayedCall.restart(true);
|
||||
(dx || dy) && onTouchOrPointerDelta(dx, dy);
|
||||
},
|
||||
_onHover = function _onHover(e) {
|
||||
self.event = e;
|
||||
onHover(self);
|
||||
},
|
||||
_onHoverEnd = function _onHoverEnd(e) {
|
||||
self.event = e;
|
||||
onHoverEnd(self);
|
||||
},
|
||||
_onClick = function _onClick(e) {
|
||||
return _ignoreCheck(e) || _getEvent(e, preventDefault) && onClick(self);
|
||||
};
|
||||
|
||||
onStopDelayedCall = self._dc = gsap.delayedCall(onStopDelay || 0.25, onStopFunc).pause();
|
||||
self.deltaX = self.deltaY = 0;
|
||||
self._vx = _getVelocityProp(0, 50, true);
|
||||
self._vy = _getVelocityProp(0, 50, true);
|
||||
self.scrollX = scrollFuncX;
|
||||
self.scrollY = scrollFuncY;
|
||||
self.isDragging = self.isGesturing = self.isPressed = false;
|
||||
|
||||
_context(this);
|
||||
|
||||
self.enable = function (e) {
|
||||
if (!self.isEnabled) {
|
||||
_addListener(isViewport ? ownerDoc : target, "scroll", _onScroll);
|
||||
|
||||
type.indexOf("scroll") >= 0 && _addListener(isViewport ? ownerDoc : target, "scroll", onScroll, passive, capture);
|
||||
type.indexOf("wheel") >= 0 && _addListener(target, "wheel", _onWheel, passive, capture);
|
||||
|
||||
if (type.indexOf("touch") >= 0 && _isTouch || type.indexOf("pointer") >= 0) {
|
||||
_addListener(target, _eventTypes[0], _onPress, passive, capture);
|
||||
|
||||
_addListener(ownerDoc, _eventTypes[2], _onRelease);
|
||||
|
||||
_addListener(ownerDoc, _eventTypes[3], _onRelease);
|
||||
|
||||
allowClicks && _addListener(target, "click", clickCapture, true, true);
|
||||
onClick && _addListener(target, "click", _onClick);
|
||||
onGestureStart && _addListener(ownerDoc, "gesturestart", _onGestureStart);
|
||||
onGestureEnd && _addListener(ownerDoc, "gestureend", _onGestureEnd);
|
||||
onHover && _addListener(target, _pointerType + "enter", _onHover);
|
||||
onHoverEnd && _addListener(target, _pointerType + "leave", _onHoverEnd);
|
||||
onMove && _addListener(target, _pointerType + "move", _onMove);
|
||||
}
|
||||
|
||||
self.isEnabled = true;
|
||||
self.isDragging = self.isGesturing = self.isPressed = moved = dragged = false;
|
||||
|
||||
self._vx.reset();
|
||||
|
||||
self._vy.reset();
|
||||
|
||||
scrollX = scrollFuncX();
|
||||
scrollY = scrollFuncY();
|
||||
e && e.type && _onPress(e);
|
||||
onEnable && onEnable(self);
|
||||
}
|
||||
|
||||
return self;
|
||||
};
|
||||
|
||||
self.disable = function () {
|
||||
if (self.isEnabled) {
|
||||
// only remove the _onScroll listener if there aren't any others that rely on the functionality.
|
||||
_observers.filter(function (o) {
|
||||
return o !== self && _isViewport(o.target);
|
||||
}).length || _removeListener(isViewport ? ownerDoc : target, "scroll", _onScroll);
|
||||
|
||||
if (self.isPressed) {
|
||||
self._vx.reset();
|
||||
|
||||
self._vy.reset();
|
||||
|
||||
_removeListener(isNormalizer ? target : ownerDoc, _eventTypes[1], _onDrag, true);
|
||||
}
|
||||
|
||||
_removeListener(isViewport ? ownerDoc : target, "scroll", onScroll, capture);
|
||||
|
||||
_removeListener(target, "wheel", _onWheel, capture);
|
||||
|
||||
_removeListener(target, _eventTypes[0], _onPress, capture);
|
||||
|
||||
_removeListener(ownerDoc, _eventTypes[2], _onRelease);
|
||||
|
||||
_removeListener(ownerDoc, _eventTypes[3], _onRelease);
|
||||
|
||||
_removeListener(target, "click", clickCapture, true);
|
||||
|
||||
_removeListener(target, "click", _onClick);
|
||||
|
||||
_removeListener(ownerDoc, "gesturestart", _onGestureStart);
|
||||
|
||||
_removeListener(ownerDoc, "gestureend", _onGestureEnd);
|
||||
|
||||
_removeListener(target, _pointerType + "enter", _onHover);
|
||||
|
||||
_removeListener(target, _pointerType + "leave", _onHoverEnd);
|
||||
|
||||
_removeListener(target, _pointerType + "move", _onMove);
|
||||
|
||||
self.isEnabled = self.isPressed = self.isDragging = false;
|
||||
onDisable && onDisable(self);
|
||||
}
|
||||
};
|
||||
|
||||
self.kill = self.revert = function () {
|
||||
self.disable();
|
||||
|
||||
var i = _observers.indexOf(self);
|
||||
|
||||
i >= 0 && _observers.splice(i, 1);
|
||||
_normalizer === self && (_normalizer = 0);
|
||||
};
|
||||
|
||||
_observers.push(self);
|
||||
|
||||
isNormalizer && _isViewport(target) && (_normalizer = self);
|
||||
self.enable(event);
|
||||
};
|
||||
|
||||
_createClass(Observer, [{
|
||||
key: "velocityX",
|
||||
get: function get() {
|
||||
return this._vx.getVelocity();
|
||||
}
|
||||
}, {
|
||||
key: "velocityY",
|
||||
get: function get() {
|
||||
return this._vy.getVelocity();
|
||||
}
|
||||
}]);
|
||||
|
||||
return Observer;
|
||||
}();
|
||||
Observer.version = "3.14.2";
|
||||
|
||||
Observer.create = function (vars) {
|
||||
return new Observer(vars);
|
||||
};
|
||||
|
||||
Observer.register = _initCore;
|
||||
|
||||
Observer.getAll = function () {
|
||||
return _observers.slice();
|
||||
};
|
||||
|
||||
Observer.getById = function (id) {
|
||||
return _observers.filter(function (o) {
|
||||
return o.vars.id === id;
|
||||
})[0];
|
||||
};
|
||||
|
||||
_getGSAP() && gsap.registerPlugin(Observer);
|
||||
export { Observer as default, _isViewport, _scrollers, _getScrollFunc, _getProxyProp, _proxies, _getVelocityProp, _vertical, _horizontal, _getTarget };
|
||||
+173
@@ -0,0 +1,173 @@
|
||||
/*!
|
||||
* Physics2DPlugin 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
|
||||
*/
|
||||
|
||||
/* eslint-disable */
|
||||
var gsap,
|
||||
_coreInitted,
|
||||
_getUnit,
|
||||
_getStyleSaver,
|
||||
_reverting,
|
||||
_DEG2RAD = Math.PI / 180,
|
||||
_getGSAP = function _getGSAP() {
|
||||
return gsap || typeof window !== "undefined" && (gsap = window.gsap) && gsap.registerPlugin && gsap;
|
||||
},
|
||||
_round = function _round(value) {
|
||||
return Math.round(value * 10000) / 10000;
|
||||
},
|
||||
_bonusValidated = 1,
|
||||
//<name>Physics2DPlugin</name>
|
||||
_initCore = function _initCore(core) {
|
||||
gsap = core || _getGSAP();
|
||||
|
||||
if (!_coreInitted) {
|
||||
_getUnit = gsap.utils.getUnit;
|
||||
_getStyleSaver = gsap.core.getStyleSaver;
|
||||
|
||||
_reverting = gsap.core.reverting || function () {};
|
||||
|
||||
_coreInitted = 1;
|
||||
}
|
||||
};
|
||||
|
||||
var PhysicsProp = function PhysicsProp(target, p, velocity, acceleration, stepsPerTimeUnit) {
|
||||
var cache = target._gsap,
|
||||
curVal = cache.get(target, p);
|
||||
this.p = p;
|
||||
this.set = cache.set(target, p); //setter
|
||||
|
||||
this.s = this.val = parseFloat(curVal);
|
||||
this.u = _getUnit(curVal) || 0;
|
||||
this.vel = velocity || 0;
|
||||
this.v = this.vel / stepsPerTimeUnit;
|
||||
|
||||
if (acceleration || acceleration === 0) {
|
||||
this.acc = acceleration;
|
||||
this.a = this.acc / (stepsPerTimeUnit * stepsPerTimeUnit);
|
||||
} else {
|
||||
this.acc = this.a = 0;
|
||||
}
|
||||
};
|
||||
|
||||
export var Physics2DPlugin = {
|
||||
version: "3.14.2",
|
||||
name: "physics2D",
|
||||
register: _initCore,
|
||||
init: function init(target, value, tween) {
|
||||
_coreInitted || _initCore();
|
||||
var data = this,
|
||||
angle = +value.angle || 0,
|
||||
velocity = +value.velocity || 0,
|
||||
acceleration = +value.acceleration || 0,
|
||||
xProp = value.xProp || "x",
|
||||
yProp = value.yProp || "y",
|
||||
aAngle = value.accelerationAngle || value.accelerationAngle === 0 ? +value.accelerationAngle : angle;
|
||||
data.styles = _getStyleSaver && _getStyleSaver(target, value.xProp && value.xProp !== "x" ? value.xProp + "," + value.yProp : "transform");
|
||||
data.target = target;
|
||||
data.tween = tween;
|
||||
data.step = 0;
|
||||
data.sps = 30; //steps per second
|
||||
|
||||
if (value.gravity) {
|
||||
acceleration = +value.gravity;
|
||||
aAngle = 90;
|
||||
}
|
||||
|
||||
angle *= _DEG2RAD;
|
||||
aAngle *= _DEG2RAD;
|
||||
data.fr = 1 - (+value.friction || 0);
|
||||
|
||||
data._props.push(xProp, yProp);
|
||||
|
||||
data.xp = new PhysicsProp(target, xProp, Math.cos(angle) * velocity, Math.cos(aAngle) * acceleration, data.sps);
|
||||
data.yp = new PhysicsProp(target, yProp, Math.sin(angle) * velocity, Math.sin(aAngle) * acceleration, data.sps);
|
||||
data.skipX = data.skipY = 0;
|
||||
},
|
||||
render: function render(ratio, data) {
|
||||
var xp = data.xp,
|
||||
yp = data.yp,
|
||||
tween = data.tween,
|
||||
target = data.target,
|
||||
step = data.step,
|
||||
sps = data.sps,
|
||||
fr = data.fr,
|
||||
skipX = data.skipX,
|
||||
skipY = data.skipY,
|
||||
time = tween._from ? tween._dur - tween._time : tween._time,
|
||||
x,
|
||||
y,
|
||||
tt,
|
||||
steps,
|
||||
remainder,
|
||||
i;
|
||||
|
||||
if (tween._time || !_reverting()) {
|
||||
if (fr === 1) {
|
||||
tt = time * time * 0.5;
|
||||
x = xp.s + xp.vel * time + xp.acc * tt;
|
||||
y = yp.s + yp.vel * time + yp.acc * tt;
|
||||
} else {
|
||||
time *= sps;
|
||||
steps = i = (time | 0) - step;
|
||||
/*
|
||||
Note: rounding errors build up if we walk the calculations backward which we used to do like this to maximize performance:
|
||||
i = -i;
|
||||
while (i--) {
|
||||
xp.val -= xp.v;
|
||||
yp.val -= yp.v;
|
||||
xp.v /= fr;
|
||||
yp.v /= fr;
|
||||
xp.v -= xp.a;
|
||||
yp.v -= yp.a;
|
||||
}
|
||||
but now for the sake of accuracy (to ensure rewinding always goes back to EXACTLY the same spot), we force the calculations to go forward every time. So if the tween is going backward, we just start from the beginning and iterate. This is only necessary with friction.
|
||||
*/
|
||||
|
||||
if (i < 0) {
|
||||
xp.v = xp.vel / sps;
|
||||
yp.v = yp.vel / sps;
|
||||
xp.val = xp.s;
|
||||
yp.val = yp.s;
|
||||
data.step = 0;
|
||||
steps = i = time | 0;
|
||||
}
|
||||
|
||||
remainder = time % 1 * fr;
|
||||
|
||||
while (i--) {
|
||||
xp.v += xp.a;
|
||||
yp.v += yp.a;
|
||||
xp.v *= fr;
|
||||
yp.v *= fr;
|
||||
xp.val += xp.v;
|
||||
yp.val += yp.v;
|
||||
}
|
||||
|
||||
x = xp.val + xp.v * remainder;
|
||||
y = yp.val + yp.v * remainder;
|
||||
data.step += steps;
|
||||
}
|
||||
|
||||
skipX || xp.set(target, xp.p, _round(x) + xp.u);
|
||||
skipY || yp.set(target, yp.p, _round(y) + yp.u);
|
||||
} else {
|
||||
data.styles.revert();
|
||||
}
|
||||
},
|
||||
kill: function kill(property) {
|
||||
if (this.xp.p === property) {
|
||||
this.skipX = 1;
|
||||
}
|
||||
|
||||
if (this.yp.p === property) {
|
||||
this.skipY = 1;
|
||||
}
|
||||
}
|
||||
};
|
||||
_getGSAP() && gsap.registerPlugin(Physics2DPlugin);
|
||||
export { Physics2DPlugin as default };
|
||||
+174
@@ -0,0 +1,174 @@
|
||||
/*!
|
||||
* PhysicsPropsPlugin 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
|
||||
*/
|
||||
|
||||
/* eslint-disable */
|
||||
var gsap,
|
||||
_coreInitted,
|
||||
_getUnit,
|
||||
_getStyleSaver,
|
||||
_reverting,
|
||||
_getGSAP = function _getGSAP() {
|
||||
return gsap || typeof window !== "undefined" && (gsap = window.gsap) && gsap.registerPlugin && gsap;
|
||||
},
|
||||
_round = function _round(value) {
|
||||
return Math.round(value * 10000) / 10000;
|
||||
},
|
||||
_bonusValidated = 1,
|
||||
//<name>PhysicsPropsPlugin</name>
|
||||
_initCore = function _initCore(core) {
|
||||
gsap = core || _getGSAP();
|
||||
|
||||
if (!_coreInitted) {
|
||||
_getUnit = gsap.utils.getUnit;
|
||||
_getStyleSaver = gsap.core.getStyleSaver;
|
||||
|
||||
_reverting = gsap.core.reverting || function () {};
|
||||
|
||||
_coreInitted = 1;
|
||||
}
|
||||
};
|
||||
|
||||
var PhysicsProp = function PhysicsProp(target, p, velocity, acceleration, friction, stepsPerTimeUnit) {
|
||||
var cache = target._gsap,
|
||||
curVal = cache.get(target, p);
|
||||
this.p = p;
|
||||
this.set = cache.set(target, p); //setter
|
||||
|
||||
this.s = this.val = parseFloat(curVal);
|
||||
this.u = _getUnit(curVal) || 0;
|
||||
this.vel = velocity || 0;
|
||||
this.v = this.vel / stepsPerTimeUnit;
|
||||
|
||||
if (acceleration || acceleration === 0) {
|
||||
this.acc = acceleration;
|
||||
this.a = this.acc / (stepsPerTimeUnit * stepsPerTimeUnit);
|
||||
} else {
|
||||
this.acc = this.a = 0;
|
||||
}
|
||||
|
||||
this.fr = 1 - (friction || 0);
|
||||
};
|
||||
|
||||
export var PhysicsPropsPlugin = {
|
||||
version: "3.14.2",
|
||||
name: "physicsProps",
|
||||
register: _initCore,
|
||||
init: function init(target, value, tween) {
|
||||
_coreInitted || _initCore();
|
||||
var data = this,
|
||||
p;
|
||||
data.styles = _getStyleSaver && _getStyleSaver(target);
|
||||
data.target = target;
|
||||
data.tween = tween;
|
||||
data.step = 0;
|
||||
data.sps = 30; //steps per second
|
||||
|
||||
data.vProps = [];
|
||||
|
||||
for (p in value) {
|
||||
var _value$p = value[p],
|
||||
velocity = _value$p.velocity,
|
||||
acceleration = _value$p.acceleration,
|
||||
friction = _value$p.friction;
|
||||
|
||||
if (velocity || acceleration) {
|
||||
data.vProps.push(new PhysicsProp(target, p, velocity, acceleration, friction, data.sps));
|
||||
|
||||
data._props.push(p);
|
||||
|
||||
_getStyleSaver && data.styles.save(p);
|
||||
friction && (data.hasFr = 1);
|
||||
}
|
||||
}
|
||||
},
|
||||
render: function render(ratio, data) {
|
||||
var vProps = data.vProps,
|
||||
tween = data.tween,
|
||||
target = data.target,
|
||||
step = data.step,
|
||||
hasFr = data.hasFr,
|
||||
sps = data.sps,
|
||||
i = vProps.length,
|
||||
time = tween._from ? tween._dur - tween._time : tween._time,
|
||||
curProp,
|
||||
steps,
|
||||
remainder,
|
||||
j,
|
||||
tt;
|
||||
|
||||
if (tween._time || !_reverting()) {
|
||||
if (hasFr) {
|
||||
time *= sps;
|
||||
steps = (time | 0) - step;
|
||||
/*
|
||||
Note: rounding errors build up if we walk the calculations backward which we used to do like this to maximize performance:
|
||||
while (i--) {
|
||||
curProp = vProps[i];
|
||||
j = -steps;
|
||||
while (j--) {
|
||||
curProp.val -= curProp.v;
|
||||
curProp.v /= curProp.fr;
|
||||
curProp.v -= curProp.a;
|
||||
}
|
||||
curProp.set(target, curProp.p, _round(curProp.val + (curProp.v * remainder * curProp.fr)) + curProp.u);
|
||||
}
|
||||
but now for the sake of accuracy (to ensure rewinding always goes back to EXACTLY the same spot), we force the calculations to go forward every time. So if the tween is going backward, we just start from the beginning and iterate. This is only necessary with friction.
|
||||
*/
|
||||
|
||||
if (steps < 0) {
|
||||
while (i--) {
|
||||
curProp = vProps[i];
|
||||
curProp.v = curProp.vel / sps;
|
||||
curProp.val = curProp.s;
|
||||
}
|
||||
|
||||
i = vProps.length;
|
||||
data.step = step = 0;
|
||||
steps = time | 0;
|
||||
}
|
||||
|
||||
remainder = time % 1;
|
||||
|
||||
while (i--) {
|
||||
curProp = vProps[i];
|
||||
j = steps;
|
||||
|
||||
while (j--) {
|
||||
curProp.v += curProp.a;
|
||||
curProp.v *= curProp.fr;
|
||||
curProp.val += curProp.v;
|
||||
}
|
||||
|
||||
curProp.set(target, curProp.p, _round(curProp.val + curProp.v * remainder * curProp.fr) + curProp.u);
|
||||
}
|
||||
|
||||
data.step += steps;
|
||||
} else {
|
||||
tt = time * time * 0.5;
|
||||
|
||||
while (i--) {
|
||||
curProp = vProps[i];
|
||||
curProp.set(target, curProp.p, _round(curProp.s + curProp.vel * time + curProp.acc * tt) + curProp.u);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
data.styles.revert();
|
||||
}
|
||||
},
|
||||
kill: function kill(property) {
|
||||
var vProps = this.vProps,
|
||||
i = vProps.length;
|
||||
|
||||
while (i--) {
|
||||
vProps[i].p === property && vProps.splice(i, 1);
|
||||
}
|
||||
}
|
||||
};
|
||||
_getGSAP() && gsap.registerPlugin(PhysicsPropsPlugin);
|
||||
export { PhysicsPropsPlugin as default };
|
||||
+473
@@ -0,0 +1,473 @@
|
||||
/*!
|
||||
* PixiPlugin 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
|
||||
*/
|
||||
|
||||
/* eslint-disable */
|
||||
var gsap,
|
||||
_splitColor,
|
||||
_coreInitted,
|
||||
_PIXI,
|
||||
PropTween,
|
||||
_getSetter,
|
||||
_isV4,
|
||||
_isV8Plus,
|
||||
_windowExists = function _windowExists() {
|
||||
return typeof window !== "undefined";
|
||||
},
|
||||
_getGSAP = function _getGSAP() {
|
||||
return gsap || _windowExists() && (gsap = window.gsap) && gsap.registerPlugin && gsap;
|
||||
},
|
||||
_isFunction = function _isFunction(value) {
|
||||
return typeof value === "function";
|
||||
},
|
||||
_warn = function _warn(message) {
|
||||
return console.warn(message);
|
||||
},
|
||||
_idMatrix = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0],
|
||||
_lumR = 0.212671,
|
||||
_lumG = 0.715160,
|
||||
_lumB = 0.072169,
|
||||
_filterClass = function _filterClass(name) {
|
||||
return _isFunction(_PIXI[name]) ? _PIXI[name] : _PIXI.filters[name];
|
||||
},
|
||||
// in PIXI 7.1, filters moved from PIXI.filters to just PIXI
|
||||
_applyMatrix = function _applyMatrix(m, m2) {
|
||||
var temp = [],
|
||||
i = 0,
|
||||
z = 0,
|
||||
y,
|
||||
x;
|
||||
|
||||
for (y = 0; y < 4; y++) {
|
||||
for (x = 0; x < 5; x++) {
|
||||
z = x === 4 ? m[i + 4] : 0;
|
||||
temp[i + x] = m[i] * m2[x] + m[i + 1] * m2[x + 5] + m[i + 2] * m2[x + 10] + m[i + 3] * m2[x + 15] + z;
|
||||
}
|
||||
|
||||
i += 5;
|
||||
}
|
||||
|
||||
return temp;
|
||||
},
|
||||
_setSaturation = function _setSaturation(m, n) {
|
||||
var inv = 1 - n,
|
||||
r = inv * _lumR,
|
||||
g = inv * _lumG,
|
||||
b = inv * _lumB;
|
||||
return _applyMatrix([r + n, g, b, 0, 0, r, g + n, b, 0, 0, r, g, b + n, 0, 0, 0, 0, 0, 1, 0], m);
|
||||
},
|
||||
_colorize = function _colorize(m, color, amount) {
|
||||
var c = _splitColor(color),
|
||||
r = c[0] / 255,
|
||||
g = c[1] / 255,
|
||||
b = c[2] / 255,
|
||||
inv = 1 - amount;
|
||||
|
||||
return _applyMatrix([inv + amount * r * _lumR, amount * r * _lumG, amount * r * _lumB, 0, 0, amount * g * _lumR, inv + amount * g * _lumG, amount * g * _lumB, 0, 0, amount * b * _lumR, amount * b * _lumG, inv + amount * b * _lumB, 0, 0, 0, 0, 0, 1, 0], m);
|
||||
},
|
||||
_setHue = function _setHue(m, n) {
|
||||
n *= Math.PI / 180;
|
||||
var c = Math.cos(n),
|
||||
s = Math.sin(n);
|
||||
return _applyMatrix([_lumR + c * (1 - _lumR) + s * -_lumR, _lumG + c * -_lumG + s * -_lumG, _lumB + c * -_lumB + s * (1 - _lumB), 0, 0, _lumR + c * -_lumR + s * 0.143, _lumG + c * (1 - _lumG) + s * 0.14, _lumB + c * -_lumB + s * -0.283, 0, 0, _lumR + c * -_lumR + s * -(1 - _lumR), _lumG + c * -_lumG + s * _lumG, _lumB + c * (1 - _lumB) + s * _lumB, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1], m);
|
||||
},
|
||||
_setContrast = function _setContrast(m, n) {
|
||||
return _applyMatrix([n, 0, 0, 0, 0.5 * (1 - n), 0, n, 0, 0, 0.5 * (1 - n), 0, 0, n, 0, 0.5 * (1 - n), 0, 0, 0, 1, 0], m);
|
||||
},
|
||||
_getFilter = function _getFilter(target, type) {
|
||||
var filterClass = _filterClass(type),
|
||||
filters = target.filters || [],
|
||||
i = filters.length,
|
||||
filter;
|
||||
|
||||
filterClass || _warn(type + " not found. PixiPlugin.registerPIXI(PIXI)");
|
||||
|
||||
while (--i > -1) {
|
||||
if (filters[i] instanceof filterClass) {
|
||||
return filters[i];
|
||||
}
|
||||
}
|
||||
|
||||
filter = new filterClass();
|
||||
|
||||
if (type === "BlurFilter") {
|
||||
if (_isV8Plus) {
|
||||
filter.strength = 0;
|
||||
} else {
|
||||
filter.blur = 0;
|
||||
}
|
||||
}
|
||||
|
||||
target.filters = [].concat(filters, [filter]);
|
||||
return filter;
|
||||
},
|
||||
_addColorMatrixFilterCacheTween = function _addColorMatrixFilterCacheTween(p, plugin, cache, vars) {
|
||||
//we cache the ColorMatrixFilter components in a _gsColorMatrixFilter object attached to the target object so that it's easy to grab the current value at any time.
|
||||
plugin.add(cache, p, cache[p], vars[p]);
|
||||
|
||||
plugin._props.push(p);
|
||||
},
|
||||
_applyBrightnessToMatrix = function _applyBrightnessToMatrix(brightness, matrix) {
|
||||
var filterClass = _filterClass("ColorMatrixFilter"),
|
||||
temp = new filterClass();
|
||||
|
||||
temp.matrix = matrix;
|
||||
temp.brightness(brightness, true);
|
||||
return temp.matrix;
|
||||
},
|
||||
_copy = function _copy(obj) {
|
||||
var copy = {},
|
||||
p;
|
||||
|
||||
for (p in obj) {
|
||||
copy[p] = obj[p];
|
||||
}
|
||||
|
||||
return copy;
|
||||
},
|
||||
_CMFdefaults = {
|
||||
contrast: 1,
|
||||
saturation: 1,
|
||||
colorizeAmount: 0,
|
||||
colorize: "rgb(255,255,255)",
|
||||
hue: 0,
|
||||
brightness: 1
|
||||
},
|
||||
_parseColorMatrixFilter = function _parseColorMatrixFilter(target, v, pg) {
|
||||
var filter = _getFilter(target, "ColorMatrixFilter"),
|
||||
cache = target._gsColorMatrixFilter = target._gsColorMatrixFilter || _copy(_CMFdefaults),
|
||||
combine = v.combineCMF && !("colorMatrixFilter" in v && !v.colorMatrixFilter),
|
||||
i,
|
||||
matrix,
|
||||
startMatrix;
|
||||
|
||||
startMatrix = filter.matrix;
|
||||
|
||||
if (v.resolution) {
|
||||
filter.resolution = v.resolution;
|
||||
}
|
||||
|
||||
if (v.matrix && v.matrix.length === startMatrix.length) {
|
||||
matrix = v.matrix;
|
||||
|
||||
if (cache.contrast !== 1) {
|
||||
_addColorMatrixFilterCacheTween("contrast", pg, cache, _CMFdefaults);
|
||||
}
|
||||
|
||||
if (cache.hue) {
|
||||
_addColorMatrixFilterCacheTween("hue", pg, cache, _CMFdefaults);
|
||||
}
|
||||
|
||||
if (cache.brightness !== 1) {
|
||||
_addColorMatrixFilterCacheTween("brightness", pg, cache, _CMFdefaults);
|
||||
}
|
||||
|
||||
if (cache.colorizeAmount) {
|
||||
_addColorMatrixFilterCacheTween("colorize", pg, cache, _CMFdefaults);
|
||||
|
||||
_addColorMatrixFilterCacheTween("colorizeAmount", pg, cache, _CMFdefaults);
|
||||
}
|
||||
|
||||
if (cache.saturation !== 1) {
|
||||
_addColorMatrixFilterCacheTween("saturation", pg, cache, _CMFdefaults);
|
||||
}
|
||||
} else {
|
||||
matrix = _idMatrix.slice();
|
||||
|
||||
if (v.contrast != null) {
|
||||
matrix = _setContrast(matrix, +v.contrast);
|
||||
|
||||
_addColorMatrixFilterCacheTween("contrast", pg, cache, v);
|
||||
} else if (cache.contrast !== 1) {
|
||||
if (combine) {
|
||||
matrix = _setContrast(matrix, cache.contrast);
|
||||
} else {
|
||||
_addColorMatrixFilterCacheTween("contrast", pg, cache, _CMFdefaults);
|
||||
}
|
||||
}
|
||||
|
||||
if (v.hue != null) {
|
||||
matrix = _setHue(matrix, +v.hue);
|
||||
|
||||
_addColorMatrixFilterCacheTween("hue", pg, cache, v);
|
||||
} else if (cache.hue) {
|
||||
if (combine) {
|
||||
matrix = _setHue(matrix, cache.hue);
|
||||
} else {
|
||||
_addColorMatrixFilterCacheTween("hue", pg, cache, _CMFdefaults);
|
||||
}
|
||||
}
|
||||
|
||||
if (v.brightness != null) {
|
||||
matrix = _applyBrightnessToMatrix(+v.brightness, matrix);
|
||||
|
||||
_addColorMatrixFilterCacheTween("brightness", pg, cache, v);
|
||||
} else if (cache.brightness !== 1) {
|
||||
if (combine) {
|
||||
matrix = _applyBrightnessToMatrix(cache.brightness, matrix);
|
||||
} else {
|
||||
_addColorMatrixFilterCacheTween("brightness", pg, cache, _CMFdefaults);
|
||||
}
|
||||
}
|
||||
|
||||
if (v.colorize != null) {
|
||||
v.colorizeAmount = "colorizeAmount" in v ? +v.colorizeAmount : 1;
|
||||
matrix = _colorize(matrix, v.colorize, v.colorizeAmount);
|
||||
|
||||
_addColorMatrixFilterCacheTween("colorize", pg, cache, v);
|
||||
|
||||
_addColorMatrixFilterCacheTween("colorizeAmount", pg, cache, v);
|
||||
} else if (cache.colorizeAmount) {
|
||||
if (combine) {
|
||||
matrix = _colorize(matrix, cache.colorize, cache.colorizeAmount);
|
||||
} else {
|
||||
_addColorMatrixFilterCacheTween("colorize", pg, cache, _CMFdefaults);
|
||||
|
||||
_addColorMatrixFilterCacheTween("colorizeAmount", pg, cache, _CMFdefaults);
|
||||
}
|
||||
}
|
||||
|
||||
if (v.saturation != null) {
|
||||
matrix = _setSaturation(matrix, +v.saturation);
|
||||
|
||||
_addColorMatrixFilterCacheTween("saturation", pg, cache, v);
|
||||
} else if (cache.saturation !== 1) {
|
||||
if (combine) {
|
||||
matrix = _setSaturation(matrix, cache.saturation);
|
||||
} else {
|
||||
_addColorMatrixFilterCacheTween("saturation", pg, cache, _CMFdefaults);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
i = matrix.length;
|
||||
|
||||
while (--i > -1) {
|
||||
if (matrix[i] !== startMatrix[i]) {
|
||||
pg.add(startMatrix, i, startMatrix[i], matrix[i], "colorMatrixFilter");
|
||||
}
|
||||
}
|
||||
|
||||
pg._props.push("colorMatrixFilter");
|
||||
},
|
||||
_renderColor = function _renderColor(ratio, _ref) {
|
||||
var t = _ref.t,
|
||||
p = _ref.p,
|
||||
color = _ref.color,
|
||||
set = _ref.set;
|
||||
set(t, p, color[0] << 16 | color[1] << 8 | color[2]);
|
||||
},
|
||||
_renderDirtyCache = function _renderDirtyCache(ratio, _ref2) {
|
||||
var g = _ref2.g;
|
||||
|
||||
if (_isV8Plus) {
|
||||
g.fill();
|
||||
g.stroke();
|
||||
} else if (g) {
|
||||
// in order for PixiJS to actually redraw GraphicsData, we've gotta increment the "dirty" and "clearDirty" values. If we don't do this, the values will be tween properly, but not rendered.
|
||||
g.dirty++;
|
||||
g.clearDirty++;
|
||||
}
|
||||
},
|
||||
_renderAutoAlpha = function _renderAutoAlpha(ratio, data) {
|
||||
data.t.visible = !!data.t.alpha;
|
||||
},
|
||||
_addColorTween = function _addColorTween(target, p, value, plugin) {
|
||||
var currentValue = target[p],
|
||||
startColor = _splitColor(_isFunction(currentValue) ? target[p.indexOf("set") || !_isFunction(target["get" + p.substr(3)]) ? p : "get" + p.substr(3)]() : currentValue),
|
||||
endColor = _splitColor(value);
|
||||
|
||||
plugin._pt = new PropTween(plugin._pt, target, p, 0, 0, _renderColor, {
|
||||
t: target,
|
||||
p: p,
|
||||
color: startColor,
|
||||
set: _getSetter(target, p)
|
||||
});
|
||||
plugin.add(startColor, 0, startColor[0], endColor[0]);
|
||||
plugin.add(startColor, 1, startColor[1], endColor[1]);
|
||||
plugin.add(startColor, 2, startColor[2], endColor[2]);
|
||||
},
|
||||
_colorProps = {
|
||||
tint: 1,
|
||||
lineColor: 1,
|
||||
fillColor: 1,
|
||||
strokeColor: 1
|
||||
},
|
||||
_xyContexts = "position,scale,skew,pivot,anchor,tilePosition,tileScale".split(","),
|
||||
_contexts = {
|
||||
x: "position",
|
||||
y: "position",
|
||||
tileX: "tilePosition",
|
||||
tileY: "tilePosition"
|
||||
},
|
||||
_colorMatrixFilterProps = {
|
||||
colorMatrixFilter: 1,
|
||||
saturation: 1,
|
||||
contrast: 1,
|
||||
hue: 1,
|
||||
colorize: 1,
|
||||
colorizeAmount: 1,
|
||||
brightness: 1,
|
||||
combineCMF: 1
|
||||
},
|
||||
_DEG2RAD = Math.PI / 180,
|
||||
_isString = function _isString(value) {
|
||||
return typeof value === "string";
|
||||
},
|
||||
_degreesToRadians = function _degreesToRadians(value) {
|
||||
return _isString(value) && value.charAt(1) === "=" ? value.substr(0, 2) + parseFloat(value.substr(2)) * _DEG2RAD : value * _DEG2RAD;
|
||||
},
|
||||
_renderPropWithEnd = function _renderPropWithEnd(ratio, data) {
|
||||
return data.set(data.t, data.p, ratio === 1 ? data.e : Math.round((data.s + data.c * ratio) * 100000) / 100000, data);
|
||||
},
|
||||
_addRotationalPropTween = function _addRotationalPropTween(plugin, target, property, startNum, endValue, radians) {
|
||||
var cap = 360 * (radians ? _DEG2RAD : 1),
|
||||
isString = _isString(endValue),
|
||||
relative = isString && endValue.charAt(1) === "=" ? +(endValue.charAt(0) + "1") : 0,
|
||||
endNum = parseFloat(relative ? endValue.substr(2) : endValue) * (radians ? _DEG2RAD : 1),
|
||||
change = relative ? endNum * relative : endNum - startNum,
|
||||
finalValue = startNum + change,
|
||||
direction,
|
||||
pt;
|
||||
|
||||
if (isString) {
|
||||
direction = endValue.split("_")[1];
|
||||
|
||||
if (direction === "short") {
|
||||
change %= cap;
|
||||
|
||||
if (change !== change % (cap / 2)) {
|
||||
change += change < 0 ? cap : -cap;
|
||||
}
|
||||
}
|
||||
|
||||
if (direction === "cw" && change < 0) {
|
||||
change = (change + cap * 1e10) % cap - ~~(change / cap) * cap;
|
||||
} else if (direction === "ccw" && change > 0) {
|
||||
change = (change - cap * 1e10) % cap - ~~(change / cap) * cap;
|
||||
}
|
||||
}
|
||||
|
||||
plugin._pt = pt = new PropTween(plugin._pt, target, property, startNum, change, _renderPropWithEnd);
|
||||
pt.e = finalValue;
|
||||
return pt;
|
||||
},
|
||||
_initCore = function _initCore() {
|
||||
if (!_coreInitted) {
|
||||
gsap = _getGSAP();
|
||||
_PIXI = _coreInitted = _PIXI || _windowExists() && window.PIXI;
|
||||
var version = _PIXI && _PIXI.VERSION && parseFloat(_PIXI.VERSION.split(".")[0]) || 0;
|
||||
_isV4 = version === 4;
|
||||
_isV8Plus = version >= 8;
|
||||
|
||||
_splitColor = function _splitColor(color) {
|
||||
return gsap.utils.splitColor((color + "").substr(0, 2) === "0x" ? "#" + color.substr(2) : color);
|
||||
}; // some colors in PIXI are reported as "0xFF4421" instead of "#FF4421".
|
||||
|
||||
}
|
||||
},
|
||||
i,
|
||||
p; //context setup...
|
||||
|
||||
|
||||
for (i = 0; i < _xyContexts.length; i++) {
|
||||
p = _xyContexts[i];
|
||||
_contexts[p + "X"] = p;
|
||||
_contexts[p + "Y"] = p;
|
||||
}
|
||||
|
||||
export var PixiPlugin = {
|
||||
version: "3.14.2",
|
||||
name: "pixi",
|
||||
register: function register(core, Plugin, propTween) {
|
||||
gsap = core;
|
||||
PropTween = propTween;
|
||||
_getSetter = Plugin.getSetter;
|
||||
|
||||
_initCore();
|
||||
},
|
||||
headless: true,
|
||||
// doesn't need window
|
||||
registerPIXI: function registerPIXI(pixi) {
|
||||
_PIXI = pixi;
|
||||
},
|
||||
init: function init(target, values, tween, index, targets) {
|
||||
_PIXI || _initCore();
|
||||
|
||||
if (!_PIXI) {
|
||||
_warn("PIXI was not found. PixiPlugin.registerPIXI(PIXI);");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
var context, axis, value, colorMatrix, filter, p, padding, i, data, subProp;
|
||||
|
||||
for (p in values) {
|
||||
context = _contexts[p];
|
||||
value = values[p];
|
||||
|
||||
if (context) {
|
||||
axis = ~p.charAt(p.length - 1).toLowerCase().indexOf("x") ? "x" : "y";
|
||||
this.add(target[context], axis, target[context][axis], context === "skew" ? _degreesToRadians(value) : value, 0, 0, 0, 0, 0, 1);
|
||||
} else if (p === "scale" || p === "anchor" || p === "pivot" || p === "tileScale") {
|
||||
this.add(target[p], "x", target[p].x, value);
|
||||
this.add(target[p], "y", target[p].y, value);
|
||||
} else if (p === "rotation" || p === "angle") {
|
||||
//PIXI expects rotation in radians, but as a convenience we let folks define it in degrees and we do the conversion.
|
||||
_addRotationalPropTween(this, target, p, target[p], value, p === "rotation");
|
||||
} else if (_colorMatrixFilterProps[p]) {
|
||||
if (!colorMatrix) {
|
||||
_parseColorMatrixFilter(target, values.colorMatrixFilter || values, this);
|
||||
|
||||
colorMatrix = true;
|
||||
}
|
||||
} else if (p === "blur" || p === "blurX" || p === "blurY" || p === "blurPadding") {
|
||||
filter = _getFilter(target, "BlurFilter");
|
||||
this.add(filter, p, filter[p], value);
|
||||
|
||||
if (values.blurPadding !== 0) {
|
||||
padding = values.blurPadding || Math.max(filter[p], value) * 2;
|
||||
i = target.filters.length;
|
||||
|
||||
while (--i > -1) {
|
||||
target.filters[i].padding = Math.max(target.filters[i].padding, padding); //if we don't expand the padding on all the filters, it can look clipped.
|
||||
}
|
||||
}
|
||||
} else if (_colorProps[p]) {
|
||||
if ((p === "lineColor" || p === "fillColor" || p === "strokeColor") && target instanceof _PIXI.Graphics) {
|
||||
data = "fillStyle" in target ? [target] : (target.geometry || target).graphicsData; //"geometry" was introduced in PIXI version 5
|
||||
|
||||
subProp = p.substr(0, p.length - 5);
|
||||
_isV8Plus && subProp === "line" && (subProp = "stroke"); // in v8, lineColor became strokeColor.
|
||||
|
||||
this._pt = new PropTween(this._pt, target, p, 0, 0, _renderDirtyCache, {
|
||||
g: target.geometry || target
|
||||
});
|
||||
i = data.length;
|
||||
|
||||
while (--i > -1) {
|
||||
_addColorTween(_isV4 ? data[i] : data[i][subProp + "Style"], _isV4 ? p : "color", value, this);
|
||||
}
|
||||
} else {
|
||||
_addColorTween(target, p, value, this);
|
||||
}
|
||||
} else if (p === "autoAlpha") {
|
||||
this._pt = new PropTween(this._pt, target, "visible", 0, 0, _renderAutoAlpha);
|
||||
this.add(target, "alpha", target.alpha, value);
|
||||
|
||||
this._props.push("alpha", "visible");
|
||||
} else if (p !== "resolution") {
|
||||
this.add(target, p, "get", value);
|
||||
}
|
||||
|
||||
this._props.push(p);
|
||||
}
|
||||
}
|
||||
};
|
||||
_getGSAP() && gsap.registerPlugin(PixiPlugin);
|
||||
export { PixiPlugin as default };
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
# GSAP (GreenSock Animation Platform)
|
||||
|
||||
[](https://gsap.com)
|
||||
|
||||
GSAP is a **framework-agnostic** JavaScript animation library that turns developers into animation superheroes. Build high-performance animations that work in **every** major browser. Animate CSS, SVG, canvas, React, Vue, WebGL, colors, strings, motion paths, generic objects... anything JavaScript can touch! GSAP's <a href="https://gsap.com/docs/v3/Plugins/ScrollTrigger/">ScrollTrigger</a> plugin delivers jaw-dropping scroll-based animations with minimal code. <a href="https://gsap.com/docs/v3/GSAP/gsap.matchMedia()">gsap.matchMedia()</a> makes building responsive, accessibility-friendly animations a breeze.
|
||||
|
||||
No other library delivers such advanced sequencing, reliability, and tight control while solving real-world problems on over 12 million sites. GSAP works around countless browser inconsistencies; your animations ***just work***. At its core, GSAP is a high-speed property manipulator, updating values over time with extreme accuracy. It's up to 20x faster than jQuery!
|
||||
|
||||
GSAP is completely flexible; sprinkle it wherever you want. **Zero dependencies.**
|
||||
|
||||
There are many optional <a href="https://gsap.com/docs/v3/Plugins">plugins</a> and <a href="https://gsap.com/docs/v3/Eases">easing</a> functions for achieving advanced effects easily like <a href="https://gsap.com/docs/v3/Plugins/ScrollTrigger/">scrolling</a>, <a href="https://gsap.com/docs/v3/Plugins/MorphSVGPlugin">morphing</a>, [text splitting](https://gsap.com/docs/v3/Plugins/SplitText), animating along a <a href="https://gsap.com/docs/v3/Plugins/MotionPathPlugin">motion path</a> or <a href="https://gsap.com/docs/v3/Plugins/Flip/">FLIP</a> animations. There's even a handy <a href="https://gsap.com/docs/v3/Plugins/Observer/">Observer</a> for normalizing event detection across browsers/devices.
|
||||
|
||||
|
||||
### Get Started
|
||||
|
||||
[](https://gsap.com/get-started)
|
||||
|
||||
|
||||
## Docs & Installation
|
||||
|
||||
View the <a href="https://gsap.com/docs">full documentation here</a>, including an <a href="https://gsap.com/install">installation guide</a>.
|
||||
|
||||
### CDN
|
||||
|
||||
```html
|
||||
<script src="https://cdn.jsdelivr.net/npm/gsap@3.14/dist/gsap.min.js"></script>
|
||||
```
|
||||
|
||||
See <a href="https://www.jsdelivr.com/gsap">JSDelivr's dedicated GSAP page</a> for quick CDN links to the core files/plugins. There are more <a href="https://gsap.com/install">installation instructions</a> at gsap.com.
|
||||
|
||||
**Every major ad network excludes GSAP from file size calculations** and most have it on their own CDNs, so contact them for the appropriate URL(s).
|
||||
|
||||
### NPM
|
||||
See the <a href="https://gsap.com/install">guide to using GSAP via NPM here</a>.
|
||||
|
||||
```javascript
|
||||
npm install gsap
|
||||
```
|
||||
|
||||
GSAP's core can animate almost anything including CSS and attributes, plus it includes all of the <a href="https://gsap.com/docs/v3/GSAP/UtilityMethods">utility methods</a> like <a href="https://gsap.com/docs/v3/GSAP/UtilityMethods/interpolate()">interpolate()</a>, <a href="https://gsap.com/docs/v3/GSAP/UtilityMethods/mapRange()">mapRange()</a>, most of the <a href="https://gsap.com/docs/v3/Eases">eases</a>, and it can do snapping and modifiers.
|
||||
|
||||
```javascript
|
||||
// typical import
|
||||
import gsap from "gsap";
|
||||
|
||||
// get other plugins:
|
||||
import ScrollTrigger from "gsap/ScrollTrigger";
|
||||
import Flip from "gsap/Flip";
|
||||
import Draggable from "gsap/Draggable";
|
||||
|
||||
// or all tools are exported from the "all" file (excluding members-only plugins):
|
||||
import { gsap, ScrollTrigger, Draggable, MotionPathPlugin } from "gsap/all";
|
||||
|
||||
// don't forget to register plugins
|
||||
gsap.registerPlugin(ScrollTrigger, Draggable, Flip, MotionPathPlugin);
|
||||
```
|
||||
|
||||
The NPM files are ES modules, but there's also a /dist/ directory with <a href="https://www.davidbcalhoun.com/2014/what-is-amd-commonjs-and-umd/">UMD</a> files for extra compatibility.
|
||||
|
||||
## GSAP is FREE!
|
||||
|
||||
Thanks to [Webflow](https://webflow.com), GSAP is now **100% FREE** including ALL of the bonus plugins like [SplitText](https://gsap.com/docs/v3/Plugins/SplitText), [MorphSVG](https://gsap.com/docs/v3/Plugins/MorphSVGPlugin), and all the others that were exclusively available to Club GSAP members. That's right - the entire GSAP toolset is FREE, even for commercial use! 🤯 Read more [here](https://webflow.com/blog/gsap-becomes-free)
|
||||
|
||||
### ScrollTrigger & ScrollSmoother
|
||||
|
||||
If you're looking for scroll-driven animations, GSAP's <a href="https://gsap.com/docs/v3/Plugins/ScrollTrigger/">ScrollTrigger</a> plugin is the standard. There's a companion <a href="https://gsap.com/docs/v3/Plugins/ScrollSmoother/">ScrollSmoother</a> as well.
|
||||
|
||||
[](https://gsap.com/docs/v3/Plugins/ScrollTrigger)
|
||||
|
||||
### Using React?
|
||||
|
||||
There's a <a href="https://www.npmjs.com/package/@gsap/react">@gsap/react</a> package that exposes a `useGSAP()` hook which is a drop-in replacement for `useEffect()`/`useLayoutEffect()`, automating cleanup tasks. Please read the <a href="https://gsap.com/react">React guide</a> for details.
|
||||
|
||||
### Resources
|
||||
|
||||
* <a href="https://gsap.com/">gsap.com</a>
|
||||
* <a href="https://gsap.com/get-started/">Getting started guide</a>
|
||||
* <a href="https://gsap.com/docs/">Docs</a>
|
||||
* <a href="https://gsap.com/demos">Demos & starter templates</a>
|
||||
* <a href="https://gsap.com/community/">Community forums</a>
|
||||
* <a href="https://gsap.com/docs/v3/Eases">Ease Visualizer</a>
|
||||
* <a href="https://gsap.com/showcase">Showcase</a>
|
||||
* <a href="https://www.youtube.com/@GreenSockLearning">YouTube Channel</a>
|
||||
* <a href="https://gsap.com/cheatsheet">Cheat sheet</a>
|
||||
* <a href="https://webflow.com">Webflow</a>
|
||||
|
||||
### Need help?
|
||||
Ask in the friendly <a href="https://gsap.com/community/">GSAP forums</a>. Or share your knowledge and help someone else - it's a great way to sharpen your skills! Report any bugs there too (or <a href="https://github.com/greensock/GSAP/issues">file an issue here</a> if you prefer).
|
||||
|
||||
### License
|
||||
GreenSock's standard "no charge" license can be viewed at <a href="https://gsap.com/standard-license">https://gsap.com/standard-license</a>.
|
||||
|
||||
Copyright (c) 2008-2025, GreenSock. All rights reserved.
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
# Security Policy
|
||||
|
||||
Please report (suspected) security vulnerabilities to
|
||||
**[info@greensock.com](mailto:info@greensock.com)**. You will receive a response from
|
||||
us within 72 hours. If the issue is confirmed, we will release a patch as soon
|
||||
as possible depending on complexity.
|
||||
+251
@@ -0,0 +1,251 @@
|
||||
/*!
|
||||
* 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
|
||||
*/
|
||||
|
||||
/* eslint-disable */
|
||||
import { emojiSafeSplit, getText } from "./utils/strings.js";
|
||||
|
||||
var CharSet = /*#__PURE__*/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); //we create 20 strings that are 80 characters long, randomly chosen and pack them into an array. We then randomly choose the scrambled text from this array in order to greatly improve efficiency compared to creating new randomized text from scratch each and every time it's needed. This is a simple lookup whereas the other technique requires looping through as many times as there are characters needed, and calling Math.random() each time through the loop, building the string, etc.
|
||||
}
|
||||
}
|
||||
|
||||
var _proto = CharSet.prototype;
|
||||
|
||||
_proto.grow = function grow(newLength) {
|
||||
//if we encounter a tween that has more than 80 characters, we'll need to add to the character sets accordingly. Once it's cached, it'll only need to grow again if we exceed that new length. Again, this is an efficiency tactic.
|
||||
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,
|
||||
//<name>ScrambleTextPlugin</name>
|
||||
_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();
|
||||
};
|
||||
|
||||
export 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; // SVG text in IE doesn't have innerHTML, but it does have textContent.
|
||||
|
||||
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; //invert the time for from() tweens
|
||||
}
|
||||
|
||||
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")) {
|
||||
//special case for from() tweens
|
||||
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);
|
||||
export { ScrambleTextPlugin as default };
|
||||
+1010
File diff suppressed because it is too large.
Load diff
+281
@@ -0,0 +1,281 @@
|
||||
/*!
|
||||
* ScrollToPlugin 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
|
||||
*/
|
||||
|
||||
/* eslint-disable */
|
||||
var gsap,
|
||||
_coreInitted,
|
||||
_window,
|
||||
_docEl,
|
||||
_body,
|
||||
_toArray,
|
||||
_config,
|
||||
ScrollTrigger,
|
||||
_windowExists = function _windowExists() {
|
||||
return typeof window !== "undefined";
|
||||
},
|
||||
_getGSAP = function _getGSAP() {
|
||||
return gsap || _windowExists() && (gsap = window.gsap) && gsap.registerPlugin && gsap;
|
||||
},
|
||||
_isString = function _isString(value) {
|
||||
return typeof value === "string";
|
||||
},
|
||||
_isFunction = function _isFunction(value) {
|
||||
return typeof value === "function";
|
||||
},
|
||||
_max = function _max(element, axis) {
|
||||
var dim = axis === "x" ? "Width" : "Height",
|
||||
scroll = "scroll" + dim,
|
||||
client = "client" + dim;
|
||||
return element === _window || element === _docEl || element === _body ? Math.max(_docEl[scroll], _body[scroll]) - (_window["inner" + dim] || _docEl[client] || _body[client]) : element[scroll] - element["offset" + dim];
|
||||
},
|
||||
_buildGetter = function _buildGetter(e, axis) {
|
||||
//pass in an element and an axis ("x" or "y") and it'll return a getter function for the scroll position of that element (like scrollTop or scrollLeft, although if the element is the window, it'll use the pageXOffset/pageYOffset or the documentElement's scrollTop/scrollLeft or document.body's. Basically this streamlines things and makes a very fast getter across browsers.
|
||||
var p = "scroll" + (axis === "x" ? "Left" : "Top");
|
||||
|
||||
if (e === _window) {
|
||||
if (e.pageXOffset != null) {
|
||||
p = "page" + axis.toUpperCase() + "Offset";
|
||||
} else {
|
||||
e = _docEl[p] != null ? _docEl : _body;
|
||||
}
|
||||
}
|
||||
|
||||
return function () {
|
||||
return e[p];
|
||||
};
|
||||
},
|
||||
_clean = function _clean(value, index, target, targets) {
|
||||
_isFunction(value) && (value = value(index, target, targets));
|
||||
|
||||
if (typeof value !== "object") {
|
||||
return _isString(value) && value !== "max" && value.charAt(1) !== "=" ? {
|
||||
x: value,
|
||||
y: value
|
||||
} : {
|
||||
y: value
|
||||
}; //if we don't receive an object as the parameter, assume the user intends "y".
|
||||
} else if (value.nodeType) {
|
||||
return {
|
||||
y: value,
|
||||
x: value
|
||||
};
|
||||
} else {
|
||||
var result = {},
|
||||
p;
|
||||
|
||||
for (p in value) {
|
||||
result[p] = p !== "onAutoKill" && _isFunction(value[p]) ? value[p](index, target, targets) : value[p];
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
},
|
||||
_getOffset = function _getOffset(element, container) {
|
||||
element = _toArray(element)[0];
|
||||
|
||||
if (!element || !element.getBoundingClientRect) {
|
||||
return console.warn("scrollTo target doesn't exist. Using 0") || {
|
||||
x: 0,
|
||||
y: 0
|
||||
};
|
||||
}
|
||||
|
||||
var rect = element.getBoundingClientRect(),
|
||||
isRoot = !container || container === _window || container === _body,
|
||||
cRect = isRoot ? {
|
||||
top: _docEl.clientTop - (_window.pageYOffset || _docEl.scrollTop || _body.scrollTop || 0),
|
||||
left: _docEl.clientLeft - (_window.pageXOffset || _docEl.scrollLeft || _body.scrollLeft || 0)
|
||||
} : container.getBoundingClientRect(),
|
||||
offsets = {
|
||||
x: rect.left - cRect.left,
|
||||
y: rect.top - cRect.top
|
||||
};
|
||||
|
||||
if (!isRoot && container) {
|
||||
//only add the current scroll position if it's not the window/body.
|
||||
offsets.x += _buildGetter(container, "x")();
|
||||
offsets.y += _buildGetter(container, "y")();
|
||||
}
|
||||
|
||||
return offsets;
|
||||
},
|
||||
_parseVal = function _parseVal(value, target, axis, currentVal, offset) {
|
||||
return !isNaN(value) && typeof value !== "object" ? parseFloat(value) - offset : _isString(value) && value.charAt(1) === "=" ? parseFloat(value.substr(2)) * (value.charAt(0) === "-" ? -1 : 1) + currentVal - offset : value === "max" ? _max(target, axis) - offset : Math.min(_max(target, axis), _getOffset(value, target)[axis] - offset);
|
||||
},
|
||||
_initCore = function _initCore() {
|
||||
gsap = _getGSAP();
|
||||
|
||||
if (_windowExists() && gsap && typeof document !== "undefined" && document.body) {
|
||||
_window = window;
|
||||
_body = document.body;
|
||||
_docEl = document.documentElement;
|
||||
_toArray = gsap.utils.toArray;
|
||||
gsap.config({
|
||||
autoKillThreshold: 7
|
||||
});
|
||||
_config = gsap.config();
|
||||
_coreInitted = 1;
|
||||
}
|
||||
};
|
||||
|
||||
export var ScrollToPlugin = {
|
||||
version: "3.14.2",
|
||||
name: "scrollTo",
|
||||
rawVars: 1,
|
||||
register: function register(core) {
|
||||
gsap = core;
|
||||
|
||||
_initCore();
|
||||
},
|
||||
init: function init(target, value, tween, index, targets) {
|
||||
_coreInitted || _initCore();
|
||||
var data = this,
|
||||
snapType = gsap.getProperty(target, "scrollSnapType");
|
||||
data.isWin = target === _window;
|
||||
data.target = target;
|
||||
data.tween = tween;
|
||||
value = _clean(value, index, target, targets);
|
||||
data.vars = value;
|
||||
data.autoKill = !!("autoKill" in value ? value : _config).autoKill;
|
||||
data.getX = _buildGetter(target, "x");
|
||||
data.getY = _buildGetter(target, "y");
|
||||
data.x = data.xPrev = data.getX();
|
||||
data.y = data.yPrev = data.getY();
|
||||
ScrollTrigger || (ScrollTrigger = gsap.core.globals().ScrollTrigger);
|
||||
gsap.getProperty(target, "scrollBehavior") === "smooth" && gsap.set(target, {
|
||||
scrollBehavior: "auto"
|
||||
});
|
||||
|
||||
if (snapType && snapType !== "none") {
|
||||
// disable scroll snapping to avoid strange behavior
|
||||
data.snap = 1;
|
||||
data.snapInline = target.style.scrollSnapType;
|
||||
target.style.scrollSnapType = "none";
|
||||
}
|
||||
|
||||
if (value.x != null) {
|
||||
data.add(data, "x", data.x, _parseVal(value.x, target, "x", data.x, value.offsetX || 0), index, targets);
|
||||
|
||||
data._props.push("scrollTo_x");
|
||||
} else {
|
||||
data.skipX = 1;
|
||||
}
|
||||
|
||||
if (value.y != null) {
|
||||
data.add(data, "y", data.y, _parseVal(value.y, target, "y", data.y, value.offsetY || 0), index, targets);
|
||||
|
||||
data._props.push("scrollTo_y");
|
||||
} else {
|
||||
data.skipY = 1;
|
||||
}
|
||||
},
|
||||
render: function render(ratio, data) {
|
||||
var pt = data._pt,
|
||||
target = data.target,
|
||||
tween = data.tween,
|
||||
autoKill = data.autoKill,
|
||||
xPrev = data.xPrev,
|
||||
yPrev = data.yPrev,
|
||||
isWin = data.isWin,
|
||||
snap = data.snap,
|
||||
snapInline = data.snapInline,
|
||||
x,
|
||||
y,
|
||||
yDif,
|
||||
xDif,
|
||||
threshold;
|
||||
|
||||
while (pt) {
|
||||
pt.r(ratio, pt.d);
|
||||
pt = pt._next;
|
||||
}
|
||||
|
||||
x = isWin || !data.skipX ? data.getX() : xPrev;
|
||||
y = isWin || !data.skipY ? data.getY() : yPrev;
|
||||
yDif = y - yPrev;
|
||||
xDif = x - xPrev;
|
||||
threshold = _config.autoKillThreshold;
|
||||
|
||||
if (data.x < 0) {
|
||||
//can't scroll to a position less than 0! Might happen if someone uses a Back.easeOut or Elastic.easeOut when scrolling back to the top of the page (for example)
|
||||
data.x = 0;
|
||||
}
|
||||
|
||||
if (data.y < 0) {
|
||||
data.y = 0;
|
||||
}
|
||||
|
||||
if (autoKill) {
|
||||
//note: iOS has a bug that throws off the scroll by several pixels, so we need to check if it's within 7 pixels of the previous one that we set instead of just looking for an exact match.
|
||||
if (!data.skipX && (xDif > threshold || xDif < -threshold) && x < _max(target, "x")) {
|
||||
data.skipX = 1; //if the user scrolls separately, we should stop tweening!
|
||||
}
|
||||
|
||||
if (!data.skipY && (yDif > threshold || yDif < -threshold) && y < _max(target, "y")) {
|
||||
data.skipY = 1; //if the user scrolls separately, we should stop tweening!
|
||||
}
|
||||
|
||||
if (data.skipX && data.skipY) {
|
||||
tween.kill();
|
||||
data.vars.onAutoKill && data.vars.onAutoKill.apply(tween, data.vars.onAutoKillParams || []);
|
||||
}
|
||||
}
|
||||
|
||||
if (isWin) {
|
||||
_window.scrollTo(!data.skipX ? data.x : x, !data.skipY ? data.y : y);
|
||||
} else {
|
||||
data.skipY || (target.scrollTop = data.y);
|
||||
data.skipX || (target.scrollLeft = data.x);
|
||||
}
|
||||
|
||||
if (snap && (ratio === 1 || ratio === 0)) {
|
||||
y = target.scrollTop;
|
||||
x = target.scrollLeft;
|
||||
snapInline ? target.style.scrollSnapType = snapInline : target.style.removeProperty("scroll-snap-type");
|
||||
target.scrollTop = y + 1; // bug in Safari causes the element to totally reset its scroll position when scroll-snap-type changes, so we need to set it to a slightly different value and then back again to work around this bug.
|
||||
|
||||
target.scrollLeft = x + 1;
|
||||
target.scrollTop = y;
|
||||
target.scrollLeft = x;
|
||||
}
|
||||
|
||||
data.xPrev = data.x;
|
||||
data.yPrev = data.y;
|
||||
ScrollTrigger && ScrollTrigger.update();
|
||||
},
|
||||
kill: function kill(property) {
|
||||
var both = property === "scrollTo",
|
||||
i = this._props.indexOf(property);
|
||||
|
||||
if (both || property === "scrollTo_x") {
|
||||
this.skipX = 1;
|
||||
}
|
||||
|
||||
if (both || property === "scrollTo_y") {
|
||||
this.skipY = 1;
|
||||
}
|
||||
|
||||
i > -1 && this._props.splice(i, 1);
|
||||
return !this._props.length;
|
||||
}
|
||||
};
|
||||
ScrollToPlugin.max = _max;
|
||||
ScrollToPlugin.getOffset = _getOffset;
|
||||
ScrollToPlugin.buildGetter = _buildGetter;
|
||||
|
||||
ScrollToPlugin.config = function (vars) {
|
||||
_config || _initCore() || (_config = gsap.config()); // in case the window hasn't been defined yet.
|
||||
|
||||
for (var p in vars) {
|
||||
_config[p] = vars[p];
|
||||
}
|
||||
};
|
||||
|
||||
_getGSAP() && gsap.registerPlugin(ScrollToPlugin);
|
||||
export { ScrollToPlugin as default };
|
||||
+2695
File diff suppressed because it is too large.
Load diff
+333
@@ -0,0 +1,333 @@
|
||||
/*!
|
||||
* SplitText 3.14.2
|
||||
* https://gsap.com
|
||||
*
|
||||
* @license Copyright 2025, GreenSock. All rights reserved. Subject to the terms at https://gsap.com/standard-license.
|
||||
* @author: Jack Doyle
|
||||
*/
|
||||
|
||||
let gsap, _fonts, _splitProp = typeof Symbol === "function" ? Symbol() : "_split", _coreInitted, _initIfNecessary = () => _coreInitted || SplitText.register(window.gsap), _charSegmenter = typeof Intl !== "undefined" && "Segmenter" in Intl ? new Intl.Segmenter() : 0, _toArray = (r) => typeof r === "string" ? _toArray(document.querySelectorAll(r)) : "length" in r ? Array.from(r).reduce((acc, cur) => {
|
||||
typeof cur === "string" ? acc.push(..._toArray(cur)) : acc.push(cur);
|
||||
return acc;
|
||||
}, []) : [r], _elements = (targets) => _toArray(targets).filter((e) => e instanceof HTMLElement), _emptyArray = [], _context = function() {
|
||||
}, _defaultContext = { add: (f) => f() }, _spacesRegEx = /\s+/g, _emojiSafeRegEx = new RegExp("\\p{RI}\\p{RI}|\\p{Emoji}(\\p{EMod}|\\u{FE0F}\\u{20E3}?|[\\u{E0020}-\\u{E007E}]+\\u{E007F})?(\\u{200D}\\p{Emoji}(\\p{EMod}|\\u{FE0F}\\u{20E3}?|[\\u{E0020}-\\u{E007E}]+\\u{E007F})?)*|.", "gu"), _emptyBounds = { left: 0, top: 0, width: 0, height: 0 }, _findNextValidBounds = (allBounds, startIndex) => {
|
||||
while (++startIndex < allBounds.length && allBounds[startIndex] === _emptyBounds) {
|
||||
}
|
||||
return allBounds[startIndex] || _emptyBounds;
|
||||
}, _revertOriginal = ({ element, html, ariaL, ariaH }) => {
|
||||
element.innerHTML = html;
|
||||
ariaL ? element.setAttribute("aria-label", ariaL) : element.removeAttribute("aria-label");
|
||||
ariaH ? element.setAttribute("aria-hidden", ariaH) : element.removeAttribute("aria-hidden");
|
||||
}, _stretchToFitSpecialChars = (collection, specialCharsRegEx) => {
|
||||
if (specialCharsRegEx) {
|
||||
let charsFound = new Set(collection.join("").match(specialCharsRegEx) || _emptyArray), i = collection.length, slots, word, char, combined;
|
||||
if (charsFound.size) {
|
||||
while (--i > -1) {
|
||||
word = collection[i];
|
||||
for (char of charsFound) {
|
||||
if (char.startsWith(word) && char.length > word.length) {
|
||||
slots = 0;
|
||||
combined = word;
|
||||
while (char.startsWith(combined += collection[i + ++slots]) && combined.length < char.length) {
|
||||
}
|
||||
if (slots && combined.length === char.length) {
|
||||
collection[i] = char;
|
||||
collection.splice(i + 1, slots);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return collection;
|
||||
}, _disallowInline = (element) => window.getComputedStyle(element).display === "inline" && (element.style.display = "inline-block"), _insertNodeBefore = (newChild, parent, existingChild) => parent.insertBefore(typeof newChild === "string" ? document.createTextNode(newChild) : newChild, existingChild), _getWrapper = (type, config, collection) => {
|
||||
let className = config[type + "sClass"] || "", { tag = "div", aria = "auto", propIndex = false } = config, display = type === "line" ? "block" : "inline-block", incrementClass = className.indexOf("++") > -1, wrapper = (text) => {
|
||||
let el = document.createElement(tag), i = collection.length + 1;
|
||||
className && (el.className = className + (incrementClass ? " " + className + i : ""));
|
||||
propIndex && el.style.setProperty("--" + type, i + "");
|
||||
aria !== "none" && el.setAttribute("aria-hidden", "true");
|
||||
if (tag !== "span") {
|
||||
el.style.position = "relative";
|
||||
el.style.display = display;
|
||||
}
|
||||
el.textContent = text;
|
||||
collection.push(el);
|
||||
return el;
|
||||
};
|
||||
incrementClass && (className = className.replace("++", ""));
|
||||
wrapper.collection = collection;
|
||||
return wrapper;
|
||||
}, _getLineWrapper = (element, nodes, config, collection) => {
|
||||
let lineWrapper = _getWrapper("line", config, collection), textAlign = window.getComputedStyle(element).textAlign || "left";
|
||||
return (startIndex, endIndex) => {
|
||||
let newLine = lineWrapper("");
|
||||
newLine.style.textAlign = textAlign;
|
||||
element.insertBefore(newLine, nodes[startIndex]);
|
||||
for (; startIndex < endIndex; startIndex++) {
|
||||
newLine.appendChild(nodes[startIndex]);
|
||||
}
|
||||
newLine.normalize();
|
||||
};
|
||||
}, _splitWordsAndCharsRecursively = (element, config, wordWrapper, charWrapper, prepForCharsOnly, deepSlice, ignore, charSplitRegEx, specialCharsRegEx, isNested) => {
|
||||
var _a;
|
||||
let nodes = Array.from(element.childNodes), i = 0, { wordDelimiter, reduceWhiteSpace = true, prepareText } = config, elementBounds = element.getBoundingClientRect(), lastBounds = elementBounds, isPreformatted = !reduceWhiteSpace && window.getComputedStyle(element).whiteSpace.substring(0, 3) === "pre", ignoredPreviousSibling = 0, wordsCollection = wordWrapper.collection, wordDelimIsNotSpace, wordDelimString, wordDelimSplitter, curNode, words, curWordEl, startsWithSpace, endsWithSpace, j, bounds, curWordChars, clonedNode, curSubNode, tempSubNode, curTextContent, wordText, lastWordText, k;
|
||||
if (typeof wordDelimiter === "object") {
|
||||
wordDelimSplitter = wordDelimiter.delimiter || wordDelimiter;
|
||||
wordDelimString = wordDelimiter.replaceWith || "";
|
||||
} else {
|
||||
wordDelimString = wordDelimiter === "" ? "" : wordDelimiter || " ";
|
||||
}
|
||||
wordDelimIsNotSpace = wordDelimString !== " ";
|
||||
for (; i < nodes.length; i++) {
|
||||
curNode = nodes[i];
|
||||
if (curNode.nodeType === 3) {
|
||||
curTextContent = curNode.textContent || "";
|
||||
if (reduceWhiteSpace) {
|
||||
curTextContent = curTextContent.replace(_spacesRegEx, " ");
|
||||
} else if (isPreformatted) {
|
||||
curTextContent = curTextContent.replace(/\n/g, wordDelimString + "\n");
|
||||
}
|
||||
prepareText && (curTextContent = prepareText(curTextContent, element));
|
||||
curNode.textContent = curTextContent;
|
||||
words = wordDelimString || wordDelimSplitter ? curTextContent.split(wordDelimSplitter || wordDelimString) : curTextContent.match(charSplitRegEx) || _emptyArray;
|
||||
lastWordText = words[words.length - 1];
|
||||
endsWithSpace = wordDelimIsNotSpace ? lastWordText.slice(-1) === " " : !lastWordText;
|
||||
lastWordText || words.pop();
|
||||
lastBounds = elementBounds;
|
||||
startsWithSpace = wordDelimIsNotSpace ? words[0].charAt(0) === " " : !words[0];
|
||||
startsWithSpace && _insertNodeBefore(" ", element, curNode);
|
||||
words[0] || words.shift();
|
||||
_stretchToFitSpecialChars(words, specialCharsRegEx);
|
||||
deepSlice && isNested || (curNode.textContent = "");
|
||||
for (j = 1; j <= words.length; j++) {
|
||||
wordText = words[j - 1];
|
||||
if (!reduceWhiteSpace && isPreformatted && wordText.charAt(0) === "\n") {
|
||||
(_a = curNode.previousSibling) == null ? void 0 : _a.remove();
|
||||
_insertNodeBefore(document.createElement("br"), element, curNode);
|
||||
wordText = wordText.slice(1);
|
||||
}
|
||||
if (!reduceWhiteSpace && wordText === "") {
|
||||
_insertNodeBefore(wordDelimString, element, curNode);
|
||||
} else if (wordText === " ") {
|
||||
element.insertBefore(document.createTextNode(" "), curNode);
|
||||
} else {
|
||||
wordDelimIsNotSpace && wordText.charAt(0) === " " && _insertNodeBefore(" ", element, curNode);
|
||||
if (ignoredPreviousSibling && j === 1 && !startsWithSpace && wordsCollection.indexOf(ignoredPreviousSibling.parentNode) > -1) {
|
||||
curWordEl = wordsCollection[wordsCollection.length - 1];
|
||||
curWordEl.appendChild(document.createTextNode(charWrapper ? "" : wordText));
|
||||
} else {
|
||||
curWordEl = wordWrapper(charWrapper ? "" : wordText);
|
||||
_insertNodeBefore(curWordEl, element, curNode);
|
||||
ignoredPreviousSibling && j === 1 && !startsWithSpace && curWordEl.insertBefore(ignoredPreviousSibling, curWordEl.firstChild);
|
||||
}
|
||||
if (charWrapper) {
|
||||
curWordChars = _charSegmenter ? _stretchToFitSpecialChars([..._charSegmenter.segment(wordText)].map((s) => s.segment), specialCharsRegEx) : wordText.match(charSplitRegEx) || _emptyArray;
|
||||
for (k = 0; k < curWordChars.length; k++) {
|
||||
curWordEl.appendChild(curWordChars[k] === " " ? document.createTextNode(" ") : charWrapper(curWordChars[k]));
|
||||
}
|
||||
}
|
||||
if (deepSlice && isNested) {
|
||||
curTextContent = curNode.textContent = curTextContent.substring(wordText.length + 1, curTextContent.length);
|
||||
bounds = curWordEl.getBoundingClientRect();
|
||||
if (bounds.top > lastBounds.top && bounds.left <= lastBounds.left) {
|
||||
clonedNode = element.cloneNode();
|
||||
curSubNode = element.childNodes[0];
|
||||
while (curSubNode && curSubNode !== curWordEl) {
|
||||
tempSubNode = curSubNode;
|
||||
curSubNode = curSubNode.nextSibling;
|
||||
clonedNode.appendChild(tempSubNode);
|
||||
}
|
||||
element.parentNode.insertBefore(clonedNode, element);
|
||||
prepForCharsOnly && _disallowInline(clonedNode);
|
||||
}
|
||||
lastBounds = bounds;
|
||||
}
|
||||
if (j < words.length || endsWithSpace) {
|
||||
_insertNodeBefore(j >= words.length ? " " : wordDelimIsNotSpace && wordText.slice(-1) === " " ? " " + wordDelimString : wordDelimString, element, curNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
element.removeChild(curNode);
|
||||
ignoredPreviousSibling = 0;
|
||||
} else if (curNode.nodeType === 1) {
|
||||
if (ignore && ignore.indexOf(curNode) > -1) {
|
||||
wordsCollection.indexOf(curNode.previousSibling) > -1 && wordsCollection[wordsCollection.length - 1].appendChild(curNode);
|
||||
ignoredPreviousSibling = curNode;
|
||||
} else {
|
||||
_splitWordsAndCharsRecursively(curNode, config, wordWrapper, charWrapper, prepForCharsOnly, deepSlice, ignore, charSplitRegEx, specialCharsRegEx, true);
|
||||
ignoredPreviousSibling = 0;
|
||||
}
|
||||
prepForCharsOnly && _disallowInline(curNode);
|
||||
}
|
||||
}
|
||||
};
|
||||
const _SplitText = class _SplitText {
|
||||
constructor(elements, config) {
|
||||
this.isSplit = false;
|
||||
_initIfNecessary();
|
||||
this.elements = _elements(elements);
|
||||
this.chars = [];
|
||||
this.words = [];
|
||||
this.lines = [];
|
||||
this.masks = [];
|
||||
this.vars = config;
|
||||
this.elements.forEach((el) => {
|
||||
var _a;
|
||||
config.overwrite !== false && ((_a = el[_splitProp]) == null ? void 0 : _a._data.orig.filter(({ element }) => element === el).forEach(_revertOriginal));
|
||||
el[_splitProp] = this;
|
||||
});
|
||||
this._split = () => this.isSplit && this.split(this.vars);
|
||||
let orig = [], timerId, checkWidths = () => {
|
||||
let i = orig.length, o;
|
||||
while (i--) {
|
||||
o = orig[i];
|
||||
let w = o.element.offsetWidth;
|
||||
if (w !== o.width) {
|
||||
o.width = w;
|
||||
this._split();
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
this._data = { orig, obs: typeof ResizeObserver !== "undefined" && new ResizeObserver(() => {
|
||||
clearTimeout(timerId);
|
||||
timerId = setTimeout(checkWidths, 200);
|
||||
}) };
|
||||
_context(this);
|
||||
this.split(config);
|
||||
}
|
||||
split(config) {
|
||||
(this._ctx || _defaultContext).add(() => {
|
||||
this.isSplit && this.revert();
|
||||
this.vars = config = config || this.vars || {};
|
||||
let { type = "chars,words,lines", aria = "auto", deepSlice = true, smartWrap, onSplit, autoSplit = false, specialChars, mask } = this.vars, splitLines = type.indexOf("lines") > -1, splitCharacters = type.indexOf("chars") > -1, splitWords = type.indexOf("words") > -1, onlySplitCharacters = splitCharacters && !splitWords && !splitLines, specialCharsRegEx = specialChars && ("push" in specialChars ? new RegExp("(?:" + specialChars.join("|") + ")", "gu") : specialChars), finalCharSplitRegEx = specialCharsRegEx ? new RegExp(specialCharsRegEx.source + "|" + _emojiSafeRegEx.source, "gu") : _emojiSafeRegEx, ignore = !!config.ignore && _elements(config.ignore), { orig, animTime, obs } = this._data, onSplitResult;
|
||||
if (splitCharacters || splitWords || splitLines) {
|
||||
this.elements.forEach((element, index) => {
|
||||
orig[index] = {
|
||||
element,
|
||||
html: element.innerHTML,
|
||||
ariaL: element.getAttribute("aria-label"),
|
||||
ariaH: element.getAttribute("aria-hidden")
|
||||
};
|
||||
aria === "auto" ? element.setAttribute("aria-label", (element.textContent || "").trim()) : aria === "hidden" && element.setAttribute("aria-hidden", "true");
|
||||
let chars = [], words = [], lines = [], charWrapper = splitCharacters ? _getWrapper("char", config, chars) : null, wordWrapper = _getWrapper("word", config, words), i, curWord, smartWrapSpan, nextSibling;
|
||||
_splitWordsAndCharsRecursively(element, config, wordWrapper, charWrapper, onlySplitCharacters, deepSlice && (splitLines || onlySplitCharacters), ignore, finalCharSplitRegEx, specialCharsRegEx, false);
|
||||
if (splitLines) {
|
||||
let nodes = _toArray(element.childNodes), wrapLine = _getLineWrapper(element, nodes, config, lines), curNode, toRemove = [], lineStartIndex = 0, allBounds = nodes.map((n) => n.nodeType === 1 ? n.getBoundingClientRect() : _emptyBounds), lastBounds = _emptyBounds, curBounds;
|
||||
for (i = 0; i < nodes.length; i++) {
|
||||
curNode = nodes[i];
|
||||
if (curNode.nodeType === 1) {
|
||||
if (curNode.nodeName === "BR") {
|
||||
if (!i || nodes[i - 1].nodeName !== "BR") {
|
||||
toRemove.push(curNode);
|
||||
wrapLine(lineStartIndex, i + 1);
|
||||
}
|
||||
lineStartIndex = i + 1;
|
||||
lastBounds = _findNextValidBounds(allBounds, i);
|
||||
} else {
|
||||
curBounds = allBounds[i];
|
||||
if (i && curBounds.top > lastBounds.top && curBounds.left < lastBounds.left + lastBounds.width - 1) {
|
||||
wrapLine(lineStartIndex, i);
|
||||
lineStartIndex = i;
|
||||
}
|
||||
lastBounds = curBounds;
|
||||
}
|
||||
}
|
||||
}
|
||||
lineStartIndex < i && wrapLine(lineStartIndex, i);
|
||||
toRemove.forEach((el) => {
|
||||
var _a;
|
||||
return (_a = el.parentNode) == null ? void 0 : _a.removeChild(el);
|
||||
});
|
||||
}
|
||||
if (!splitWords) {
|
||||
for (i = 0; i < words.length; i++) {
|
||||
curWord = words[i];
|
||||
if (splitCharacters || !curWord.nextSibling || curWord.nextSibling.nodeType !== 3) {
|
||||
if (smartWrap && !splitLines) {
|
||||
smartWrapSpan = document.createElement("span");
|
||||
smartWrapSpan.style.whiteSpace = "nowrap";
|
||||
while (curWord.firstChild) {
|
||||
smartWrapSpan.appendChild(curWord.firstChild);
|
||||
}
|
||||
curWord.replaceWith(smartWrapSpan);
|
||||
} else {
|
||||
curWord.replaceWith(...curWord.childNodes);
|
||||
}
|
||||
} else {
|
||||
nextSibling = curWord.nextSibling;
|
||||
if (nextSibling && nextSibling.nodeType === 3) {
|
||||
nextSibling.textContent = (curWord.textContent || "") + (nextSibling.textContent || "");
|
||||
curWord.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
words.length = 0;
|
||||
element.normalize();
|
||||
}
|
||||
this.lines.push(...lines);
|
||||
this.words.push(...words);
|
||||
this.chars.push(...chars);
|
||||
});
|
||||
mask && this[mask] && this.masks.push(...this[mask].map((el) => {
|
||||
let maskEl = el.cloneNode();
|
||||
el.replaceWith(maskEl);
|
||||
maskEl.appendChild(el);
|
||||
el.className && (maskEl.className = el.className.trim() + "-mask");
|
||||
maskEl.style.overflow = "clip";
|
||||
return maskEl;
|
||||
}));
|
||||
}
|
||||
this.isSplit = true;
|
||||
_fonts && splitLines && (autoSplit ? _fonts.addEventListener("loadingdone", this._split) : _fonts.status === "loading" && console.warn("SplitText called before fonts loaded"));
|
||||
if ((onSplitResult = onSplit && onSplit(this)) && onSplitResult.totalTime) {
|
||||
this._data.anim = animTime ? onSplitResult.totalTime(animTime) : onSplitResult;
|
||||
}
|
||||
splitLines && autoSplit && this.elements.forEach((element, index) => {
|
||||
orig[index].width = element.offsetWidth;
|
||||
obs && obs.observe(element);
|
||||
});
|
||||
});
|
||||
return this;
|
||||
}
|
||||
kill() {
|
||||
let { obs } = this._data;
|
||||
obs && obs.disconnect();
|
||||
_fonts == null ? void 0 : _fonts.removeEventListener("loadingdone", this._split);
|
||||
}
|
||||
revert() {
|
||||
var _a, _b;
|
||||
if (this.isSplit) {
|
||||
let { orig, anim } = this._data;
|
||||
this.kill();
|
||||
orig.forEach(_revertOriginal);
|
||||
this.chars.length = this.words.length = this.lines.length = orig.length = this.masks.length = 0;
|
||||
this.isSplit = false;
|
||||
if (anim) {
|
||||
this._data.animTime = anim.totalTime();
|
||||
anim.revert();
|
||||
}
|
||||
(_b = (_a = this.vars).onRevert) == null ? void 0 : _b.call(_a, this);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
static create(elements, config) {
|
||||
return new _SplitText(elements, config);
|
||||
}
|
||||
static register(core) {
|
||||
gsap = gsap || core || window.gsap;
|
||||
if (gsap) {
|
||||
_toArray = gsap.utils.toArray;
|
||||
_context = gsap.core.context || _context;
|
||||
}
|
||||
if (!_coreInitted && window.innerWidth > 0) {
|
||||
_fonts = document.fonts;
|
||||
_coreInitted = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
_SplitText.version = "3.14.2";
|
||||
let SplitText = _SplitText;
|
||||
|
||||
export { SplitText, SplitText as default };
|
||||
+165
@@ -0,0 +1,165 @@
|
||||
/*!
|
||||
* TextPlugin 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
|
||||
*/
|
||||
|
||||
/* eslint-disable */
|
||||
import { emojiSafeSplit, getText, splitInnerHTML } from "./utils/strings.js";
|
||||
|
||||
var gsap,
|
||||
_tempDiv,
|
||||
_getGSAP = function _getGSAP() {
|
||||
return gsap || typeof window !== "undefined" && (gsap = window.gsap) && gsap.registerPlugin && gsap;
|
||||
};
|
||||
|
||||
export var TextPlugin = {
|
||||
version: "3.14.2",
|
||||
name: "text",
|
||||
init: function init(target, value, tween) {
|
||||
typeof value !== "object" && (value = {
|
||||
value: value
|
||||
});
|
||||
|
||||
var i = target.nodeName.toUpperCase(),
|
||||
data = this,
|
||||
_value = value,
|
||||
newClass = _value.newClass,
|
||||
oldClass = _value.oldClass,
|
||||
preserveSpaces = _value.preserveSpaces,
|
||||
rtl = _value.rtl,
|
||||
delimiter = data.delimiter = value.delimiter || "",
|
||||
fillChar = data.fillChar = value.fillChar || (value.padSpace ? " " : ""),
|
||||
_short,
|
||||
text,
|
||||
original,
|
||||
j,
|
||||
condensedText,
|
||||
condensedOriginal,
|
||||
aggregate,
|
||||
s;
|
||||
|
||||
data.svg = target.getBBox && (i === "TEXT" || i === "TSPAN");
|
||||
|
||||
if (!("innerHTML" in target) && !data.svg) {
|
||||
return false;
|
||||
}
|
||||
|
||||
data.target = target;
|
||||
|
||||
if (!("value" in value)) {
|
||||
data.text = data.original = [""];
|
||||
return;
|
||||
}
|
||||
|
||||
original = splitInnerHTML(target, delimiter, false, preserveSpaces, data.svg);
|
||||
_tempDiv || (_tempDiv = document.createElement("div"));
|
||||
_tempDiv.innerHTML = value.value;
|
||||
text = splitInnerHTML(_tempDiv, delimiter, false, preserveSpaces, data.svg);
|
||||
data.from = tween._from;
|
||||
|
||||
if ((data.from || rtl) && !(rtl && data.from)) {
|
||||
// right-to-left or "from()" tweens should invert things (but if it's BOTH .from() and rtl, inverting twice equals not inverting at all :)
|
||||
i = original;
|
||||
original = text;
|
||||
text = i;
|
||||
}
|
||||
|
||||
data.hasClass = !!(newClass || oldClass);
|
||||
data.newClass = rtl ? oldClass : newClass;
|
||||
data.oldClass = rtl ? newClass : oldClass;
|
||||
i = original.length - text.length;
|
||||
_short = i < 0 ? original : text;
|
||||
|
||||
if (i < 0) {
|
||||
i = -i;
|
||||
}
|
||||
|
||||
while (--i > -1) {
|
||||
_short.push(fillChar);
|
||||
}
|
||||
|
||||
if (value.type === "diff") {
|
||||
j = 0;
|
||||
condensedText = [];
|
||||
condensedOriginal = [];
|
||||
aggregate = "";
|
||||
|
||||
for (i = 0; i < text.length; i++) {
|
||||
s = text[i];
|
||||
|
||||
if (s === original[i]) {
|
||||
aggregate += s;
|
||||
} else {
|
||||
condensedText[j] = aggregate + s;
|
||||
condensedOriginal[j++] = aggregate + original[i];
|
||||
aggregate = "";
|
||||
}
|
||||
}
|
||||
|
||||
text = condensedText;
|
||||
original = condensedOriginal;
|
||||
|
||||
if (aggregate) {
|
||||
text.push(aggregate);
|
||||
original.push(aggregate);
|
||||
}
|
||||
}
|
||||
|
||||
value.speed && tween.duration(Math.min(0.05 / value.speed * _short.length, value.maxDuration || 9999));
|
||||
data.rtl = rtl;
|
||||
data.original = original;
|
||||
data.text = text;
|
||||
|
||||
data._props.push("text");
|
||||
},
|
||||
render: function render(ratio, data) {
|
||||
if (ratio > 1) {
|
||||
ratio = 1;
|
||||
} else if (ratio < 0) {
|
||||
ratio = 0;
|
||||
}
|
||||
|
||||
if (data.from) {
|
||||
ratio = 1 - ratio;
|
||||
}
|
||||
|
||||
var text = data.text,
|
||||
hasClass = data.hasClass,
|
||||
newClass = data.newClass,
|
||||
oldClass = data.oldClass,
|
||||
delimiter = data.delimiter,
|
||||
target = data.target,
|
||||
fillChar = data.fillChar,
|
||||
original = data.original,
|
||||
rtl = data.rtl,
|
||||
l = text.length,
|
||||
i = (rtl ? 1 - ratio : ratio) * l + 0.5 | 0,
|
||||
applyNew,
|
||||
applyOld,
|
||||
str;
|
||||
|
||||
if (hasClass && ratio) {
|
||||
applyNew = newClass && i;
|
||||
applyOld = oldClass && i !== l;
|
||||
str = (applyNew ? "<span class='" + newClass + "'>" : "") + text.slice(0, i).join(delimiter) + (applyNew ? "</span>" : "") + (applyOld ? "<span class='" + oldClass + "'>" : "") + delimiter + original.slice(i).join(delimiter) + (applyOld ? "</span>" : "");
|
||||
} else {
|
||||
str = text.slice(0, i).join(delimiter) + delimiter + original.slice(i).join(delimiter);
|
||||
}
|
||||
|
||||
if (data.svg) {
|
||||
//SVG text elements don't have an "innerHTML" in Microsoft browsers.
|
||||
target.textContent = str;
|
||||
} else {
|
||||
target.innerHTML = fillChar === " " && ~str.indexOf(" ") ? str.split(" ").join(" ") : str;
|
||||
}
|
||||
}
|
||||
};
|
||||
TextPlugin.splitInnerHTML = splitInnerHTML;
|
||||
TextPlugin.emojiSafeSplit = emojiSafeSplit;
|
||||
TextPlugin.getText = getText;
|
||||
_getGSAP() && gsap.registerPlugin(TextPlugin);
|
||||
export { TextPlugin as default };
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
import gsap from "./gsap-core.js";
|
||||
import CSSPlugin from "./CSSPlugin.js";
|
||||
var gsapWithCSS = gsap.registerPlugin(CSSPlugin) || gsap,
|
||||
// to protect from tree shaking
|
||||
TweenMaxWithCSS = gsapWithCSS.core.Tween;
|
||||
export { gsapWithCSS as gsap, gsapWithCSS as default, TweenMaxWithCSS as TweenMax, CSSPlugin };
|
||||
export { TweenLite, TimelineMax, TimelineLite, Power0, Power1, Power2, Power3, Power4, Linear, Quad, Cubic, Quart, Quint, Strong, Elastic, Back, SteppedEase, Bounce, Sine, Expo, Circ, wrap, wrapYoyo, distribute, random, snap, normalize, getUnit, clamp, splitColor, toArray, mapRange, pipe, unitize, interpolate, shuffle, selector } from "./gsap-core.js";
|
||||
export * from "./CustomEase.js";
|
||||
export * from "./Draggable.js";
|
||||
export * from "./CSSRulePlugin.js";
|
||||
export * from "./EaselPlugin.js";
|
||||
export * from "./EasePack.js";
|
||||
export * from "./Flip.js";
|
||||
export * from "./MotionPathPlugin.js";
|
||||
export * from "./Observer.js";
|
||||
export * from "./PixiPlugin.js";
|
||||
export * from "./ScrollToPlugin.js";
|
||||
export * from "./ScrollTrigger.js";
|
||||
export * from "./TextPlugin.js";
|
||||
export * from "./DrawSVGPlugin.js";
|
||||
export * from "./Physics2DPlugin.js";
|
||||
export * from "./PhysicsPropsPlugin.js";
|
||||
export * from "./ScrambleTextPlugin.js";
|
||||
export * from "./CustomBounce.js";
|
||||
export * from "./CustomWiggle.js";
|
||||
export * from "./GSDevTools.js";
|
||||
export * from "./InertiaPlugin.js";
|
||||
export * from "./MorphSVGPlugin.js";
|
||||
export * from "./MotionPathHelper.js";
|
||||
export * from "./ScrollSmoother.js";
|
||||
export * from "./SplitText.js";
|
||||
+139
@@ -0,0 +1,139 @@
|
||||
(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';
|
||||
|
||||
/*!
|
||||
* CSSRulePlugin 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 gsap,
|
||||
_coreInitted,
|
||||
_doc,
|
||||
CSSPlugin,
|
||||
_windowExists = function _windowExists() {
|
||||
return typeof window !== "undefined";
|
||||
},
|
||||
_getGSAP = function _getGSAP() {
|
||||
return gsap || _windowExists() && (gsap = window.gsap) && gsap.registerPlugin && gsap;
|
||||
},
|
||||
_checkRegister = function _checkRegister() {
|
||||
if (!_coreInitted) {
|
||||
_initCore();
|
||||
|
||||
if (!CSSPlugin) {
|
||||
console.warn("Please gsap.registerPlugin(CSSPlugin, CSSRulePlugin)");
|
||||
}
|
||||
}
|
||||
|
||||
return _coreInitted;
|
||||
},
|
||||
_initCore = function _initCore(core) {
|
||||
gsap = core || _getGSAP();
|
||||
|
||||
if (_windowExists()) {
|
||||
_doc = document;
|
||||
}
|
||||
|
||||
if (gsap) {
|
||||
CSSPlugin = gsap.plugins.css;
|
||||
|
||||
if (CSSPlugin) {
|
||||
_coreInitted = 1;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var CSSRulePlugin = {
|
||||
version: "3.14.2",
|
||||
name: "cssRule",
|
||||
init: function init(target, value, tween, index, targets) {
|
||||
if (!_checkRegister() || typeof target.cssText === "undefined") {
|
||||
return false;
|
||||
}
|
||||
|
||||
var div = target._gsProxy = target._gsProxy || _doc.createElement("div");
|
||||
|
||||
this.ss = target;
|
||||
this.style = div.style;
|
||||
div.style.cssText = target.cssText;
|
||||
CSSPlugin.prototype.init.call(this, div, value, tween, index, targets);
|
||||
},
|
||||
render: function render(ratio, data) {
|
||||
var pt = data._pt,
|
||||
style = data.style,
|
||||
ss = data.ss,
|
||||
i;
|
||||
|
||||
while (pt) {
|
||||
pt.r(ratio, pt.d);
|
||||
pt = pt._next;
|
||||
}
|
||||
|
||||
i = style.length;
|
||||
|
||||
while (--i > -1) {
|
||||
ss[style[i]] = style[style[i]];
|
||||
}
|
||||
},
|
||||
getRule: function getRule(selector) {
|
||||
_checkRegister();
|
||||
|
||||
var ruleProp = _doc.all ? "rules" : "cssRules",
|
||||
styleSheets = _doc.styleSheets,
|
||||
i = styleSheets.length,
|
||||
pseudo = selector.charAt(0) === ":",
|
||||
j,
|
||||
curSS,
|
||||
cs,
|
||||
a;
|
||||
selector = (pseudo ? "" : ",") + selector.split("::").join(":").toLowerCase() + ",";
|
||||
|
||||
if (pseudo) {
|
||||
a = [];
|
||||
}
|
||||
|
||||
while (i--) {
|
||||
try {
|
||||
curSS = styleSheets[i][ruleProp];
|
||||
|
||||
if (!curSS) {
|
||||
continue;
|
||||
}
|
||||
|
||||
j = curSS.length;
|
||||
} catch (e) {
|
||||
console.warn(e);
|
||||
continue;
|
||||
}
|
||||
|
||||
while (--j > -1) {
|
||||
cs = curSS[j];
|
||||
|
||||
if (cs.selectorText && ("," + cs.selectorText.split("::").join(":").toLowerCase() + ",").indexOf(selector) !== -1) {
|
||||
if (pseudo) {
|
||||
a.push(cs.style);
|
||||
} else {
|
||||
return cs.style;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return a;
|
||||
},
|
||||
register: _initCore
|
||||
};
|
||||
_getGSAP() && gsap.registerPlugin(CSSRulePlugin);
|
||||
|
||||
exports.CSSRulePlugin = CSSRulePlugin;
|
||||
exports.default = CSSRulePlugin;
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
})));
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
/*!
|
||||
* CSSRulePlugin 3.14.2
|
||||
* https://gsap.com
|
||||
*
|
||||
* @license Copyright 2025, GreenSock. All rights reserved.
|
||||
* Subject to the terms at https://gsap.com/standard-license.
|
||||
* @author: Jack Doyle, jack@greensock.com
|
||||
*/
|
||||
|
||||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).window=e.window||{})}(this,function(e){"use strict";function h(){return"undefined"!=typeof window}function i(){return t||h()&&(t=window.gsap)&&t.registerPlugin&&t}function j(){return n||(s(),o||console.warn("Please gsap.registerPlugin(CSSPlugin, CSSRulePlugin)")),n}var t,n,c,o,s=function _initCore(e){t=e||i(),h()&&(c=document),t&&(o=t.plugins.css)&&(n=1)},r={version:"3.14.2",name:"cssRule",init:function init(e,t,n,i,s){if(!j()||void 0===e.cssText)return!1;var r=e._gsProxy=e._gsProxy||c.createElement("div");this.ss=e,this.style=r.style,r.style.cssText=e.cssText,o.prototype.init.call(this,r,t,n,i,s)},render:function render(e,t){for(var n,i=t._pt,s=t.style,r=t.ss;i;)i.r(e,i.d),i=i._next;for(n=s.length;-1<--n;)r[s[n]]=s[s[n]]},getRule:function getRule(e){j();var t,n,i,s,r=c.all?"rules":"cssRules",o=c.styleSheets,l=o.length,u=":"===e.charAt(0);for(e=(u?"":",")+e.split("::").join(":").toLowerCase()+",",u&&(s=[]);l--;){try{if(!(n=o[l][r]))continue;t=n.length}catch(e){console.warn(e);continue}for(;-1<--t;)if((i=n[t]).selectorText&&-1!==(","+i.selectorText.split("::").join(":").toLowerCase()+",").indexOf(e)){if(!u)return i.style;s.push(i.style)}}return s},register:s};i()&&t.registerPlugin(r),e.CSSRulePlugin=r,e.default=r;if (typeof(window)==="undefined"||window!==e){Object.defineProperty(e,"__esModule",{value:!0})} else {delete e.default}});
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"CSSRulePlugin.min.js","sources":["../src/CSSRulePlugin.js"],"sourcesContent":["/*!\n * CSSRulePlugin 3.14.2\n * https://gsap.com\n *\n * @license Copyright 2008-2025, GreenSock. All rights reserved.\n * Subject to the terms at https://gsap.com/standard-license\n * @author: Jack Doyle, jack@greensock.com\n*/\n/* eslint-disable */\n\nlet gsap, _coreInitted, _win, _doc, CSSPlugin,\n\t_windowExists = () => typeof(window) !== \"undefined\",\n\t_getGSAP = () => gsap || (_windowExists() && (gsap = window.gsap) && gsap.registerPlugin && gsap),\n\t_checkRegister = () => {\n\t\tif (!_coreInitted) {\n\t\t\t_initCore();\n\t\t\tif (!CSSPlugin) {\n\t\t\t\tconsole.warn(\"Please gsap.registerPlugin(CSSPlugin, CSSRulePlugin)\");\n\t\t\t}\n\t\t}\n\t\treturn _coreInitted;\n\t},\n\t_initCore = core => {\n\t\tgsap = core || _getGSAP();\n\t\tif (_windowExists()) {\n\t\t\t_win = window;\n\t\t\t_doc = document;\n\t\t}\n\t\tif (gsap) {\n\t\t\tCSSPlugin = gsap.plugins.css;\n\t\t\tif (CSSPlugin) {\n\t\t\t\t_coreInitted = 1;\n\t\t\t}\n\t\t}\n\t};\n\n\nexport const CSSRulePlugin = {\n\tversion: \"3.14.2\",\n\tname: \"cssRule\",\n\tinit(target, value, tween, index, targets) {\n\t\tif (!_checkRegister() || typeof(target.cssText) === \"undefined\") {\n\t\t\treturn false;\n\t\t}\n\t\tlet div = target._gsProxy = target._gsProxy || _doc.createElement(\"div\");\n\t\tthis.ss = target;\n\t\tthis.style = div.style;\n\t\tdiv.style.cssText = target.cssText;\n\t\tCSSPlugin.prototype.init.call(this, div, value, tween, index, targets); //we just offload all the work to the regular CSSPlugin and then copy the cssText back over to the rule in the render() method. This allows us to have all of the updates to CSSPlugin automatically flow through to CSSRulePlugin instead of having to maintain both\n\t},\n\trender(ratio, data) {\n\t\tlet pt = data._pt,\n\t\t\tstyle = data.style,\n\t\t\tss = data.ss,\n\t\t\ti;\n\t\twhile (pt) {\n\t\t\tpt.r(ratio, pt.d);\n\t\t\tpt = pt._next;\n\t\t}\n\t\ti = style.length;\n\t\twhile (--i > -1) {\n\t\t\tss[style[i]] = style[style[i]];\n\t\t}\n\t},\n\tgetRule(selector) {\n\t\t_checkRegister();\n\t\tlet ruleProp = _doc.all ? \"rules\" : \"cssRules\",\n\t\t\tstyleSheets = _doc.styleSheets,\n\t\t\ti = styleSheets.length,\n\t\t\tpseudo = (selector.charAt(0) === \":\"),\n\t\t\tj, curSS, cs, a;\n\t\tselector = (pseudo ? \"\" : \",\") + selector.split(\"::\").join(\":\").toLowerCase() + \",\"; //note: old versions of IE report tag name selectors as upper case, so we just change everything to lowercase.\n\t\tif (pseudo) {\n\t\t\ta = [];\n\t\t}\n\t\twhile (i--) {\n\t\t\t//Firefox may throw insecure operation errors when css is loaded from other domains, so try/catch.\n\t\t\ttry {\n\t\t\t\tcurSS = styleSheets[i][ruleProp];\n\t\t\t\tif (!curSS) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tj = curSS.length;\n\t\t\t} catch (e) {\n\t\t\t\tconsole.warn(e);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\twhile (--j > -1) {\n\t\t\t\tcs = curSS[j];\n\t\t\t\tif (cs.selectorText && (\",\" + cs.selectorText.split(\"::\").join(\":\").toLowerCase() + \",\").indexOf(selector) !== -1) { //note: IE adds an extra \":\" to pseudo selectors, so .myClass:after becomes .myClass::after, so we need to strip the extra one out.\n\t\t\t\t\tif (pseudo) {\n\t\t\t\t\t\ta.push(cs.style);\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn cs.style;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn a;\n\t},\n\tregister: _initCore\n};\n\n_getGSAP() && gsap.registerPlugin(CSSRulePlugin);\n\nexport { CSSRulePlugin as default };"],"names":["_windowExists","window","_getGSAP","gsap","registerPlugin","_checkRegister","_coreInitted","_initCore","CSSPlugin","console","warn","_doc","core","document","plugins","css","CSSRulePlugin","version","name","init","target","value","tween","index","targets","cssText","div","_gsProxy","createElement","ss","style","prototype","call","this","render","ratio","data","i","pt","_pt","r","d","_next","length","getRule","selector","j","curSS","cs","a","ruleProp","all","styleSheets","pseudo","charAt","split","join","toLowerCase","e","selectorText","indexOf","push","register"],"mappings":";;;;;;;;;6MAWiB,SAAhBA,UAAyC,oBAAZC,OAClB,SAAXC,WAAiBC,GAASH,MAAoBG,EAAOF,OAAOE,OAASA,EAAKC,gBAAkBD,EAC3E,SAAjBE,WACMC,IACJC,IACKC,GACJC,QAAQC,KAAK,yDAGRJ,MAVLH,EAAMG,EAAoBK,EAAMH,EAYnCD,EAAY,SAAZA,UAAYK,GACXT,EAAOS,GAAQV,IACXF,MAEHW,EAAOE,UAEJV,IACHK,EAAYL,EAAKW,QAAQC,OAExBT,EAAe,IAMNU,EAAgB,CAC5BC,QAAS,SACTC,KAAM,UACNC,mBAAKC,EAAQC,EAAOC,EAAOC,EAAOC,OAC5BnB,UAA+C,IAApBe,EAAOK,eAC/B,MAEJC,EAAMN,EAAOO,SAAWP,EAAOO,UAAYhB,EAAKiB,cAAc,YAC7DC,GAAKT,OACLU,MAAQJ,EAAII,MACjBJ,EAAII,MAAML,QAAUL,EAAOK,QAC3BjB,EAAUuB,UAAUZ,KAAKa,KAAKC,KAAMP,EAAKL,EAAOC,EAAOC,EAAOC,IAE/DU,uBAAOC,EAAOC,WAIZC,EAHGC,EAAKF,EAAKG,IACbT,EAAQM,EAAKN,MACbD,EAAKO,EAAKP,GAEJS,GACNA,EAAGE,EAAEL,EAAOG,EAAGG,GACfH,EAAKA,EAAGI,UAETL,EAAIP,EAAMa,QACI,IAALN,GACRR,EAAGC,EAAMO,IAAMP,EAAMA,EAAMO,KAG7BO,yBAAQC,GACPxC,QAKCyC,EAAGC,EAAOC,EAAIC,EAJXC,EAAWvC,EAAKwC,IAAM,QAAU,WACnCC,EAAczC,EAAKyC,YACnBf,EAAIe,EAAYT,OACLine truncated
|
||||
+168
@@ -0,0 +1,168 @@
|
||||
(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';
|
||||
|
||||
/*!
|
||||
* CustomBounce 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 gsap,
|
||||
_coreInitted,
|
||||
createCustomEase,
|
||||
_getGSAP = function _getGSAP() {
|
||||
return gsap || typeof window !== "undefined" && (gsap = window.gsap) && gsap.registerPlugin && gsap;
|
||||
},
|
||||
_initCore = function _initCore(required) {
|
||||
gsap = _getGSAP();
|
||||
createCustomEase = gsap && gsap.parseEase("_CE");
|
||||
|
||||
if (createCustomEase) {
|
||||
_coreInitted = 1;
|
||||
|
||||
gsap.parseEase("bounce").config = function (vars) {
|
||||
return typeof vars === "object" ? _create("", vars) : _create("bounce(" + vars + ")", {
|
||||
strength: +vars
|
||||
});
|
||||
};
|
||||
} else {
|
||||
required && console.warn("Please gsap.registerPlugin(CustomEase, CustomBounce)");
|
||||
}
|
||||
},
|
||||
_normalizeX = function _normalizeX(a) {
|
||||
var l = a.length,
|
||||
s = 1 / a[l - 2],
|
||||
rnd = 1000,
|
||||
i;
|
||||
|
||||
for (i = 2; i < l; i += 2) {
|
||||
a[i] = ~~(a[i] * s * rnd) / rnd;
|
||||
}
|
||||
|
||||
a[l - 2] = 1;
|
||||
},
|
||||
_create = function _create(id, vars) {
|
||||
if (!_coreInitted) {
|
||||
_initCore(1);
|
||||
}
|
||||
|
||||
vars = vars || {};
|
||||
|
||||
{
|
||||
var max = 0.999,
|
||||
decay = Math.min(max, vars.strength || 0.7),
|
||||
decayX = decay,
|
||||
gap = (vars.squash || 0) / 100,
|
||||
originalGap = gap,
|
||||
slope = 1 / 0.03,
|
||||
w = 0.2,
|
||||
h = 1,
|
||||
prevX = 0.1,
|
||||
path = [0, 0, 0.07, 0, 0.1, 1, 0.1, 1],
|
||||
squashPath = [0, 0, 0, 0, 0.1, 0, 0.1, 0],
|
||||
cp1,
|
||||
cp2,
|
||||
x,
|
||||
y,
|
||||
i,
|
||||
nextX,
|
||||
squishMagnitude;
|
||||
|
||||
for (i = 0; i < 200; i++) {
|
||||
w *= decayX * ((decayX + 1) / 2);
|
||||
h *= decay * decay;
|
||||
nextX = prevX + w;
|
||||
x = prevX + w * 0.49;
|
||||
y = 1 - h;
|
||||
cp1 = prevX + h / slope;
|
||||
cp2 = x + (x - cp1) * 0.8;
|
||||
|
||||
if (gap) {
|
||||
prevX += gap;
|
||||
cp1 += gap;
|
||||
x += gap;
|
||||
cp2 += gap;
|
||||
nextX += gap;
|
||||
squishMagnitude = gap / originalGap;
|
||||
squashPath.push(prevX - gap, 0, prevX - gap, squishMagnitude, prevX - gap / 2, squishMagnitude, prevX, squishMagnitude, prevX, 0, prevX, 0, prevX, squishMagnitude * -0.6, prevX + (nextX - prevX) / 6, 0, nextX, 0);
|
||||
path.push(prevX - gap, 1, prevX, 1, prevX, 1);
|
||||
gap *= decay * decay;
|
||||
}
|
||||
|
||||
path.push(prevX, 1, cp1, y, x, y, cp2, y, nextX, 1, nextX, 1);
|
||||
decay *= 0.95;
|
||||
slope = h / (nextX - cp2);
|
||||
prevX = nextX;
|
||||
|
||||
if (y > max) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (vars.endAtStart && vars.endAtStart !== "false") {
|
||||
x = -0.1;
|
||||
path.unshift(x, 1, x, 1, -0.07, 0);
|
||||
|
||||
if (originalGap) {
|
||||
gap = originalGap * 2.5;
|
||||
x -= gap;
|
||||
path.unshift(x, 1, x, 1, x, 1);
|
||||
squashPath.splice(0, 6);
|
||||
squashPath.unshift(x, 0, x, 0, x, 1, x + gap / 2, 1, x + gap, 1, x + gap, 0, x + gap, 0, x + gap, -0.6, x + gap + 0.033, 0);
|
||||
|
||||
for (i = 0; i < squashPath.length; i += 2) {
|
||||
squashPath[i] -= x;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < path.length; i += 2) {
|
||||
path[i] -= x;
|
||||
path[i + 1] = 1 - path[i + 1];
|
||||
}
|
||||
}
|
||||
|
||||
if (gap) {
|
||||
_normalizeX(squashPath);
|
||||
|
||||
squashPath[2] = "C" + squashPath[2];
|
||||
createCustomEase(vars.squashID || id + "-squash", "M" + squashPath.join(","));
|
||||
}
|
||||
|
||||
_normalizeX(path);
|
||||
|
||||
path[2] = "C" + path[2];
|
||||
return createCustomEase(id, "M" + path.join(","));
|
||||
}
|
||||
};
|
||||
|
||||
var CustomBounce = function () {
|
||||
function CustomBounce(id, vars) {
|
||||
this.ease = _create(id, vars);
|
||||
}
|
||||
|
||||
CustomBounce.create = function create(id, vars) {
|
||||
return _create(id, vars);
|
||||
};
|
||||
|
||||
CustomBounce.register = function register(core) {
|
||||
gsap = core;
|
||||
|
||||
_initCore();
|
||||
};
|
||||
|
||||
return CustomBounce;
|
||||
}();
|
||||
_getGSAP() && gsap.registerPlugin(CustomBounce);
|
||||
CustomBounce.version = "3.14.2";
|
||||
|
||||
exports.CustomBounce = CustomBounce;
|
||||
exports.default = CustomBounce;
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
})));
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
/*!
|
||||
* CustomBounce 3.14.2
|
||||
* https://gsap.com
|
||||
*
|
||||
* @license Copyright 2025, GreenSock. All rights reserved.
|
||||
* Subject to the terms at https://gsap.com/standard-license.
|
||||
* @author: Jack Doyle, jack@greensock.com
|
||||
*/
|
||||
|
||||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e=e||self).window=e.window||{})}(this,function(e){"use strict";function g(){return n||"undefined"!=typeof window&&(n=window.gsap)&&n.registerPlugin&&n}function h(e){n=g(),(j=n&&n.parseEase("_CE"))?(b=1,n.parseEase("bounce").config=function(e){return"object"==typeof e?t("",e):t("bounce("+e+")",{strength:+e})}):e&&console.warn("Please gsap.registerPlugin(CustomEase, CustomBounce)")}function i(e){var n,t=e.length,o=1/e[t-2];for(n=2;n<t;n+=2)e[n]=~~(e[n]*o*1e3)/1e3;e[t-2]=1}var n,b,j,t=function _create(e,n){b||h(1),n=n||{};var t,o,u,s,r,f,c,a=Math.min(.999,n.strength||.7),g=a,d=(n.squash||0)/100,p=d,l=1/.03,m=.2,C=1,w=.1,y=[0,0,.07,0,.1,1,.1,1],B=[0,0,0,0,.1,0,.1,0];for(r=0;r<200&&(f=w+(m*=g*((g+1)/2)),s=1-(C*=a*a),o=(u=w+.49*m)+.8*(u-(t=w+C/l)),d&&(w+=d,t+=d,u+=d,o+=d,f+=d,c=d/p,B.push(w-d,0,w-d,c,w-d/2,c,w,c,w,0,w,0,w,-.6*c,w+(f-w)/6,0,f,0),y.push(w-d,1,w,1,w,1),d*=a*a),y.push(w,1,t,s,u,s,o,s,f,1,f,1),a*=.95,l=C/(f-o),w=f,!(.999<s));r++);if(n.endAtStart&&"false"!==n.endAtStart){if(u=-.1,y.unshift(u,1,u,1,-.07,0),p)for(u-=d=2.5*p,y.unshift(u,1,u,1,u,1),B.splice(0,6),B.unshift(u,0,u,0,u,1,u+d/2,1,u+d,1,u+d,0,u+d,0,u+d,-.6,u+d+.033,0),r=0;r<B.length;r+=2)B[r]-=u;for(r=0;r<y.length;r+=2)y[r]-=u,y[r+1]=1-y[r+1]}return d&&(i(B),B[2]="C"+B[2],j(n.squashID||e+"-squash","M"+B.join(","))),i(y),y[2]="C"+y[2],j(e,"M"+y.join(","))},o=(CustomBounce.create=function create(e,n){return t(e,n)},CustomBounce.register=function register(e){n=e,h()},CustomBounce);function CustomBounce(e,n){this.ease=t(e,n)}g()&&n.registerPlugin(o),o.version="3.14.2",e.CustomBounce=o,e.default=o;if (typeof(window)==="undefined"||window!==e){Object.defineProperty(e,"__esModule",{value:!0})} else {delete e.default}});
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"CustomBounce.min.js","sources":["../src/CustomBounce.js"],"sourcesContent":["/*!\n * CustomBounce 3.14.2\n * https://gsap.com\n *\n * @license Copyright 2008-2025, GreenSock. All rights reserved.\n * Subject to the terms at https://gsap.com/standard-license\n * @author: Jack Doyle, jack@greensock.com\n*/\n/* eslint-disable */\n\nlet gsap, _coreInitted, createCustomEase,\n\t_getGSAP = () => gsap || (typeof(window) !== \"undefined\" && (gsap = window.gsap) && gsap.registerPlugin && gsap),\n\t_initCore = required => {\n\t\tgsap = _getGSAP();\n\t\tcreateCustomEase = gsap && gsap.parseEase(\"_CE\");\n\t\tif (createCustomEase) {\n\t\t\t_coreInitted = 1;\n\t\t\tgsap.parseEase(\"bounce\").config = vars => typeof(vars) === \"object\" ? _create(\"\", vars) : _create(\"bounce(\" + vars + \")\", {strength:+vars});\n\t\t} else {\n\t\t\trequired && console.warn(\"Please gsap.registerPlugin(CustomEase, CustomBounce)\");\n\t\t}\n\t},\n\t_normalizeX = a => { //scales all the x values in an array [x, y, x, y...] AND rounds them to the closest hundredth (decimal)\n\t\tlet l = a.length,\n\t\t\ts = 1 / a[l - 2],\n\t\t\trnd = 1000,\n\t\t\ti;\n\t\tfor (i = 2; i < l; i += 2) {\n\t\t\ta[i] = ~~(a[i] * s * rnd) / rnd;\n\t\t}\n\t\ta[l - 2] = 1; //in case there are any rounding errors. x should always end at 1.\n\t},\n\t_bonusValidated = 1, //<name>CustomBounce</name>\n\t_create = (id, vars) => {\n\t\tif (!_coreInitted) {\n\t\t\t_initCore(1);\n\t\t}\n\t\tvars = vars || {};\n\t\tif (_bonusValidated) {\n\t\t\tlet max = 0.999,\n\t\t\t\tdecay = Math.min(max, vars.strength || 0.7), // Math.min(0.999, 1 - 0.3 / (vars.strength || 1)),\n\t\t\t\tdecayX = decay,\n\t\t\t\tgap = (vars.squash || 0) / 100,\n\t\t\t\toriginalGap = gap,\n\t\t\t\tslope = 1 / 0.03,\n\t\t\t\tw = 0.2,\n\t\t\t\th = 1,\n\t\t\t\tprevX = 0.1,\n\t\t\t\tpath = [0, 0, 0.07, 0, 0.1, 1, 0.1, 1],\n\t\t\t\tsquashPath = [0, 0, 0, 0, 0.1, 0, 0.1, 0],\n\t\t\t\tcp1, cp2, x, y, i, nextX, squishMagnitude;\n\t\t\tfor (i = 0; i < 200; i++) {\n\t\t\t\tw *= decayX * ((decayX + 1) / 2);\n\t\t\t\th *= decay * decay;\n\t\t\t\tnextX = prevX + w;\n\t\t\t\tx = prevX + w * 0.49;\n\t\t\t\ty = 1 - h;\n\t\t\t\tcp1 = prevX + h / slope;\n\t\t\t\tcp2 = x + (x - cp1) * 0.8;\n\n\t\t\t\tif (gap) {\n\t\t\t\t\tprevX += gap;\n\t\t\t\t\tcp1 += gap;\n\t\t\t\t\tx += gap;\n\t\t\t\t\tcp2 += gap;\n\t\t\t\t\tnextX += gap;\n\t\t\t\t\tsquishMagnitude = gap / originalGap;\n\t\t\t\t\tsquashPath.push(\n\t\t\t\t\t\tprevX - gap, 0,\n\t\t\t\t\t\tprevX - gap, squishMagnitude,\n\t\t\t\t\t\tprevX - gap / 2, squishMagnitude, //center peak anchor\n\t\t\t\t\t\tprevX, squishMagnitude,\n\t\t\t\t\t\tprevX, 0,\n\t\t\t\t\t\tprevX, 0, //base anchor\n\t\t\t\t\t\tprevX, squishMagnitude * -0.6,\n\t\t\t\t\t\tprevX + (nextX - prevX) / 6, 0,\n\t\t\t\t\t\tnextX, 0\n\t\t\t\t\t);\n\t\t\t\t\tpath.push(prevX - gap, 1,\n\t\t\t\t\t\tprevX, 1,\n\t\t\t\t\t\tprevX, 1);\n\t\t\t\t\tgap *= decay * decay;\n\t\t\t\t}\n\n\t\t\t\tpath.push(prevX, 1,\n\t\t\t\t\tcp1, y,\n\t\t\t\t\tx, y,\n\t\t\t\t\tcp2, y,\n\t\t\t\t\tnextX, 1,\n\t\t\t\t\tnextX, 1);\n\n\t\t\t\tdecay *= 0.95;\n\t\t\t\tslope = h / (nextX - cp2);\n\t\t\t\tprevX = nextX;\n\t\t\t\tif (y > max) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (vars.endAtStart && vars.endAtStart !== \"false\") {\n\t\t\t\tx = -0.1;\n\t\t\t\tpath.unshift(x, 1, x, 1, -0.07, 0);\n\t\t\t\tif (originalGap) {\n\t\t\t\t\tgap = originalGap * 2.5; //make the initial anticipation squash longer (more realistic)\n\t\t\t\t\tx -= gap;\n\t\t\t\t\tpath.unshift(x, 1, x, 1, x, 1);\n\t\t\t\t\tsquashPath.splice(0, 6);\n\t\t\t\t\tsquashPath.unshift(x, 0, x, 0, x, 1, x + gap / 2, 1, x + gap, 1, x + gap, 0, x + gap, 0, x + gap, -0.6, x + gap + 0.033, 0);\n\t\t\t\t\tfor (i = 0; i < squashPath.length; i+=2) {\n\t\t\t\t\t\tsquashPath[i] -= x;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (i = 0; i < path.length; i+=2) {\n\t\t\t\t\tpath[i] -= x;\n\t\t\t\t\tpath[i+1] = 1 - path[i+1];\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (gap) {\n\t\t\t\t_normalizeX(squashPath);\n\t\t\t\tsquashPath[2] = \"C\" + squashPath[2];\n\t\t\t\tcreateCustomEase(vars.squashID || (id + \"-squash\"), \"M\" + squashPath.join(\",\"));\n\t\t\t}\n\t\t\t_normalizeX(path);\n\t\t\tpath[2] = \"C\" + path[2];\n\t\t\treturn createCustomEase(id, \"M\" + path.join(\",\"));\n\t\t}\n\t};\n\nexport class CustomBounce {\n\n\tconstructor(id, vars) {\n\t\tthis.ease = _create(id, vars);\n\t}\n\n\tstatic create(id, vars) {\n\t\treturn _create(id, vars);\n\t}\n\n\tstatic register(core) {\n\t\tgsap = core;\n\t\t_initCore();\n\t}\n\n}\n\n_getGSAP() && gsap.registerPlugin(CustomBounce);\n\nCustomBounce.version = \"3.14.2\";\n\nexport { CustomBounce as default };"],"names":["_getGSAP","gsap","window","registerPlugin","_initCore","required","createCustomEase","parseEase","_coreInitted","config","vars","_create","strength","console","warn","_normalizeX","a","i","l","length","s","id","cp1","cp2","x","y","nextX","squishMagnitude","decay","Math","min","decayX","gap","squash","originalGap","slope","wLine truncated
|
||||
+721
@@ -0,0 +1,721 @@
|
||||
(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 _svgPathExp = /[achlmqstvz]|(-?\d*\.?\d*(?:e[\-+]?\d+)?)[0-9]/ig,
|
||||
_scientific = /[\+\-]?\d*\.?\d+e[\+\-]?\d+/ig,
|
||||
_DEG2RAD = Math.PI / 180,
|
||||
_sin = Math.sin,
|
||||
_cos = Math.cos,
|
||||
_abs = Math.abs,
|
||||
_sqrt = Math.sqrt,
|
||||
_isNumber = function _isNumber(value) {
|
||||
return typeof value === "number";
|
||||
},
|
||||
_roundingNum = 1e5,
|
||||
_round = function _round(value) {
|
||||
return Math.round(value * _roundingNum) / _roundingNum || 0;
|
||||
},
|
||||
_segmentIsClosed = function _segmentIsClosed(segment) {
|
||||
return segment.closed = Math.abs(segment[0] - segment[segment.length - 2]) < 0.001 && Math.abs(segment[1] - segment[segment.length - 1]) < 0.001;
|
||||
};
|
||||
function transformRawPath(rawPath, a, b, c, d, tx, ty) {
|
||||
var j = rawPath.length,
|
||||
segment,
|
||||
l,
|
||||
i,
|
||||
x,
|
||||
y;
|
||||
|
||||
while (--j > -1) {
|
||||
segment = rawPath[j];
|
||||
l = segment.length;
|
||||
|
||||
for (i = 0; i < l; i += 2) {
|
||||
x = segment[i];
|
||||
y = segment[i + 1];
|
||||
segment[i] = x * a + y * c + tx;
|
||||
segment[i + 1] = x * b + y * d + ty;
|
||||
}
|
||||
}
|
||||
|
||||
rawPath._dirty = 1;
|
||||
return rawPath;
|
||||
}
|
||||
|
||||
function arcToSegment(lastX, lastY, rx, ry, angle, largeArcFlag, sweepFlag, x, y) {
|
||||
if (lastX === x && lastY === y) {
|
||||
return;
|
||||
}
|
||||
|
||||
rx = _abs(rx);
|
||||
ry = _abs(ry);
|
||||
|
||||
var angleRad = angle % 360 * _DEG2RAD,
|
||||
cosAngle = _cos(angleRad),
|
||||
sinAngle = _sin(angleRad),
|
||||
PI = Math.PI,
|
||||
TWOPI = PI * 2,
|
||||
dx2 = (lastX - x) / 2,
|
||||
dy2 = (lastY - y) / 2,
|
||||
x1 = cosAngle * dx2 + sinAngle * dy2,
|
||||
y1 = -sinAngle * dx2 + cosAngle * dy2,
|
||||
x1_sq = x1 * x1,
|
||||
y1_sq = y1 * y1,
|
||||
radiiCheck = x1_sq / (rx * rx) + y1_sq / (ry * ry);
|
||||
|
||||
if (radiiCheck > 1) {
|
||||
rx = _sqrt(radiiCheck) * rx;
|
||||
ry = _sqrt(radiiCheck) * ry;
|
||||
}
|
||||
|
||||
var rx_sq = rx * rx,
|
||||
ry_sq = ry * ry,
|
||||
sq = (rx_sq * ry_sq - rx_sq * y1_sq - ry_sq * x1_sq) / (rx_sq * y1_sq + ry_sq * x1_sq);
|
||||
|
||||
if (sq < 0) {
|
||||
sq = 0;
|
||||
}
|
||||
|
||||
var coef = (largeArcFlag === sweepFlag ? -1 : 1) * _sqrt(sq),
|
||||
cx1 = coef * (rx * y1 / ry),
|
||||
cy1 = coef * -(ry * x1 / rx),
|
||||
sx2 = (lastX + x) / 2,
|
||||
sy2 = (lastY + y) / 2,
|
||||
cx = sx2 + (cosAngle * cx1 - sinAngle * cy1),
|
||||
cy = sy2 + (sinAngle * cx1 + cosAngle * cy1),
|
||||
ux = (x1 - cx1) / rx,
|
||||
uy = (y1 - cy1) / ry,
|
||||
vx = (-x1 - cx1) / rx,
|
||||
vy = (-y1 - cy1) / ry,
|
||||
temp = ux * ux + uy * uy,
|
||||
angleStart = (uy < 0 ? -1 : 1) * Math.acos(ux / _sqrt(temp)),
|
||||
angleExtent = (ux * vy - uy * vx < 0 ? -1 : 1) * Math.acos((ux * vx + uy * vy) / _sqrt(temp * (vx * vx + vy * vy)));
|
||||
|
||||
isNaN(angleExtent) && (angleExtent = PI);
|
||||
|
||||
if (!sweepFlag && angleExtent > 0) {
|
||||
angleExtent -= TWOPI;
|
||||
} else if (sweepFlag && angleExtent < 0) {
|
||||
angleExtent += TWOPI;
|
||||
}
|
||||
|
||||
angleStart %= TWOPI;
|
||||
angleExtent %= TWOPI;
|
||||
|
||||
var segments = Math.ceil(_abs(angleExtent) / (TWOPI / 4)),
|
||||
rawPath = [],
|
||||
angleIncrement = angleExtent / segments,
|
||||
controlLength = 4 / 3 * _sin(angleIncrement / 2) / (1 + _cos(angleIncrement / 2)),
|
||||
ma = cosAngle * rx,
|
||||
mb = sinAngle * rx,
|
||||
mc = sinAngle * -ry,
|
||||
md = cosAngle * ry,
|
||||
i;
|
||||
|
||||
for (i = 0; i < segments; i++) {
|
||||
angle = angleStart + i * angleIncrement;
|
||||
x1 = _cos(angle);
|
||||
y1 = _sin(angle);
|
||||
ux = _cos(angle += angleIncrement);
|
||||
uy = _sin(angle);
|
||||
rawPath.push(x1 - controlLength * y1, y1 + controlLength * x1, ux + controlLength * uy, uy - controlLength * ux, ux, uy);
|
||||
}
|
||||
|
||||
for (i = 0; i < rawPath.length; i += 2) {
|
||||
x1 = rawPath[i];
|
||||
y1 = rawPath[i + 1];
|
||||
rawPath[i] = x1 * ma + y1 * mc + cx;
|
||||
rawPath[i + 1] = x1 * mb + y1 * md + cy;
|
||||
}
|
||||
|
||||
rawPath[i - 2] = x;
|
||||
rawPath[i - 1] = y;
|
||||
return rawPath;
|
||||
}
|
||||
|
||||
function stringToRawPath(d) {
|
||||
var a = (d + "").replace(_scientific, function (m) {
|
||||
var n = +m;
|
||||
return n < 0.0001 && n > -0.0001 ? 0 : n;
|
||||
}).match(_svgPathExp) || [],
|
||||
path = [],
|
||||
relativeX = 0,
|
||||
relativeY = 0,
|
||||
twoThirds = 2 / 3,
|
||||
elements = a.length,
|
||||
points = 0,
|
||||
errorMessage = "ERROR: malformed path: " + d,
|
||||
i,
|
||||
j,
|
||||
x,
|
||||
y,
|
||||
command,
|
||||
isRelative,
|
||||
segment,
|
||||
startX,
|
||||
startY,
|
||||
difX,
|
||||
difY,
|
||||
beziers,
|
||||
prevCommand,
|
||||
flag1,
|
||||
flag2,
|
||||
line = function line(sx, sy, ex, ey) {
|
||||
difX = (ex - sx) / 3;
|
||||
difY = (ey - sy) / 3;
|
||||
segment.push(sx + difX, sy + difY, ex - difX, ey - difY, ex, ey);
|
||||
};
|
||||
|
||||
if (!d || !isNaN(a[0]) || isNaN(a[1])) {
|
||||
console.log(errorMessage);
|
||||
return path;
|
||||
}
|
||||
|
||||
for (i = 0; i < elements; i++) {
|
||||
prevCommand = command;
|
||||
|
||||
if (isNaN(a[i])) {
|
||||
command = a[i].toUpperCase();
|
||||
isRelative = command !== a[i];
|
||||
} else {
|
||||
i--;
|
||||
}
|
||||
|
||||
x = +a[i + 1];
|
||||
y = +a[i + 2];
|
||||
|
||||
if (isRelative) {
|
||||
x += relativeX;
|
||||
y += relativeY;
|
||||
}
|
||||
|
||||
if (!i) {
|
||||
startX = x;
|
||||
startY = y;
|
||||
}
|
||||
|
||||
if (command === "M") {
|
||||
if (segment) {
|
||||
if (segment.length < 8) {
|
||||
path.length -= 1;
|
||||
} else {
|
||||
points += segment.length;
|
||||
}
|
||||
|
||||
_segmentIsClosed(segment);
|
||||
}
|
||||
|
||||
relativeX = startX = x;
|
||||
relativeY = startY = y;
|
||||
segment = [x, y];
|
||||
path.push(segment);
|
||||
i += 2;
|
||||
command = "L";
|
||||
} else if (command === "C") {
|
||||
if (!segment) {
|
||||
segment = [0, 0];
|
||||
}
|
||||
|
||||
if (!isRelative) {
|
||||
relativeX = relativeY = 0;
|
||||
}
|
||||
|
||||
segment.push(x, y, relativeX + a[i + 3] * 1, relativeY + a[i + 4] * 1, relativeX += a[i + 5] * 1, relativeY += a[i + 6] * 1);
|
||||
i += 6;
|
||||
} else if (command === "S") {
|
||||
difX = relativeX;
|
||||
difY = relativeY;
|
||||
|
||||
if (prevCommand === "C" || prevCommand === "S") {
|
||||
difX += relativeX - segment[segment.length - 4];
|
||||
difY += relativeY - segment[segment.length - 3];
|
||||
}
|
||||
|
||||
if (!isRelative) {
|
||||
relativeX = relativeY = 0;
|
||||
}
|
||||
|
||||
segment.push(difX, difY, x, y, relativeX += a[i + 3] * 1, relativeY += a[i + 4] * 1);
|
||||
i += 4;
|
||||
} else if (command === "Q") {
|
||||
difX = relativeX + (x - relativeX) * twoThirds;
|
||||
difY = relativeY + (y - relativeY) * twoThirds;
|
||||
|
||||
if (!isRelative) {
|
||||
relativeX = relativeY = 0;
|
||||
}
|
||||
|
||||
relativeX += a[i + 3] * 1;
|
||||
relativeY += a[i + 4] * 1;
|
||||
segment.push(difX, difY, relativeX + (x - relativeX) * twoThirds, relativeY + (y - relativeY) * twoThirds, relativeX, relativeY);
|
||||
i += 4;
|
||||
} else if (command === "T") {
|
||||
difX = relativeX - segment[segment.length - 4];
|
||||
difY = relativeY - segment[segment.length - 3];
|
||||
segment.push(relativeX + difX, relativeY + difY, x + (relativeX + difX * 1.5 - x) * twoThirds, y + (relativeY + difY * 1.5 - y) * twoThirds, relativeX = x, relativeY = y);
|
||||
i += 2;
|
||||
} else if (command === "H") {
|
||||
line(relativeX, relativeY, relativeX = x, relativeY);
|
||||
i += 1;
|
||||
} else if (command === "V") {
|
||||
line(relativeX, relativeY, relativeX, relativeY = x + (isRelative ? relativeY - relativeX : 0));
|
||||
i += 1;
|
||||
} else if (command === "L" || command === "Z") {
|
||||
if (command === "Z") {
|
||||
x = startX;
|
||||
y = startY;
|
||||
segment.closed = true;
|
||||
}
|
||||
|
||||
if (command === "L" || _abs(relativeX - x) > 0.5 || _abs(relativeY - y) > 0.5) {
|
||||
line(relativeX, relativeY, x, y);
|
||||
|
||||
if (command === "L") {
|
||||
i += 2;
|
||||
}
|
||||
}
|
||||
|
||||
relativeX = x;
|
||||
relativeY = y;
|
||||
} else if (command === "A") {
|
||||
flag1 = a[i + 4];
|
||||
flag2 = a[i + 5];
|
||||
difX = a[i + 6];
|
||||
difY = a[i + 7];
|
||||
j = 7;
|
||||
|
||||
if (flag1.length > 1) {
|
||||
if (flag1.length < 3) {
|
||||
difY = difX;
|
||||
difX = flag2;
|
||||
j--;
|
||||
} else {
|
||||
difY = flag2;
|
||||
difX = flag1.substr(2);
|
||||
j -= 2;
|
||||
}
|
||||
|
||||
flag2 = flag1.charAt(1);
|
||||
flag1 = flag1.charAt(0);
|
||||
}
|
||||
|
||||
beziers = arcToSegment(relativeX, relativeY, +a[i + 1], +a[i + 2], +a[i + 3], +flag1, +flag2, (isRelative ? relativeX : 0) + difX * 1, (isRelative ? relativeY : 0) + difY * 1);
|
||||
i += j;
|
||||
|
||||
if (beziers) {
|
||||
for (j = 0; j < beziers.length; j++) {
|
||||
segment.push(beziers[j]);
|
||||
}
|
||||
}
|
||||
|
||||
relativeX = segment[segment.length - 2];
|
||||
relativeY = segment[segment.length - 1];
|
||||
} else {
|
||||
console.log(errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
i = segment.length;
|
||||
|
||||
if (i < 6) {
|
||||
path.pop();
|
||||
i = 0;
|
||||
} else {
|
||||
_segmentIsClosed(segment);
|
||||
}
|
||||
|
||||
path.totalPoints = points + i;
|
||||
return path;
|
||||
}
|
||||
function rawPathToString(rawPath) {
|
||||
if (_isNumber(rawPath[0])) {
|
||||
rawPath = [rawPath];
|
||||
}
|
||||
|
||||
var result = "",
|
||||
l = rawPath.length,
|
||||
sl,
|
||||
s,
|
||||
i,
|
||||
segment;
|
||||
|
||||
for (s = 0; s < l; s++) {
|
||||
segment = rawPath[s];
|
||||
result += "M" + _round(segment[0]) + "," + _round(segment[1]) + " C";
|
||||
sl = segment.length;
|
||||
|
||||
for (i = 2; i < sl; i++) {
|
||||
result += _round(segment[i++]) + "," + _round(segment[i++]) + " " + _round(segment[i++]) + "," + _round(segment[i++]) + " " + _round(segment[i++]) + "," + _round(segment[i]) + " ";
|
||||
}
|
||||
|
||||
if (segment.closed) {
|
||||
result += "z";
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*!
|
||||
* CustomEase 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 gsap,
|
||||
_coreInitted,
|
||||
_getGSAP = function _getGSAP() {
|
||||
return gsap || typeof window !== "undefined" && (gsap = window.gsap) && gsap.registerPlugin && gsap;
|
||||
},
|
||||
_initCore = function _initCore() {
|
||||
gsap = _getGSAP();
|
||||
|
||||
if (gsap) {
|
||||
gsap.registerEase("_CE", CustomEase.create);
|
||||
_coreInitted = 1;
|
||||
} else {
|
||||
console.warn("Please gsap.registerPlugin(CustomEase)");
|
||||
}
|
||||
},
|
||||
_bigNum = 1e20,
|
||||
_round$1 = function _round(value) {
|
||||
return ~~(value * 1000 + (value < 0 ? -.5 : .5)) / 1000;
|
||||
},
|
||||
_numExp = /[-+=.]*\d+[.e\-+]*\d*[e\-+]*\d*/gi,
|
||||
_needsParsingExp = /[cLlsSaAhHvVtTqQ]/g,
|
||||
_findMinimum = function _findMinimum(values) {
|
||||
var l = values.length,
|
||||
min = _bigNum,
|
||||
i;
|
||||
|
||||
for (i = 1; i < l; i += 6) {
|
||||
+values[i] < min && (min = +values[i]);
|
||||
}
|
||||
|
||||
return min;
|
||||
},
|
||||
_normalize = function _normalize(values, height, originY) {
|
||||
if (!originY && originY !== 0) {
|
||||
originY = Math.max(+values[values.length - 1], +values[1]);
|
||||
}
|
||||
|
||||
var tx = +values[0] * -1,
|
||||
ty = -originY,
|
||||
l = values.length,
|
||||
sx = 1 / (+values[l - 2] + tx),
|
||||
sy = -height || (Math.abs(+values[l - 1] - +values[1]) < 0.01 * (+values[l - 2] - +values[0]) ? _findMinimum(values) + ty : +values[l - 1] + ty),
|
||||
i;
|
||||
|
||||
if (sy) {
|
||||
sy = 1 / sy;
|
||||
} else {
|
||||
sy = -sx;
|
||||
}
|
||||
|
||||
for (i = 0; i < l; i += 2) {
|
||||
values[i] = (+values[i] + tx) * sx;
|
||||
values[i + 1] = (+values[i + 1] + ty) * sy;
|
||||
}
|
||||
},
|
||||
_bezierToPoints = function _bezierToPoints(x1, y1, x2, y2, x3, y3, x4, y4, threshold, points, index) {
|
||||
var x12 = (x1 + x2) / 2,
|
||||
y12 = (y1 + y2) / 2,
|
||||
x23 = (x2 + x3) / 2,
|
||||
y23 = (y2 + y3) / 2,
|
||||
x34 = (x3 + x4) / 2,
|
||||
y34 = (y3 + y4) / 2,
|
||||
x123 = (x12 + x23) / 2,
|
||||
y123 = (y12 + y23) / 2,
|
||||
x234 = (x23 + x34) / 2,
|
||||
y234 = (y23 + y34) / 2,
|
||||
x1234 = (x123 + x234) / 2,
|
||||
y1234 = (y123 + y234) / 2,
|
||||
dx = x4 - x1,
|
||||
dy = y4 - y1,
|
||||
d2 = Math.abs((x2 - x4) * dy - (y2 - y4) * dx),
|
||||
d3 = Math.abs((x3 - x4) * dy - (y3 - y4) * dx),
|
||||
length;
|
||||
|
||||
if (!points) {
|
||||
points = [{
|
||||
x: x1,
|
||||
y: y1
|
||||
}, {
|
||||
x: x4,
|
||||
y: y4
|
||||
}];
|
||||
index = 1;
|
||||
}
|
||||
|
||||
points.splice(index || points.length - 1, 0, {
|
||||
x: x1234,
|
||||
y: y1234
|
||||
});
|
||||
|
||||
if ((d2 + d3) * (d2 + d3) > threshold * (dx * dx + dy * dy)) {
|
||||
length = points.length;
|
||||
|
||||
_bezierToPoints(x1, y1, x12, y12, x123, y123, x1234, y1234, threshold, points, index);
|
||||
|
||||
_bezierToPoints(x1234, y1234, x234, y234, x34, y34, x4, y4, threshold, points, index + 1 + (points.length - length));
|
||||
}
|
||||
|
||||
return points;
|
||||
};
|
||||
|
||||
var CustomEase = function () {
|
||||
function CustomEase(id, data, config) {
|
||||
_coreInitted || _initCore();
|
||||
this.id = id;
|
||||
this.setData(data, config);
|
||||
}
|
||||
|
||||
var _proto = CustomEase.prototype;
|
||||
|
||||
_proto.setData = function setData(data, config) {
|
||||
config = config || {};
|
||||
data = data || "0,0,1,1";
|
||||
var values = data.match(_numExp),
|
||||
closest = 1,
|
||||
points = [],
|
||||
lookup = [],
|
||||
precision = config.precision || 1,
|
||||
fast = precision <= 1,
|
||||
l,
|
||||
a1,
|
||||
a2,
|
||||
i,
|
||||
inc,
|
||||
j,
|
||||
point,
|
||||
prevPoint,
|
||||
p;
|
||||
this.data = data;
|
||||
|
||||
if (_needsParsingExp.test(data) || ~data.indexOf("M") && data.indexOf("C") < 0) {
|
||||
values = stringToRawPath(data)[0];
|
||||
}
|
||||
|
||||
l = values.length;
|
||||
|
||||
if (l === 4) {
|
||||
values.unshift(0, 0);
|
||||
values.push(1, 1);
|
||||
l = 8;
|
||||
} else if ((l - 2) % 6) {
|
||||
throw "Invalid CustomEase";
|
||||
}
|
||||
|
||||
if (+values[0] !== 0 || +values[l - 2] !== 1) {
|
||||
_normalize(values, config.height, config.originY);
|
||||
}
|
||||
|
||||
this.segment = values;
|
||||
|
||||
for (i = 2; i < l; i += 6) {
|
||||
a1 = {
|
||||
x: +values[i - 2],
|
||||
y: +values[i - 1]
|
||||
};
|
||||
a2 = {
|
||||
x: +values[i + 4],
|
||||
y: +values[i + 5]
|
||||
};
|
||||
points.push(a1, a2);
|
||||
|
||||
_bezierToPoints(a1.x, a1.y, +values[i], +values[i + 1], +values[i + 2], +values[i + 3], a2.x, a2.y, 1 / (precision * 200000), points, points.length - 1);
|
||||
}
|
||||
|
||||
l = points.length;
|
||||
|
||||
for (i = 0; i < l; i++) {
|
||||
point = points[i];
|
||||
prevPoint = points[i - 1] || point;
|
||||
|
||||
if ((point.x > prevPoint.x || prevPoint.y !== point.y && prevPoint.x === point.x || point === prevPoint) && point.x <= 1) {
|
||||
prevPoint.cx = point.x - prevPoint.x;
|
||||
prevPoint.cy = point.y - prevPoint.y;
|
||||
prevPoint.n = point;
|
||||
prevPoint.nx = point.x;
|
||||
|
||||
if (fast && i > 1 && Math.abs(prevPoint.cy / prevPoint.cx - points[i - 2].cy / points[i - 2].cx) > 2) {
|
||||
fast = 0;
|
||||
}
|
||||
|
||||
if (prevPoint.cx < closest) {
|
||||
if (!prevPoint.cx) {
|
||||
prevPoint.cx = 0.001;
|
||||
|
||||
if (i === l - 1) {
|
||||
prevPoint.x -= 0.001;
|
||||
closest = Math.min(closest, 0.001);
|
||||
fast = 0;
|
||||
}
|
||||
} else {
|
||||
closest = prevPoint.cx;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
points.splice(i--, 1);
|
||||
l--;
|
||||
}
|
||||
}
|
||||
|
||||
l = 1 / closest + 1 | 0;
|
||||
inc = 1 / l;
|
||||
j = 0;
|
||||
point = points[0];
|
||||
|
||||
if (fast) {
|
||||
for (i = 0; i < l; i++) {
|
||||
p = i * inc;
|
||||
|
||||
if (point.nx < p) {
|
||||
point = points[++j];
|
||||
}
|
||||
|
||||
a1 = point.y + (p - point.x) / point.cx * point.cy;
|
||||
lookup[i] = {
|
||||
x: p,
|
||||
cx: inc,
|
||||
y: a1,
|
||||
cy: 0,
|
||||
nx: 9
|
||||
};
|
||||
|
||||
if (i) {
|
||||
lookup[i - 1].cy = a1 - lookup[i - 1].y;
|
||||
}
|
||||
}
|
||||
|
||||
j = points[points.length - 1];
|
||||
lookup[l - 1].cy = j.y - a1;
|
||||
lookup[l - 1].cx = j.x - lookup[lookup.length - 1].x;
|
||||
} else {
|
||||
for (i = 0; i < l; i++) {
|
||||
if (point.nx < i * inc) {
|
||||
point = points[++j];
|
||||
}
|
||||
|
||||
lookup[i] = point;
|
||||
}
|
||||
|
||||
if (j < points.length - 1) {
|
||||
lookup[i - 1] = points[points.length - 2];
|
||||
}
|
||||
}
|
||||
|
||||
this.ease = function (p) {
|
||||
var point = lookup[p * l | 0] || lookup[l - 1];
|
||||
|
||||
if (point.nx < p) {
|
||||
point = point.n;
|
||||
}
|
||||
|
||||
return point.y + (p - point.x) / point.cx * point.cy;
|
||||
};
|
||||
|
||||
this.ease.custom = this;
|
||||
this.id && gsap && gsap.registerEase(this.id, this.ease);
|
||||
return this;
|
||||
};
|
||||
|
||||
_proto.getSVGData = function getSVGData(config) {
|
||||
return CustomEase.getSVGData(this, config);
|
||||
};
|
||||
|
||||
CustomEase.create = function create(id, data, config) {
|
||||
return new CustomEase(id, data, config).ease;
|
||||
};
|
||||
|
||||
CustomEase.register = function register(core) {
|
||||
gsap = core;
|
||||
|
||||
_initCore();
|
||||
};
|
||||
|
||||
CustomEase.get = function get(id) {
|
||||
return gsap.parseEase(id);
|
||||
};
|
||||
|
||||
CustomEase.getSVGData = function getSVGData(ease, config) {
|
||||
config = config || {};
|
||||
var width = config.width || 100,
|
||||
height = config.height || 100,
|
||||
x = config.x || 0,
|
||||
y = (config.y || 0) + height,
|
||||
e = gsap.utils.toArray(config.path)[0],
|
||||
a,
|
||||
slope,
|
||||
i,
|
||||
inc,
|
||||
tx,
|
||||
ty,
|
||||
precision,
|
||||
threshold,
|
||||
prevX,
|
||||
prevY;
|
||||
|
||||
if (config.invert) {
|
||||
height = -height;
|
||||
y = 0;
|
||||
}
|
||||
|
||||
if (typeof ease === "string") {
|
||||
ease = gsap.parseEase(ease);
|
||||
}
|
||||
|
||||
if (ease.custom) {
|
||||
ease = ease.custom;
|
||||
}
|
||||
|
||||
if (ease instanceof CustomEase) {
|
||||
a = rawPathToString(transformRawPath([ease.segment.slice(0)], width, 0, 0, -height, x, y));
|
||||
} else {
|
||||
a = [x, y];
|
||||
precision = Math.max(5, (config.precision || 1) * 200);
|
||||
inc = 1 / precision;
|
||||
precision += 2;
|
||||
threshold = 5 / precision;
|
||||
prevX = _round$1(x + inc * width);
|
||||
prevY = _round$1(y + ease(inc) * -height);
|
||||
slope = (prevY - y) / (prevX - x);
|
||||
|
||||
for (i = 2; i < precision; i++) {
|
||||
tx = _round$1(x + i * inc * width);
|
||||
ty = _round$1(y + ease(i * inc) * -height);
|
||||
|
||||
if (Math.abs((ty - prevY) / (tx - prevX) - slope) > threshold || i === precision - 1) {
|
||||
a.push(prevX, prevY);
|
||||
slope = (ty - prevY) / (tx - prevX);
|
||||
}
|
||||
|
||||
prevX = tx;
|
||||
prevY = ty;
|
||||
}
|
||||
|
||||
a = "M" + a.join(",");
|
||||
}
|
||||
|
||||
e && e.setAttribute("d", a);
|
||||
return a;
|
||||
};
|
||||
|
||||
return CustomEase;
|
||||
}();
|
||||
CustomEase.version = "3.14.2";
|
||||
CustomEase.headless = true;
|
||||
_getGSAP() && gsap.registerPlugin(CustomEase);
|
||||
|
||||
exports.CustomEase = CustomEase;
|
||||
exports.default = CustomEase;
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
})));
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
/*!
|
||||
* CustomEase 3.14.2
|
||||
* https://gsap.com
|
||||
*
|
||||
* @license Copyright 2025, GreenSock. All rights reserved.
|
||||
* Subject to the terms at https://gsap.com/standard-license.
|
||||
* @author: Jack Doyle, jack@greensock.com
|
||||
*/
|
||||
|
||||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).window=e.window||{})}(this,function(e){"use strict";function m(e){return Math.round(1e5*e)/1e5||0}function n(e){return e.closed=Math.abs(e[0]-e[e.length-2])<.001&&Math.abs(e[1]-e[e.length-1])<.001}var w=/[achlmqstvz]|(-?\d*\.?\d*(?:e[\-+]?\d+)?)[0-9]/gi,P=/[\+\-]?\d*\.?\d+e[\+\-]?\d+/gi,Y=Math.PI/180,k=Math.sin,B=Math.cos,F=Math.abs,J=Math.sqrt;function arcToSegment(e,t,n,s,a,r,i,o,h){if(e!==o||t!==h){n=F(n),s=F(s);var u=a%360*Y,f=B(u),c=k(u),l=Math.PI,g=2*l,m=(e-o)/2,x=(t-h)/2,d=f*m+c*x,y=-c*m+f*x,p=d*d,M=y*y,v=p/(n*n)+M/(s*s);1<v&&(n=J(v)*n,s=J(v)*s);var C=n*n,E=s*s,b=(C*E-C*M-E*p)/(C*M+E*p);b<0&&(b=0);var w=(r===i?-1:1)*J(b),P=n*y/s*w,S=-s*d/n*w,N=f*P-c*S+(e+o)/2,D=c*P+f*S+(t+h)/2,T=(d-P)/n,V=(y-S)/s,_=(-d-P)/n,q=(-y-S)/s,A=T*T+V*V,R=(V<0?-1:1)*Math.acos(T/J(A)),G=(T*q-V*_<0?-1:1)*Math.acos((T*_+V*q)/J(A*(_*_+q*q)));isNaN(G)&&(G=l),!i&&0<G?G-=g:i&&G<0&&(G+=g),R%=g,G%=g;var L,O=Math.ceil(F(G)/(g/4)),j=[],z=G/O,I=4/3*k(z/2)/(1+B(z/2)),H=f*n,Q=c*n,Z=c*-s,U=f*s;for(L=0;L<O;L++)d=B(a=R+L*z),y=k(a),T=B(a+=z),V=k(a),j.push(d-I*y,y+I*d,T+I*V,V-I*T,T,V);for(L=0;L<j.length;L+=2)d=j[L],y=j[L+1],j[L]=d*H+y*Z+N,j[L+1]=d*Q+y*U+D;return j[L-2]=o,j[L-1]=h,j}}function stringToRawPath(e){function fb(e,t,n,s){c=(n-e)/3,l=(s-t)/3,h.push(e+c,t+l,n-c,s-l,n,s)}var t,s,a,r,i,o,h,u,f,c,l,g,m,x,d,y=(e+"").replace(P,function(e){var t=+e;return t<1e-4&&-1e-4<t?0:t}).match(w)||[],p=[],M=0,v=0,C=y.length,E=0,b="ERROR: malformed path: "+e;if(!e||!isNaN(y[0])||isNaN(y[1]))return console.log(b),p;for(t=0;t<C;t++)if(m=i,isNaN(y[t])?o=(i=y[t].toUpperCase())!==y[t]:t--,a=+y[t+1],r=+y[t+2],o&&(a+=M,r+=v),t||(u=a,f=r),"M"===i)h&&(h.length<8?--p.length:E+=h.length,n(h)),M=u=a,v=f=r,h=[a,r],p.push(h),t+=2,i="L";else if("C"===i)o||(M=v=0),(h=h||[0,0]).push(a,r,M+1*y[t+3],v+1*y[t+4],M+=1*y[t+5],v+=1*y[t+6]),t+=6;else if("S"===i)c=M,l=v,"C"!==m&&"S"!==m||(c+=M-h[h.length-4],l+=v-h[h.length-3]),o||(M=v=0),h.push(c,l,a,r,M+=1*y[t+3],v+=1*y[t+4]),t+=4;else if("Q"===i)c=M+2/3*(a-M),l=v+2/3*(r-v),o||(M=v=0),M+=1*y[t+3],v+=1*y[t+4],h.push(c,l,M+2/3*(a-M),v+2/3*(r-v),M,v),t+=4;else if("T"===i)c=M-h[h.length-4],l=v-h[h.length-3],h.push(M+c,v+l,a+2/3*(M+1.5*c-a),r+2/3*(v+1.5*l-r),M=a,v=r),t+=2;else if("H"===i)fb(M,v,M=a,v),t+=1;else if("V"===i)fb(M,v,M,v=a+(o?v-M:0)),t+=1;else if("L"===i||"Z"===i)"Z"===i&&(a=u,r=f,h.closed=!0),("L"===i||.5<F(M-a)||.5<F(v-r))&&(fb(M,v,a,r),"L"===i&&(t+=2)),M=a,v=r;else if("A"===i){if(x=y[t+4],d=y[t+5],c=y[t+6],l=y[t+7],s=7,1<x.length&&(x.length<3?(l=c,c=d,s--):(l=d,c=x.substr(2),s-=2),d=x.charAt(1),x=x.charAt(0)),g=arcToSegment(M,v,+y[t+1],+y[t+2],+y[t+3],+x,+d,(o?M:0)+1*c,(o?v:0)+1*l),t+=s,g)for(s=0;s<g.length;s++)h.push(g[s]);M=h[h.length-2],v=h[h.length-1]}else console.log(b);return(t=h.length)<6?(p.pop(),t=0):n(h),p.totalPoints=E+t,p}function q(){return M||"undefined"!=typeof window&&(M=window.gsap)&&M.registerPlugin&&M}function r(){(M=q())?(M.registerEase("_CE",i.create),s=1):console.warn("Please gsap.registerPlugin(CustomEase)")}function t(e){return~~(1e3*e+(e<0?-.5:.5))/1e3}function y(e,t,n,s,a,r,i,o,h,u,f){var c,l=(e+n)/2,g=(t+s)/2,m=(n+a)/2,x=(s+r)/2,d=(a+i)/2,p=(r+o)/2,M=(l+m)/2,v=(g+x)/2,C=(m+d)/2,E=(x+p)/2,b=(M+C)/2,w=(v+E)/2,P=i-e,S=o-t,N=Math.abs((n-i)*S-(s-o)*P),D=Math.abs((a-i)*S-(r-o)*P);return u||(u=[{x:e,y:t},{x:i,y:o}],f=1),u.splice(f||u.length-1,0,{x:b,y:w}),h*(P*P+S*S)<(N+D)*(N+D)&&(c=u.length,y(e,t,l,g,M,v,b,w,h,u,f),y(b,w,C,E,d,p,i,o,h,u,f+1+(u.length-c))),u}var M,s,a,p=/[-+=.]*\d+[.e\-+]*\d*[e\-+]*\d*/gi,v=/[cLlsSaAhHvVtTqQ]/g,i=((a=CustomEase.prototype).setData=function setData(e,t){t=t||{};var n,s,a,r,i,o,h,u,f,c=(e=e||"0,0,1,1").match(p),l=1,g=[],m=[],x=t.precision||1,d=x<=1;if(this.data=e,(v.test(e)||~e.indexOf("M")&&e.indexOf("C")<0)&&(c=stringToRawPath(e)[0]),4===(n=c.length))c.unshift(0,0),c.push(1,1),n=8;else if((n-2)%6)throw"Invalid CustomEase";for(0==+c[0]&&1==+c[n-2]||function _normalize(e,t,n){n||0===n||(n=Math.max(+e[e.length-1],+e[1]));var s,a=-1*e[0],r=-n,i=e.length,o=1/(+e[i-2]+a),h=-t||(Math.abs(e[i-1]-e[1])<.01*(e[i-2]-e[0])?function _findMinimum(e){var t,n=e.length,s=1e20;for(t=1;t<n;t+=6)+e[t]<s&&(s=+e[t]);return s}(e)+r:+e[i-1]+r);for(h=h?1/h:-o,s=0;s<i;s+=2)e[s]=(+e[s]+a)*o,e[s+1]=(+e[s+1]+r)*h}(c,t.height,t.originY),this.segment=c,r=2;r<n;r+=6)s={x:+c[r-2],y:+c[r-1]},a={x:+c[r+4],y:+c[r+5]},g.push(s,a),y(s.x,s.y,+c[r],+c[r+1],+c[r+2],+c[r+3],a.x,a.y,1/(2e5*x),g,g.length-1);for(n=g.length,r=0;r<n;r++)h=g[r],u=g[r-1]||h,(h.x>u.x||u.y!==h.y&&u.x===h.x||h===u)&&h.x<=1?(u.cx=h.x-u.x,u.cy=h.y-u.y,u.n=h,u.nx=h.x,d&&1<r&&2<Math.abs(u.cy/u.cx-g[r-2].cy/g[r-2].cx)&&(d=0),u.cx<l&&(u.cx?l=u.cx:(u.cx=.001,r===n-1&&(u.x-=.001,l=Math.min(l,.001),d=0)))):(g.splice(r--,1),n--);if(i=1/(n=1/l+1|0),h=g[o=0],d){for(r=0;r<n;r++)f=r*i,h.nx<f&&(h=g[++o]),s=h.y+(f-h.x)/h.cx*h.cy,m[r]={x:f,cx:i,y:s,cy:0,nx:9},r&&(m[r-1].cy=s-m[r-1].y);o=g[g.length-1]Line truncated
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"CustomEase.min.js","sources":["../src/utils/paths.js","../src/CustomEase.js"],"sourcesContent":["/*!\n * paths 3.14.2\n * https://gsap.com\n *\n * Copyright 2008-2025, GreenSock. All rights reserved.\n * Subject to the terms at https://gsap.com/standard-license\n * @author: Jack Doyle, jack@greensock.com\n*/\n/* eslint-disable */\n\nlet _svgPathExp = /[achlmqstvz]|(-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?)[0-9]/ig,\n\t_numbersExp = /(?:(-)?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?)[0-9]/ig,\n\t_scientific = /[\\+\\-]?\\d*\\.?\\d+e[\\+\\-]?\\d+/ig,\n\t_selectorExp = /(^[#\\.][a-z]|[a-y][a-z])/i,\n\t_DEG2RAD = Math.PI / 180,\n\t_RAD2DEG = 180 / Math.PI,\n\t_sin = Math.sin,\n\t_cos = Math.cos,\n\t_abs = Math.abs,\n\t_sqrt = Math.sqrt,\n\t_atan2 = Math.atan2,\n\t_largeNum = 1e8,\n\t_isString = value => typeof(value) === \"string\",\n\t_isNumber = value => typeof(value) === \"number\",\n\t_isUndefined = value => typeof(value) === \"undefined\",\n\t_temp = {},\n\t_temp2 = {},\n\t_roundingNum = 1e5,\n\t_wrapProgress = progress => (Math.round((progress + _largeNum) % 1 * _roundingNum) / _roundingNum) || ((progress < 0) ? 0 : 1), //if progress lands on 1, the % will make it 0 which is why we || 1, but not if it's negative because it makes more sense for motion to end at 0 in that case.\n\t_round = value => (Math.round(value * _roundingNum) / _roundingNum) || 0,\n\t_roundPrecise = value => (Math.round(value * 1e10) / 1e10) || 0,\n\t_segmentIsClosed = segment => (segment.closed = Math.abs(segment[0] - segment[segment.length-2]) < 0.001 && Math.abs(segment[1] - segment[segment.length-1]) < 0.001),\n\t_splitSegment = (rawPath, segIndex, i, t) => {\n\t\tlet segment = rawPath[segIndex],\n\t\t\tshift = t === 1 ? 6 : subdivideSegment(segment, i, t);\n\t\tif ((shift || !t) && shift + i + 2 < segment.length) {\n\t\t\trawPath.splice(segIndex, 0, segment.slice(0, i + shift + 2));\n\t\t\tsegment.splice(0, i + shift);\n\t\t\treturn 1;\n\t\t}\n\t},\n\t_getSampleIndex = (samples, length, progress) => {\n\t\t// slightly slower way than doing this (when there's no lookup): segment.lookup[progress < 1 ? ~~(length / segment.minLength) : segment.lookup.length - 1] || 0;\n\t\tlet l = samples.length,\n\t\t\ti = ~~(progress * l);\n\t\tif (samples[i] > length) {\n\t\t\twhile (--i && samples[i] > length) {}\n\t\t\ti < 0 && (i = 0);\n\t\t} else {\n\t\t\twhile (samples[++i] < length && i < l) {}\n\t\t}\n\t\treturn i < l ? i : l - 1;\n\t},\n\t_reverseRawPath = (rawPath, skipOuter) => {\n\t\tlet i = rawPath.length;\n\t\tskipOuter || rawPath.reverse();\n\t\twhile (i--) {\n\t\t\trawPath[i].reversed || reverseSegment(rawPath[i]);\n\t\t}\n\t},\n\t_copyMetaData = (source, copy) => {\n\t\tcopy.totalLength = source.totalLength;\n\t\tif (source.samples) { //segment\n\t\t\tcopy.samples = source.samples.slice(0);\n\t\t\tcopy.lookup = source.lookup.slice(0);\n\t\t\tcopy.minLength = source.minLength;\n\t\t\tcopy.resolution = source.resolution;\n\t\t} else if (source.totalPoints) { //rawPath\n\t\t\tcopy.totalPoints = source.totalPoints;\n\t\t}\n\t\treturn copy;\n\t},\n\t//pushes a new segment into a rawPath, but if its starting values match the ending values of the last segment, it'll merge it into that same segment (to reduce the number of segments)\n\t_appendOrMerge = (rawPath, segment) => {\n\t\tlet index = rawPath.length,\n\t\t\tprevSeg = rawPath[index - 1] || [],\n\t\t\tl = prevSeg.length;\n\t\tif (index && segment[0] === prevSeg[l-2] && segment[1] === prevSeg[l-1]) {\n\t\t\tsegment = prevSeg.concat(segment.slice(2));\n\t\t\tindex--;\n\t\t}\n\t\trawPath[index] = segment;\n\t},\n\t_bestDistance;\n\n/* TERMINOLOGY\n - RawPath - an array of arrays, one for each Segment. A single RawPath could have multiple \"M\" commands, defining Segments (paths aren't always connected).\n - Segment - an array containing a sequence of Cubic Bezier coordinates in alternating x, y, x, y format. Starting anchor, then control point 1, control point 2, and ending anchor, then the next control point 1, control point 2, anchor, etc. Uses less memory than an array with a bunch of {x, y} points.\n - Bezier - a single cubic Bezier with a starting anchor, two control points, and an ending anchor.\n - the variable \"t\" is typically the position along an individual Bezier path (time) and it's NOT linear, meaning it could accelerate/decelerate based on the control points whereas the \"p\" or \"progress\" value is linearly mapped to the whole path, so it shouldn't really accelerate/decelerate based on control points. So a progress of 0.2 would be almost exactly 20% along the path. \"t\" is ONLY in an individual Bezier piece.\n */\n\n//accepts basic selector text, a path instance, a RawPath instance, or a Segment and returns a RawPath (makes it easy to homogenize things). If an element or selector text is passed in, it'll also cache the value so that if it's queried again, it'll just take the path data from there instead of parsing it all over again (as long as the path data itself hasLine truncated
|
||||
+167
@@ -0,0 +1,167 @@
|
||||
(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';
|
||||
|
||||
/*!
|
||||
* CustomWiggle 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 gsap,
|
||||
_coreInitted,
|
||||
createCustomEase,
|
||||
_getGSAP = function _getGSAP() {
|
||||
return gsap || typeof window !== "undefined" && (gsap = window.gsap) && gsap.registerPlugin && gsap;
|
||||
},
|
||||
_eases = {
|
||||
easeOut: "M0,1,C0.7,1,0.6,0,1,0",
|
||||
easeInOut: "M0,0,C0.1,0,0.24,1,0.444,1,0.644,1,0.6,0,1,0",
|
||||
anticipate: "M0,0,C0,0.222,0.024,0.386,0,0.4,0.18,0.455,0.65,0.646,0.7,0.67,0.9,0.76,1,0.846,1,1",
|
||||
uniform: "M0,0,C0,0.95,0,1,0,1,0,1,1,1,1,1,1,1,1,0,1,0"
|
||||
},
|
||||
_linearEase = function _linearEase(p) {
|
||||
return p;
|
||||
},
|
||||
_initCore = function _initCore(required) {
|
||||
if (!_coreInitted) {
|
||||
gsap = _getGSAP();
|
||||
createCustomEase = gsap && gsap.parseEase("_CE");
|
||||
|
||||
if (createCustomEase) {
|
||||
for (var p in _eases) {
|
||||
_eases[p] = createCustomEase("", _eases[p]);
|
||||
}
|
||||
|
||||
_coreInitted = 1;
|
||||
|
||||
_create("wiggle").config = function (vars) {
|
||||
return typeof vars === "object" ? _create("", vars) : _create("wiggle(" + vars + ")", {
|
||||
wiggles: +vars
|
||||
});
|
||||
};
|
||||
} else {
|
||||
required && console.warn("Please gsap.registerPlugin(CustomEase, CustomWiggle)");
|
||||
}
|
||||
}
|
||||
},
|
||||
_parseEase = function _parseEase(ease, invertNonCustomEases) {
|
||||
if (typeof ease !== "function") {
|
||||
ease = gsap.parseEase(ease) || createCustomEase("", ease);
|
||||
}
|
||||
|
||||
return ease.custom || !invertNonCustomEases ? ease : function (p) {
|
||||
return 1 - ease(p);
|
||||
};
|
||||
},
|
||||
_create = function _create(id, vars) {
|
||||
if (!_coreInitted) {
|
||||
_initCore(1);
|
||||
}
|
||||
|
||||
vars = vars || {};
|
||||
var wiggles = (vars.wiggles || 10) | 0,
|
||||
inc = 1 / wiggles,
|
||||
x = inc / 2,
|
||||
anticipate = vars.type === "anticipate",
|
||||
yEase = _eases[vars.type] || _eases.easeOut,
|
||||
xEase = _linearEase,
|
||||
rnd = 1000,
|
||||
nextX,
|
||||
nextY,
|
||||
angle,
|
||||
handleX,
|
||||
handleY,
|
||||
easedX,
|
||||
y,
|
||||
path,
|
||||
i;
|
||||
|
||||
{
|
||||
if (anticipate) {
|
||||
xEase = yEase;
|
||||
yEase = _eases.easeOut;
|
||||
}
|
||||
|
||||
if (vars.timingEase) {
|
||||
xEase = _parseEase(vars.timingEase);
|
||||
}
|
||||
|
||||
if (vars.amplitudeEase) {
|
||||
yEase = _parseEase(vars.amplitudeEase, true);
|
||||
}
|
||||
|
||||
easedX = xEase(x);
|
||||
y = anticipate ? -yEase(x) : yEase(x);
|
||||
path = [0, 0, easedX / 4, 0, easedX / 2, y, easedX, y];
|
||||
|
||||
if (vars.type === "random") {
|
||||
path.length = 4;
|
||||
nextX = xEase(inc);
|
||||
nextY = Math.random() * 2 - 1;
|
||||
|
||||
for (i = 2; i < wiggles; i++) {
|
||||
x = nextX;
|
||||
y = nextY;
|
||||
nextX = xEase(inc * i);
|
||||
nextY = Math.random() * 2 - 1;
|
||||
angle = Math.atan2(nextY - path[path.length - 3], nextX - path[path.length - 4]);
|
||||
handleX = Math.cos(angle) * inc;
|
||||
handleY = Math.sin(angle) * inc;
|
||||
path.push(x - handleX, y - handleY, x, y, x + handleX, y + handleY);
|
||||
}
|
||||
|
||||
path.push(nextX, 0, 1, 0);
|
||||
} else {
|
||||
for (i = 1; i < wiggles; i++) {
|
||||
path.push(xEase(x + inc / 2), y);
|
||||
x += inc;
|
||||
y = (y > 0 ? -1 : 1) * yEase(i * inc);
|
||||
easedX = xEase(x);
|
||||
path.push(xEase(x - inc / 2), y, easedX, y);
|
||||
}
|
||||
|
||||
path.push(xEase(x + inc / 4), y, xEase(x + inc / 4), 0, 1, 0);
|
||||
}
|
||||
|
||||
i = path.length;
|
||||
|
||||
while (--i > -1) {
|
||||
path[i] = ~~(path[i] * rnd) / rnd;
|
||||
}
|
||||
|
||||
path[2] = "C" + path[2];
|
||||
return createCustomEase(id, "M" + path.join(","));
|
||||
}
|
||||
};
|
||||
|
||||
var CustomWiggle = function () {
|
||||
function CustomWiggle(id, vars) {
|
||||
this.ease = _create(id, vars);
|
||||
}
|
||||
|
||||
CustomWiggle.create = function create(id, vars) {
|
||||
return _create(id, vars);
|
||||
};
|
||||
|
||||
CustomWiggle.register = function register(core) {
|
||||
gsap = core;
|
||||
|
||||
_initCore();
|
||||
};
|
||||
|
||||
return CustomWiggle;
|
||||
}();
|
||||
_getGSAP() && gsap.registerPlugin(CustomWiggle);
|
||||
CustomWiggle.version = "3.14.2";
|
||||
|
||||
exports.CustomWiggle = CustomWiggle;
|
||||
exports.default = CustomWiggle;
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
})));
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
/*!
|
||||
* CustomWiggle 3.14.2
|
||||
* https://gsap.com
|
||||
*
|
||||
* @license Copyright 2025, GreenSock. All rights reserved.
|
||||
* Subject to the terms at https://gsap.com/standard-license.
|
||||
* @author: Jack Doyle, jack@greensock.com
|
||||
*/
|
||||
|
||||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).window=e.window||{})}(this,function(e){"use strict";function g(){return n||"undefined"!=typeof window&&(n=window.gsap)&&n.registerPlugin&&n}function i(e){return e}function j(e){if(!C)if(n=g(),M=n&&n.parseEase("_CE")){for(var t in y)y[t]=M("",y[t]);C=1,o("wiggle").config=function(e){return"object"==typeof e?o("",e):o("wiggle("+e+")",{wiggles:+e})}}else e&&console.warn("Please gsap.registerPlugin(CustomEase, CustomWiggle)")}function k(t,e){return"function"!=typeof t&&(t=n.parseEase(t)||M("",t)),t.custom||!e?t:function(e){return 1-t(e)}}var n,C,M,y={easeOut:"M0,1,C0.7,1,0.6,0,1,0",easeInOut:"M0,0,C0.1,0,0.24,1,0.444,1,0.644,1,0.6,0,1,0",anticipate:"M0,0,C0,0.222,0.024,0.386,0,0.4,0.18,0.455,0.65,0.646,0.7,0.67,0.9,0.76,1,0.846,1,1",uniform:"M0,0,C0,0.95,0,1,0,1,0,1,1,1,1,1,1,1,1,0,1,0"},o=function _create(e,t){C||j(1);var n,o,s,u,r,a,g,f,l,c=0|((t=t||{}).wiggles||10),p=1/c,d=p/2,m="anticipate"===t.type,h=y[t.type]||y.easeOut,w=i;if(m&&(w=h,h=y.easeOut),t.timingEase&&(w=k(t.timingEase)),t.amplitudeEase&&(h=k(t.amplitudeEase,!0)),f=[0,0,(a=w(d))/4,0,a/2,g=m?-h(d):h(d),a,g],"random"===t.type){for(f.length=4,n=w(p),o=2*Math.random()-1,l=2;l<c;l++)d=n,g=o,n=w(p*l),o=2*Math.random()-1,s=Math.atan2(o-f[f.length-3],n-f[f.length-4]),u=Math.cos(s)*p,r=Math.sin(s)*p,f.push(d-u,g-r,d,g,d+u,g+r);f.push(n,0,1,0)}else{for(l=1;l<c;l++)f.push(w(d+p/2),g),d+=p,g=(0<g?-1:1)*h(l*p),a=w(d),f.push(w(d-p/2),g,a,g);f.push(w(d+p/4),g,w(d+p/4),0,1,0)}for(l=f.length;-1<--l;)f[l]=~~(1e3*f[l])/1e3;return f[2]="C"+f[2],M(e,"M"+f.join(","))},t=(CustomWiggle.create=function create(e,t){return o(e,t)},CustomWiggle.register=function register(e){n=e,j()},CustomWiggle);function CustomWiggle(e,t){this.ease=o(e,t)}g()&&n.registerPlugin(t),t.version="3.14.2",e.CustomWiggle=t,e.default=t;if (typeof(window)==="undefined"||window!==e){Object.defineProperty(e,"__esModule",{value:!0})} else {delete e.default}});
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"CustomWiggle.min.js","sources":["../src/CustomWiggle.js"],"sourcesContent":["/*!\n * CustomWiggle 3.14.2\n * https://gsap.com\n *\n * @license Copyright 2008-2025, GreenSock. All rights reserved.\n * Subject to the terms at https://gsap.com/standard-license\n * @author: Jack Doyle, jack@greensock.com\n*/\n/* eslint-disable */\n\nlet gsap, _coreInitted, createCustomEase,\n\t_getGSAP = () => gsap || (typeof(window) !== \"undefined\" && (gsap = window.gsap) && gsap.registerPlugin && gsap),\n\t_eases = {\n\t\teaseOut: \"M0,1,C0.7,1,0.6,0,1,0\",\n\t\teaseInOut: \"M0,0,C0.1,0,0.24,1,0.444,1,0.644,1,0.6,0,1,0\",\n\t\tanticipate: \"M0,0,C0,0.222,0.024,0.386,0,0.4,0.18,0.455,0.65,0.646,0.7,0.67,0.9,0.76,1,0.846,1,1\",\n\t\tuniform: \"M0,0,C0,0.95,0,1,0,1,0,1,1,1,1,1,1,1,1,0,1,0\"\n\t},\n\t_linearEase = p => p,\n\t_initCore = required => {\n\t\tif (!_coreInitted) {\n\t\t\tgsap = _getGSAP();\n\t\t\tcreateCustomEase = gsap && gsap.parseEase(\"_CE\");\n\t\t\tif (createCustomEase) {\n\t\t\t\tfor (let p in _eases) {\n\t\t\t\t\t_eases[p] = createCustomEase(\"\", _eases[p]);\n\t\t\t\t}\n\t\t\t\t_coreInitted = 1;\n\t\t\t\t_create(\"wiggle\").config = vars => typeof(vars) === \"object\" ? _create(\"\", vars) : _create(\"wiggle(\" + vars + \")\", {wiggles:+vars});\n\t\t\t} else {\n\t\t\t\trequired && console.warn(\"Please gsap.registerPlugin(CustomEase, CustomWiggle)\");\n\t\t\t}\n\t\t}\n\t},\n\t_parseEase = (ease, invertNonCustomEases) => {\n\t\tif (typeof(ease) !== \"function\") {\n\t\t\tease = gsap.parseEase(ease) || createCustomEase(\"\", ease);\n\t\t}\n\t\treturn (ease.custom || !invertNonCustomEases) ? ease : p => 1 - ease(p);\n\t},\n\t_bonusValidated = 1, //<name>CustomWiggle</name>\n\t_create = (id, vars) => {\n\t\tif (!_coreInitted) {\n\t\t\t_initCore(1);\n\t\t}\n\t\tvars = vars || {};\n\t\tlet wiggles = (vars.wiggles || 10) | 0,\n\t\t\tinc = 1 / wiggles,\n\t\t\tx = inc / 2,\n\t\t\tanticipate = (vars.type === \"anticipate\"),\n\t\t\tyEase = _eases[vars.type] || _eases.easeOut,\n\t\t\txEase = _linearEase,\n\t\t\trnd = 1000,\n\t\t\tnextX, nextY, angle, handleX, handleY, easedX, y, path, i;\n\t\tif (_bonusValidated) {\n\t\t\tif (anticipate) { //the anticipate ease is actually applied on the x-axis (timing) and uses easeOut for amplitude.\n\t\t\t\txEase = yEase;\n\t\t\t\tyEase = _eases.easeOut;\n\t\t\t}\n\t\t\tif (vars.timingEase) {\n\t\t\t\txEase = _parseEase(vars.timingEase);\n\t\t\t}\n\t\t\tif (vars.amplitudeEase) {\n\t\t\t\tyEase = _parseEase(vars.amplitudeEase, true);\n\t\t\t}\n\t\t\teasedX = xEase(x);\n\t\t\ty = anticipate ? -yEase(x) : yEase(x);\n\t\t\tpath = [0, 0, easedX / 4, 0, easedX / 2, y, easedX, y];\n\n\t\t\tif (vars.type === \"random\") { //if we just select random values on the y-axis and plug them into the \"normal\" algorithm, since the control points are always straight horizontal, it creates a bit of a slowdown at each anchor which just didn't seem as desirable, so we switched to an algorithm that bends the control points to be more in line with their context.\n\t\t\t\tpath.length = 4;\n\t\t\t\tnextX = xEase(inc);\n\t\t\t\tnextY = Math.random() * 2 - 1;\n\t\t\t\tfor (i = 2; i < wiggles; i++) {\n\t\t\t\t\tx = nextX;\n\t\t\t\t\ty = nextY;\n\t\t\t\t\tnextX = xEase(inc * i);\n\t\t\t\t\tnextY = Math.random() * 2 - 1;\n\t\t\t\t\tangle = Math.atan2(nextY - path[path.length - 3], nextX - path[path.length - 4]);\n\t\t\t\t\thandleX = Math.cos(angle) * inc;\n\t\t\t\t\thandleY = Math.sin(angle) * inc;\n\t\t\t\t\tpath.push(x - handleX, y - handleY, x, y, x + handleX, y + handleY);\n\t\t\t\t}\n\t\t\t\tpath.push(nextX, 0, 1, 0);\n\t\t\t} else {\n\t\t\t\tfor (i = 1; i < wiggles; i++) {\n\t\t\t\t\tpath.push(xEase(x + inc / 2), y);\n\t\t\t\t\tx += inc;\n\t\t\t\t\ty = ((y > 0) ? -1 : 1) * (yEase(i * inc));\n\t\t\t\t\teasedX = xEase(x);\n\t\t\t\t\tpath.push(xEase(x - inc / 2), y, easedX, y);\n\t\t\t\t}\n\t\t\t\tpath.push(xEase(x + inc / 4), y, xEase(x + inc / 4), 0, 1, 0);\n\t\t\t}\n\t\t\ti = path.length;\n\t\t\twhile (--i > -1) {\n\t\t\t\tpath[i] = ~~(path[i] * rnd) / rnd; //round values to avoid odd strings for super tiny values\n\t\t\t}\n\t\t\tpath[2] = \"C\" + path[2];\n\t\t\treturn createCustomEase(id, \"M\" + path.join(\",\"));\n\t\t}\n\t};\n\nexport class CustomWiggle {\n\n\tconstructor(id, vars) {\n\t\tthis.ease = _create(id, vars);\n\t}\n\n\tstatic create(id, vars) {\n\t\treturn _create(id, vars);\n\t}\n\n\tstatic register(core) {\n\t\tgsap = core;\n\t\t_initCore();\n\t}\n\n}\n\n_getGSAP() && gsap.registerPlugin(CustomWiggle);\n\nCustomWiggle.version = \"3.14.2\";\n\nexport { CustomWiggle as default };"],"names":["_getGSAP","gsap","window","registerPlugin","_linearEase","p","_initCore","required","_coreInitted","createCustomEase","parseEase","_eases","_create","config","vars","wiggles","console","warn","_parseEase","ease","invertNonCustomEases","custom","easeOut","easeInOut","anticipate","uniform","id","nextX","nextY","angle","handleX","handleY","easedX","y","path","i","inc","x","type","yEaLine truncated
|
||||
+2993
File diff suppressed because it is too large.
Load diff
+11
@@ -0,0 +1,11 @@
|
||||
/*!
|
||||
* Draggable 3.14.2
|
||||
* https://gsap.com
|
||||
*
|
||||
* @license Copyright 2025, GreenSock. All rights reserved.
|
||||
* Subject to the terms at https://gsap.com/standard-license.
|
||||
* @author: Jack Doyle, jack@greensock.com
|
||||
*/
|
||||
|
||||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).window=e.window||{})}(this,function(e){"use strict";function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function w(e,t){if(e.parentNode&&(h||M(e))){var n=P(e),o=n?n.getAttribute("xmlns")||"http://www.w3.org/2000/svg":"http://www.w3.org/1999/xhtml",r=n?t?"rect":"g":"div",i=2!==t?0:100,a=3===t?100:0,l={position:"absolute",display:"block",pointerEvents:"none",margin:"0",padding:"0"},s=h.createElementNS?h.createElementNS(o.replace(/^https/,"http"),r):h.createElement(r);return t&&(n?(x=x||w(e),s.setAttribute("width",.01),s.setAttribute("height",.01),s.setAttribute("transform","translate("+i+","+a+")"),s.setAttribute("fill","transparent"),x.appendChild(s)):(g||(g=w(e),Object.assign(g.style,l)),Object.assign(s.style,l,{width:"0.1px",height:"0.1px",top:a+"px",left:i+"px"}),g.appendChild(s))),s}throw"Need document and parent."}function A(e,t,n,o,r,i,a){return e.a=t,e.b=n,e.c=o,e.d=r,e.e=i,e.f=a,e}var h,f,i,a,g,x,m,y,v,t,b="transform",T=b+"Origin",M=function _setDoc(e){var t=e.ownerDocument||e;!(b in e.style)&&"msTransform"in e.style&&(T=(b="msTransform")+"Origin");for(;t.parentNode&&(t=t.parentNode););if(f=window,m=new ge,t){i=(h=t).documentElement,a=t.body,(y=h.createElementNS("http://www.w3.org/2000/svg","g")).style.transform="none";var n=t.createElement("div"),o=t.createElement("div"),r=t&&(t.body||t.firstElementChild);r&&r.appendChild&&(r.appendChild(n),n.appendChild(o),n.style.position="static",n.style.transform="translate3d(0,0,1px)",v=o.offsetParent!==n,r.removeChild(n))}return t},E=function _forceNonZeroScale(e){for(var t,n;e&&e!==a;)(n=e._gsap)&&n.uncache&&n.get(e,"x"),n&&!n.scaleX&&!n.scaleY&&n.renderTransform&&(n.scaleX=n.scaleY=1e-4,n.renderTransform(1,n),t?t.push(n):t=[n]),e=e.parentNode;return t},D=[],S=[],C=function _getDocScrollTop(){return f.pageYOffset||h.scrollTop||i.scrollTop||a.scrollTop||0},L=function _getDocScrollLeft(){return f.pageXOffset||h.scrollLeft||i.scrollLeft||a.scrollLeft||0},P=function _svgOwner(e){return e.ownerSVGElement||("svg"===(e.tagName+"").toLowerCase()?e:null)},k=function _isFixed(e){return"fixed"===f.getComputedStyle(e).position||((e=e.parentNode)&&1===e.nodeType?_isFixed(e):void 0)},N=function _placeSiblings(e,t){var n,o,r,i,a,l,s=P(e),c=e===s,d=s?D:S,p=e.parentNode,u=p&&!s&&p.shadowRoot&&p.shadowRoot.appendChild?p.shadowRoot:p;if(e===f)return e;if(d.length||d.push(w(e,1),w(e,2),w(e,3)),n=s?x:g,s)c?(i=-(r=function _getCTM(e){var t,n=e.getCTM();return n||(t=e.style[b],e.style[b]="none",e.appendChild(y),n=y.getCTM(),e.removeChild(y),t?e.style[b]=t:e.style.removeProperty(b.replace(/([A-Z])/g,"-$1").toLowerCase())),n||m.clone()}(e)).e/r.a,a=-r.f/r.d,o=m):e.getBBox?(r=e.getBBox(),i=(o=(o=e.transform?e.transform.baseVal:{}).numberOfItems?1<o.numberOfItems?function _consolidate(e){for(var t=new ge,n=0;n<e.numberOfItems;n++)t.multiply(e.getItem(n).matrix);return t}(o):o.getItem(0).matrix:m).a*r.x+o.c*r.y,a=o.b*r.x+o.d*r.y):(o=new ge,i=a=0),t&&"g"===e.tagName.toLowerCase()&&(i=a=0),(c||!e.getBoundingClientRect().width?s:p).appendChild(n),n.setAttribute("transform","matrix("+o.a+","+o.b+","+o.c+","+o.d+","+(o.e+i)+","+(o.f+a)+")");else{if(i=a=0,v)for(o=e.offsetParent,r=e;(r=r&&r.parentNode)&&r!==o&&r.parentNode;)4<(f.getComputedStyle(r)[b]+"").length&&(i=r.offsetLeft,a=r.offsetTop,r=0);if("absolute"!==(l=f.getComputedStyle(e)).position&&"fixed"!==l.position)for(o=e.offsetParent;p&&p!==o;)i+=p.scrollLeft||0,a+=p.scrollTop||0,p=p.parentNode;(r=n.style).top=e.offsetTop-a+"px",r.left=e.offsetLeft-i+"px",r[b]=l[b],r[T]=l[T],r.position="fixed"===l.position?"fixed":"absolute",u.appendChild(n)}return n},ge=((t=Matrix2D.prototype).inverse=function inverse(){var e=this.a,t=this.b,n=this.c,o=this.d,r=this.e,i=this.f,a=e*o-t*n||1e-10;return A(this,o/a,-t/a,-n/a,e/a,(n*i-o*r)/a,-(e*i-t*r)/a)},t.multiply=function multiply(e){var t=this.a,n=this.b,o=this.c,r=this.d,i=this.e,a=this.f,l=e.a,s=e.c,c=e.b,d=e.d,p=e.e,u=e.f;return A(this,l*t+c*o,l*n+c*r,s*t+d*o,s*n+d*r,i+p*t+u*o,a+p*n+u*r)},t.clone=function clone(){return new Matrix2D(this.a,this.b,this.c,this.d,this.e,this.f)},t.equals=function equals(e){var t=this.a,n=this.b,o=this.c,r=this.d,i=this.e,a=this.f;return t===e.a&&n===e.b&&o===e.c&&r===e.d&&i===e.e&&a===e.f},t.apply=function apply(e,t){void 0===t&&(t={});var n=e.x,o=e.y,r=this.a,i=this.b,a=this.c,l=this.d,s=this.e,c=this.f;return t.x=n*r+o*a+s||0,t.y=n*i+o*l+c||0,t},Matrix2D);function Matrix2D(e,t,n,o,r,i){void 0===e&&(e=1),void 0===t&&(t=0),void 0===n&&(n=0),void 0===o&&(o=1),void 0===r&&(r=0),void 0===i&&(i=0),A(this,e,t,n,o,r,i)}function getGlobalMatrix(e,t,n,o){if(!e||!e.parentNode||(h||M(e)).documentElement===e)return new ge;var r=E(e),i=P(e)?D:S,a=N(e,n),l=i[0].getBoundingClientRect(),s=i[1].getBoundingClientRect(),c=i[2].getBoundingClientReLine truncated
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Draggable.min.js","sources":["../src/utils/matrix.js","../src/Draggable.js"],"sourcesContent":["/*!\n * matrix 3.14.2\n * https://gsap.com\n *\n * Copyright 2008-2025, GreenSock. All rights reserved.\n * Subject to the terms at https://gsap.com/standard-license\n * @author: Jack Doyle, jack@greensock.com\n*/\n/* eslint-disable */\n\nlet _doc, _win, _docElement, _body,\t_divContainer, _svgContainer, _identityMatrix, _gEl,\n\t_transformProp = \"transform\",\n\t_transformOriginProp = _transformProp + \"Origin\",\n\t_hasOffsetBug,\n\t_setDoc = element => {\n\t\tlet doc = element.ownerDocument || element;\n\t\tif (!(_transformProp in element.style) && \"msTransform\" in element.style) { //to improve compatibility with old Microsoft browsers\n\t\t\t_transformProp = \"msTransform\";\n\t\t\t_transformOriginProp = _transformProp + \"Origin\";\n\t\t}\n\t\twhile (doc.parentNode && (doc = doc.parentNode)) {\t}\n\t\t_win = window;\n\t\t_identityMatrix = new Matrix2D();\n\t\tif (doc) {\n\t\t\t_doc = doc;\n\t\t\t_docElement = doc.documentElement;\n\t\t\t_body = doc.body;\n\t\t\t_gEl = _doc.createElementNS(\"http://www.w3.org/2000/svg\", \"g\");\n\t\t\t// prevent any existing CSS from transforming it\n\t\t\t_gEl.style.transform = \"none\";\n\t\t\t// 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.\n\t\t\tlet d1 = doc.createElement(\"div\"),\n\t\t\t\td2 = doc.createElement(\"div\"),\n\t\t\t\troot = doc && (doc.body || doc.firstElementChild);\n\t\t\tif (root && root.appendChild) {\n\t\t\t\troot.appendChild(d1);\n\t\t\t\td1.appendChild(d2);\n\t\t\t\td1.style.position = \"static\";\n\t\t\t\td1.style.transform = \"translate3d(0,0,1px)\";\n\t\t\t\t_hasOffsetBug = (d2.offsetParent !== d1);\n\t\t\t\troot.removeChild(d1);\n\t\t\t}\n\t\t}\n\t\treturn doc;\n\t},\n\t_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.\n\t\tlet a, cache;\n\t\twhile (e && e !== _body) {\n\t\t\tcache = e._gsap;\n\t\t\tcache && cache.uncache && cache.get(e, \"x\"); // force re-parsing of transforms if necessary\n\t\t\tif (cache && !cache.scaleX && !cache.scaleY && cache.renderTransform) {\n\t\t\t\tcache.scaleX = cache.scaleY = 1e-4;\n\t\t\t\tcache.renderTransform(1, cache);\n\t\t\t\ta ? a.push(cache) : (a = [cache]);\n\t\t\t}\n\t\t\te = e.parentNode;\n\t\t}\n\t\treturn a;\n\t},\n\t// 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.\n\t// _forceDisplay = e => {\n\t// \tlet a = [],\n\t// \t\tparent;\n\t// \twhile (e && e !== _body) {\n\t// \t\tparent = e.parentNode;\n\t// \t\t(_win.getComputedStyle(e).display === \"none\" || !parent) && a.push(e, e.style.display, parent) && (e.style.display = \"block\");\n\t// \t\tparent || _body.appendChild(e);\n\t// \t\te = parent;\n\t// \t}\n\t// \treturn a;\n\t// },\n\t// _revertDisplay = a => {\n\t// \tfor (let i = 0; i < a.length; i+=3) {\n\t// \t\ta[i+1] ? (a[i].style.display = a[i+1]) : a[i].style.removeProperty(\"display\");\n\t// \t\ta[i+2] || a[i].parentNode.removeChild(a[i]);\n\t// \t}\n\t// },\n\t_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.\n\t_divTemps = [],\n\t_getDocScrollTop = () => _win.pageYOffset || _doc.scrollTop || _docElement.scrollTop || _body.scrollTop || 0,\n\t_getDocScrollLeft = () => _win.pageXOffset || _doc.scrollLeft || _docElement.scrollLeft || _body.scrollLeft || 0,\n\t_svgOwner = element => element.ownerSVGElement || ((element.tagName + \"\").toLowerCase() === \"svg\" ? element : null),\n\t_isFixed = element => {\n\t\tif (_win.getComputedStyle(element).position === \"fixed\") {\n\t\t\treturn true;\n\t\t}\n\t\telement = element.parentNode;\n\t\tif (element && element.nodeType === 1) { // avoid document fragments which will throw an error.\n\t\t\treturn _isFixed(element);\n\t\t}\n\t},\n\t_createSibling = (element, i) => {\n\t\tif (element.parentNode && (_doc || _setDoc(element))) {\n\t\t\tlet svg = _svgOwner(element),\n\t\t\t\tns = svg ? (svg.getAttribute(\"xmlns\") || \"http://www.w3.org/2000/svg\") : \"http://www.w3.org/1999/xhtml\",\n\t\t\t\ttype = svg ? (i ? \"rect\" : \"g\") : \"div\",\n\t\t\t\tx = i !== 2 ? 0 : 100,\n\t\t\t\ty = i === 3 ? 100 : 0,\n\t\t\t\tcss = {position: \"absolute\", display: \"block\", pointerEvents: \"nonLine truncated
|
||||
+310
@@ -0,0 +1,310 @@
|
||||
(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';
|
||||
|
||||
/*!
|
||||
* DrawSVGPlugin 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 gsap,
|
||||
_toArray,
|
||||
_win,
|
||||
_isEdge,
|
||||
_coreInitted,
|
||||
_warned,
|
||||
_getStyleSaver,
|
||||
_reverting,
|
||||
_windowExists = function _windowExists() {
|
||||
return typeof window !== "undefined";
|
||||
},
|
||||
_getGSAP = function _getGSAP() {
|
||||
return gsap || _windowExists() && (gsap = window.gsap) && gsap.registerPlugin && gsap;
|
||||
},
|
||||
_numExp = /[-+=\.]*\d+[\.e\-\+]*\d*[e\-\+]*\d*/gi,
|
||||
_types = {
|
||||
rect: ["width", "height"],
|
||||
circle: ["r", "r"],
|
||||
ellipse: ["rx", "ry"],
|
||||
line: ["x2", "y2"]
|
||||
},
|
||||
_round = function _round(value) {
|
||||
return Math.round(value * 10000) / 10000;
|
||||
},
|
||||
_parseNum = function _parseNum(value) {
|
||||
return parseFloat(value) || 0;
|
||||
},
|
||||
_parseSingleVal = function _parseSingleVal(value, length) {
|
||||
var num = _parseNum(value);
|
||||
|
||||
return ~value.indexOf("%") ? num / 100 * length : num;
|
||||
},
|
||||
_getAttributeAsNumber = function _getAttributeAsNumber(target, attr) {
|
||||
return _parseNum(target.getAttribute(attr));
|
||||
},
|
||||
_sqrt = Math.sqrt,
|
||||
_getDistance = function _getDistance(x1, y1, x2, y2, scaleX, scaleY) {
|
||||
return _sqrt(Math.pow((_parseNum(x2) - _parseNum(x1)) * scaleX, 2) + Math.pow((_parseNum(y2) - _parseNum(y1)) * scaleY, 2));
|
||||
},
|
||||
_warn = function _warn(message) {
|
||||
return console.warn(message);
|
||||
},
|
||||
_hasNonScalingStroke = function _hasNonScalingStroke(target) {
|
||||
return target.getAttribute("vector-effect") === "non-scaling-stroke";
|
||||
},
|
||||
_bonusValidated = 1,
|
||||
_parse = function _parse(value, length, defaultStart) {
|
||||
var i = value.indexOf(" "),
|
||||
s,
|
||||
e;
|
||||
|
||||
if (i < 0) {
|
||||
s = defaultStart !== undefined ? defaultStart + "" : value;
|
||||
e = value;
|
||||
} else {
|
||||
s = value.substr(0, i);
|
||||
e = value.substr(i + 1);
|
||||
}
|
||||
|
||||
s = _parseSingleVal(s, length);
|
||||
e = _parseSingleVal(e, length);
|
||||
return s > e ? [e, s] : [s, e];
|
||||
},
|
||||
_getLength = function _getLength(target) {
|
||||
target = _toArray(target)[0];
|
||||
|
||||
if (!target) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
var type = target.tagName.toLowerCase(),
|
||||
style = target.style,
|
||||
scaleX = 1,
|
||||
scaleY = 1,
|
||||
length,
|
||||
bbox,
|
||||
points,
|
||||
prevPoint,
|
||||
i,
|
||||
rx,
|
||||
ry;
|
||||
|
||||
if (_hasNonScalingStroke(target)) {
|
||||
scaleY = target.getScreenCTM();
|
||||
scaleX = _sqrt(scaleY.a * scaleY.a + scaleY.b * scaleY.b);
|
||||
scaleY = _sqrt(scaleY.d * scaleY.d + scaleY.c * scaleY.c);
|
||||
}
|
||||
|
||||
try {
|
||||
bbox = target.getBBox();
|
||||
} catch (e) {
|
||||
_warn("Some browsers won't measure invisible elements (like display:none or masks inside defs).");
|
||||
}
|
||||
|
||||
var _ref = bbox || {
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: 0,
|
||||
height: 0
|
||||
},
|
||||
x = _ref.x,
|
||||
y = _ref.y,
|
||||
width = _ref.width,
|
||||
height = _ref.height;
|
||||
|
||||
if ((!bbox || !width && !height) && _types[type]) {
|
||||
width = _getAttributeAsNumber(target, _types[type][0]);
|
||||
height = _getAttributeAsNumber(target, _types[type][1]);
|
||||
|
||||
if (type !== "rect" && type !== "line") {
|
||||
width *= 2;
|
||||
height *= 2;
|
||||
}
|
||||
|
||||
if (type === "line") {
|
||||
x = _getAttributeAsNumber(target, "x1");
|
||||
y = _getAttributeAsNumber(target, "y1");
|
||||
width = Math.abs(width - x);
|
||||
height = Math.abs(height - y);
|
||||
}
|
||||
}
|
||||
|
||||
if (type === "path") {
|
||||
prevPoint = style.strokeDasharray;
|
||||
style.strokeDasharray = "none";
|
||||
length = target.getTotalLength() || 0;
|
||||
_round(scaleX) !== _round(scaleY) && !_warned && (_warned = 1) && _warn("Warning: <path> length cannot be measured when vector-effect is non-scaling-stroke and the element isn't proportionally scaled.");
|
||||
length *= (scaleX + scaleY) / 2;
|
||||
style.strokeDasharray = prevPoint;
|
||||
} else if (type === "rect") {
|
||||
length = width * 2 * scaleX + height * 2 * scaleY;
|
||||
} else if (type === "line") {
|
||||
length = _getDistance(x, y, x + width, y + height, scaleX, scaleY);
|
||||
} else if (type === "polyline" || type === "polygon") {
|
||||
points = target.getAttribute("points").match(_numExp) || [];
|
||||
type === "polygon" && points.push(points[0], points[1]);
|
||||
length = 0;
|
||||
|
||||
for (i = 2; i < points.length; i += 2) {
|
||||
length += _getDistance(points[i - 2], points[i - 1], points[i], points[i + 1], scaleX, scaleY) || 0;
|
||||
}
|
||||
} else if (type === "circle" || type === "ellipse") {
|
||||
rx = width / 2 * scaleX;
|
||||
ry = height / 2 * scaleY;
|
||||
length = Math.PI * (3 * (rx + ry) - _sqrt((3 * rx + ry) * (rx + 3 * ry)));
|
||||
}
|
||||
|
||||
return length || 0;
|
||||
},
|
||||
_getPosition = function _getPosition(target, length) {
|
||||
target = _toArray(target)[0];
|
||||
|
||||
if (!target) {
|
||||
return [0, 0];
|
||||
}
|
||||
|
||||
length || (length = _getLength(target) + 1);
|
||||
|
||||
var cs = _win.getComputedStyle(target),
|
||||
dash = cs.strokeDasharray || "",
|
||||
offset = _parseNum(cs.strokeDashoffset),
|
||||
i = dash.indexOf(",");
|
||||
|
||||
i < 0 && (i = dash.indexOf(" "));
|
||||
dash = i < 0 ? length : _parseNum(dash.substr(0, i));
|
||||
dash > length && (dash = length);
|
||||
return [-offset || 0, dash - offset || 0];
|
||||
},
|
||||
_initCore = function _initCore() {
|
||||
if (_windowExists()) {
|
||||
_win = window;
|
||||
_coreInitted = gsap = _getGSAP();
|
||||
_toArray = gsap.utils.toArray;
|
||||
_getStyleSaver = gsap.core.getStyleSaver;
|
||||
|
||||
_reverting = gsap.core.reverting || function () {};
|
||||
|
||||
_isEdge = ((_win.navigator || {}).userAgent || "").indexOf("Edge") !== -1;
|
||||
}
|
||||
};
|
||||
|
||||
var DrawSVGPlugin = {
|
||||
version: "3.14.2",
|
||||
name: "drawSVG",
|
||||
register: function register(core) {
|
||||
gsap = core;
|
||||
|
||||
_initCore();
|
||||
},
|
||||
init: function init(target, value, tween, index, targets) {
|
||||
if (!target.getBBox) {
|
||||
return false;
|
||||
}
|
||||
|
||||
_coreInitted || _initCore();
|
||||
|
||||
var length = _getLength(target),
|
||||
start,
|
||||
end,
|
||||
cs;
|
||||
|
||||
this.styles = _getStyleSaver && _getStyleSaver(target, "strokeDashoffset,strokeDasharray,strokeMiterlimit");
|
||||
this.tween = tween;
|
||||
this._style = target.style;
|
||||
this._target = target;
|
||||
|
||||
if (value + "" === "true") {
|
||||
value = "0 100%";
|
||||
} else if (!value) {
|
||||
value = "0 0";
|
||||
} else if ((value + "").indexOf(" ") === -1) {
|
||||
value = "0 " + value;
|
||||
}
|
||||
|
||||
start = _getPosition(target, length);
|
||||
end = _parse(value, length, start[0]);
|
||||
this._length = _round(length);
|
||||
this._dash = _round(start[1] - start[0]);
|
||||
this._offset = _round(-start[0]);
|
||||
this._dashPT = this.add(this, "_dash", this._dash, _round(end[1] - end[0]), 0, 0, 0, 0, 0, 1);
|
||||
this._offsetPT = this.add(this, "_offset", this._offset, _round(-end[0]), 0, 0, 0, 0, 0, 1);
|
||||
|
||||
if (_isEdge) {
|
||||
cs = _win.getComputedStyle(target);
|
||||
|
||||
if (cs.strokeLinecap !== cs.strokeLinejoin) {
|
||||
end = _parseNum(cs.strokeMiterlimit);
|
||||
this.add(target.style, "strokeMiterlimit", end, end + 0.01);
|
||||
}
|
||||
}
|
||||
|
||||
this._live = _hasNonScalingStroke(target) || ~(value + "").indexOf("live");
|
||||
this._nowrap = ~(value + "").indexOf("nowrap");
|
||||
|
||||
this._props.push("drawSVG");
|
||||
|
||||
return _bonusValidated;
|
||||
},
|
||||
render: function render(ratio, data) {
|
||||
if (data.tween._time || !_reverting()) {
|
||||
var pt = data._pt,
|
||||
style = data._style,
|
||||
length,
|
||||
lengthRatio,
|
||||
dash,
|
||||
offset;
|
||||
|
||||
if (pt) {
|
||||
if (data._live) {
|
||||
length = _getLength(data._target);
|
||||
|
||||
if (length !== data._length) {
|
||||
lengthRatio = length / data._length;
|
||||
data._length = length;
|
||||
|
||||
if (data._offsetPT) {
|
||||
data._offsetPT.s *= lengthRatio;
|
||||
data._offsetPT.c *= lengthRatio;
|
||||
}
|
||||
|
||||
if (data._dashPT) {
|
||||
data._dashPT.s *= lengthRatio;
|
||||
data._dashPT.c *= lengthRatio;
|
||||
} else {
|
||||
data._dash *= lengthRatio;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (pt) {
|
||||
pt.r(ratio, pt.d);
|
||||
pt = pt._next;
|
||||
}
|
||||
|
||||
dash = data._dash || ratio && ratio !== 1 && 0.0001 || 0;
|
||||
length = data._length - dash + 0.1;
|
||||
offset = data._offset;
|
||||
dash && offset && dash + Math.abs(offset % data._length) > data._length - 0.05 && (offset += offset < 0 ? 0.005 : -0.005) && (length += 0.005);
|
||||
style.strokeDashoffset = dash ? offset : offset + 0.001;
|
||||
style.strokeDasharray = length < 0.1 ? "none" : dash ? dash + "px," + (data._nowrap ? 999999 : length) + "px" : "0px, 999999px";
|
||||
}
|
||||
} else {
|
||||
data.styles.revert();
|
||||
}
|
||||
},
|
||||
getLength: _getLength,
|
||||
getPosition: _getPosition
|
||||
};
|
||||
_getGSAP() && gsap.registerPlugin(DrawSVGPlugin);
|
||||
|
||||
exports.DrawSVGPlugin = DrawSVGPlugin;
|
||||
exports.default = DrawSVGPlugin;
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
})));
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
/*!
|
||||
* DrawSVGPlugin 3.14.2
|
||||
* https://gsap.com
|
||||
*
|
||||
* @license Copyright 2025, GreenSock. All rights reserved.
|
||||
* Subject to the terms at https://gsap.com/standard-license.
|
||||
* @author: Jack Doyle, jack@greensock.com
|
||||
*/
|
||||
|
||||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).window=e.window||{})}(this,function(e){"use strict";function l(){return"undefined"!=typeof window}function m(){return t||l()&&(t=window.gsap)&&t.registerPlugin&&t}function p(e){return Math.round(1e4*e)/1e4}function q(e){return parseFloat(e)||0}function r(e,t){var r=q(e);return~e.indexOf("%")?r/100*t:r}function s(e,t){return q(e.getAttribute(t))}function u(e,t,r,n,s,i){return D(Math.pow((q(r)-q(e))*s,2)+Math.pow((q(n)-q(t))*i,2))}function v(e){return console.warn(e)}function w(e){return"non-scaling-stroke"===e.getAttribute("vector-effect")}function z(e){if(!(e=k(e)[0]))return 0;var t,r,n,i,o,a,f,h=e.tagName.toLowerCase(),l=e.style,d=1,c=1;w(e)&&(c=e.getScreenCTM(),d=D(c.a*c.a+c.b*c.b),c=D(c.d*c.d+c.c*c.c));try{r=e.getBBox()}catch(e){v("Some browsers won't measure invisible elements (like display:none or masks inside defs).")}var g=r||{x:0,y:0,width:0,height:0},_=g.x,y=g.y,x=g.width,m=g.height;if(r&&(x||m)||!M[h]||(x=s(e,M[h][0]),m=s(e,M[h][1]),"rect"!==h&&"line"!==h&&(x*=2,m*=2),"line"===h&&(_=s(e,"x1"),y=s(e,"y1"),x=Math.abs(x-_),m=Math.abs(m-y))),"path"===h)i=l.strokeDasharray,l.strokeDasharray="none",t=e.getTotalLength()||0,p(d)!==p(c)&&!b&&(b=1)&&v("Warning: <path> length cannot be measured when vector-effect is non-scaling-stroke and the element isn't proportionally scaled."),t*=(d+c)/2,l.strokeDasharray=i;else if("rect"===h)t=2*x*d+2*m*c;else if("line"===h)t=u(_,y,_+x,y+m,d,c);else if("polyline"===h||"polygon"===h)for(n=e.getAttribute("points").match(P)||[],"polygon"===h&&n.push(n[0],n[1]),t=0,o=2;o<n.length;o+=2)t+=u(n[o-2],n[o-1],n[o],n[o+1],d,c)||0;else"circle"!==h&&"ellipse"!==h||(a=x/2*d,f=m/2*c,t=Math.PI*(3*(a+f)-D((3*a+f)*(a+3*f))));return t||0}function A(e,t){if(!(e=k(e)[0]))return[0,0];t=t||z(e)+1;var r=f.getComputedStyle(e),n=r.strokeDasharray||"",s=q(r.strokeDashoffset),i=n.indexOf(",");return i<0&&(i=n.indexOf(" ")),t<(n=i<0?t:q(n.substr(0,i)))&&(n=t),[-s||0,n-s||0]}function B(){l()&&(f=window,d=t=m(),k=t.utils.toArray,c=t.core.getStyleSaver,g=t.core.reverting||function(){},h=-1!==((f.navigator||{}).userAgent||"").indexOf("Edge"))}var t,k,f,h,d,b,c,g,P=/[-+=\.]*\d+[\.e\-\+]*\d*[e\-\+]*\d*/gi,M={rect:["width","height"],circle:["r","r"],ellipse:["rx","ry"],line:["x2","y2"]},D=Math.sqrt,n={version:"3.14.2",name:"drawSVG",register:function register(e){t=e,B()},init:function init(e,t,n){if(!e.getBBox)return!1;d||B();var s,i,o,a=z(e);return this.styles=c&&c(e,"strokeDashoffset,strokeDasharray,strokeMiterlimit"),this.tween=n,this._style=e.style,this._target=e,t+""=="true"?t="0 100%":t?-1===(t+"").indexOf(" ")&&(t="0 "+t):t="0 0",i=function _parse(e,t,n){var s,i,o=e.indexOf(" ");return i=o<0?(s=void 0!==n?n+"":e,e):(s=e.substr(0,o),e.substr(o+1)),s=r(s,t),(i=r(i,t))<s?[i,s]:[s,i]}(t,a,(s=A(e,a))[0]),this._length=p(a),this._dash=p(s[1]-s[0]),this._offset=p(-s[0]),this._dashPT=this.add(this,"_dash",this._dash,p(i[1]-i[0]),0,0,0,0,0,1),this._offsetPT=this.add(this,"_offset",this._offset,p(-i[0]),0,0,0,0,0,1),h&&(o=f.getComputedStyle(e)).strokeLinecap!==o.strokeLinejoin&&(i=q(o.strokeMiterlimit),this.add(e.style,"strokeMiterlimit",i,i+.01)),this._live=w(e)||~(t+"").indexOf("live"),this._nowrap=~(t+"").indexOf("nowrap"),this._props.push("drawSVG"),1},render:function render(e,t){if(t.tween._time||!g()){var r,n,s,i,o=t._pt,a=t._style;if(o){for(t._live&&(r=z(t._target))!==t._length&&(n=r/t._length,t._length=r,t._offsetPT&&(t._offsetPT.s*=n,t._offsetPT.c*=n),t._dashPT?(t._dashPT.s*=n,t._dashPT.c*=n):t._dash*=n);o;)o.r(e,o.d),o=o._next;s=t._dash||e&&1!==e&&1e-4||0,r=t._length-s+.1,i=t._offset,s&&i&&s+Math.abs(i%t._length)>t._length-.05&&(i+=i<0?.005:-.005)&&(r+=.005),a.strokeDashoffset=s?i:i+.001,a.strokeDasharray=r<.1?"none":s?s+"px,"+(t._nowrap?999999:r)+"px":"0px, 999999px"}}else t.styles.revert()},getLength:z,getPosition:A};m()&&t.registerPlugin(n),e.DrawSVGPlugin=n,e.default=n;if (typeof(window)==="undefined"||window!==e){Object.defineProperty(e,"__esModule",{value:!0})} else {delete e.default}});
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"DrawSVGPlugin.min.js","sources":["../src/DrawSVGPlugin.js"],"sourcesContent":["/*!\n * DrawSVGPlugin 3.14.2\n * https://gsap.com\n *\n * @license Copyright 2008-2025, GreenSock. All rights reserved.\n * Subject to the terms at https://gsap.com/standard-license\n * @author: Jack Doyle, jack@greensock.com\n*/\n/* eslint-disable */\n\n\nlet gsap, _toArray, _doc, _win, _isEdge, _coreInitted, _warned, _getStyleSaver, _reverting,\n\t_windowExists = () => typeof(window) !== \"undefined\",\n\t_getGSAP = () => gsap || (_windowExists() && (gsap = window.gsap) && gsap.registerPlugin && gsap),\n\t_numExp = /[-+=\\.]*\\d+[\\.e\\-\\+]*\\d*[e\\-\\+]*\\d*/gi, //finds any numbers, including ones that start with += or -=, negative numbers, and ones in scientific notation like 1e-8.\n\t_types = {rect:[\"width\",\"height\"], circle:[\"r\",\"r\"], ellipse:[\"rx\",\"ry\"], line:[\"x2\",\"y2\"]},\n\t_round = value => Math.round(value * 10000) / 10000,\n\t_parseNum = value => parseFloat(value) || 0,\n\t_parseSingleVal = (value, length) => {\n\t\tlet num = _parseNum(value);\n\t\treturn ~value.indexOf(\"%\") ? num / 100 * length : num;\n\t},\n\t_getAttributeAsNumber = (target, attr) => _parseNum(target.getAttribute(attr)),\n\t_sqrt = Math.sqrt,\n\t_getDistance = (x1, y1, x2, y2, scaleX, scaleY) => _sqrt(((_parseNum(x2) - _parseNum(x1)) * scaleX) ** 2 + ((_parseNum(y2) - _parseNum(y1)) * scaleY) ** 2),\n\t_warn = message => console.warn(message),\n\t_hasNonScalingStroke = target => target.getAttribute(\"vector-effect\") === \"non-scaling-stroke\",\n\t_bonusValidated = 1, //<name>DrawSVGPlugin</name>\n\t//accepts values like \"100%\" or \"20% 80%\" or \"20 50\" and parses it into an absolute start and end position on the line/stroke based on its length. Returns an an array with the start and end values, like [0, 243]\n\t_parse = (value, length, defaultStart) => {\n\t\tlet i = value.indexOf(\" \"),\n\t\t\ts, e;\n\t\tif (i < 0) {\n\t\t\ts = defaultStart !== undefined ? defaultStart + \"\" : value;\n\t\t\te = value;\n\t\t} else {\n\t\t\ts = value.substr(0, i);\n\t\t\te = value.substr(i + 1);\n\t\t}\n\t\ts = _parseSingleVal(s, length);\n\t\te = _parseSingleVal(e, length);\n\t\treturn (s > e) ? [e, s] : [s, e];\n\t},\n\t_getLength = target => {\n\t\ttarget = _toArray(target)[0];\n\t\tif (!target) {\n\t\t\treturn 0;\n\t\t}\n\t\tlet type = target.tagName.toLowerCase(),\n\t\t\tstyle = target.style,\n\t\t\tscaleX = 1,\n\t\t\tscaleY = 1,\n\t\t\tlength, bbox, points, prevPoint, i, rx, ry;\n\t\tif (_hasNonScalingStroke(target)) { //non-scaling-stroke basically scales the shape and then strokes it at the screen-level (after transforms), thus we need to adjust the length accordingly.\n\t\t\tscaleY = target.getScreenCTM();\n\t\t\tscaleX = _sqrt(scaleY.a * scaleY.a + scaleY.b * scaleY.b);\n\t\t\tscaleY = _sqrt(scaleY.d * scaleY.d + scaleY.c * scaleY.c);\n\t\t}\n\t\ttry { //IE bug: calling <path>.getTotalLength() locks the repaint area of the stroke to whatever its current dimensions are on that frame/tick. To work around that, we must call getBBox() to force IE to recalculate things.\n\t\t\tbbox = target.getBBox(); //solely for fixing bug in IE - we don't actually use the bbox.\n\t\t} catch (e) {\n\t\t\t//firefox has a bug that throws an error if the element isn't visible.\n\t\t\t_warn(\"Some browsers won't measure invisible elements (like display:none or masks inside defs).\");\n\t\t}\n\t\tlet {x, y, width, height} = bbox || {x:0, y:0, width:0, height:0};\n\t\tif ((!bbox || (!width && !height)) && _types[type]) { //if the element isn't visible, try to discern width/height using its attributes.\n\t\t\twidth =_getAttributeAsNumber(target, _types[type][0]);\n\t\t\theight = _getAttributeAsNumber(target, _types[type][1]);\n\t\t\tif (type !== \"rect\" && type !== \"line\") { //double the radius for circles and ellipses\n\t\t\t\twidth *= 2;\n\t\t\t\theight *= 2;\n\t\t\t}\n\t\t\tif (type === \"line\") {\n\t\t\t\tx = _getAttributeAsNumber(target, \"x1\");\n\t\t\t\ty = _getAttributeAsNumber(target, \"y1\");\n\t\t\t\twidth = Math.abs(width - x);\n\t\t\t\theight = Math.abs(height - y);\n\t\t\t}\n\t\t}\n\t\tif (type === \"path\") {\n\t\t\tprevPoint = style.strokeDasharray;\n\t\t\tstyle.strokeDasharray = \"none\";\n\t\t\tlength = target.getTotalLength() || 0;\n\t\t\t_round(scaleX) !== _round(scaleY) && !_warned && (_warned = 1) && _warn(\"Warning: <path> length cannot be measured when vector-effect is non-scaling-stroke and the element isn't proportionally scaled.\");\n\t\t\tlength *= (scaleX + scaleY) / 2;\n\t\t\tstyle.strokeDasharray = prevPoint;\n\t\t} else if (type === \"rect\") {\n\t\t\tlength = width * 2 * scaleX + height * 2 * scaleY;\n\t\t} else if (type === \"line\") {\n\t\t\tlength = _getDistance(x, y, x + width, y + height, scaleX, scaleY);\n\t\t} else if (type === \"polyline\" || type === \"polygon\") {\n\t\t\tpoints = target.getAttribute(\"points\").match(_numExp) || [];\n\t\t\ttype === \"polygon\" && points.push(points[0], poinLine truncated
|
||||
+216
@@ -0,0 +1,216 @@
|
||||
(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';
|
||||
|
||||
/*!
|
||||
* EasePack 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 gsap,
|
||||
_registerEase,
|
||||
_getGSAP = function _getGSAP() {
|
||||
return gsap || typeof window !== "undefined" && (gsap = window.gsap) && gsap.registerPlugin && gsap;
|
||||
},
|
||||
_boolean = function _boolean(value, defaultValue) {
|
||||
return !!(typeof value === "undefined" ? defaultValue : value && !~(value + "").indexOf("false"));
|
||||
},
|
||||
_initCore = function _initCore(core) {
|
||||
gsap = core || _getGSAP();
|
||||
|
||||
if (gsap) {
|
||||
_registerEase = gsap.registerEase;
|
||||
|
||||
var eases = gsap.parseEase(),
|
||||
createConfig = function createConfig(ease) {
|
||||
return function (ratio) {
|
||||
var y = 0.5 + ratio / 2;
|
||||
|
||||
ease.config = function (p) {
|
||||
return ease(2 * (1 - p) * p * y + p * p);
|
||||
};
|
||||
};
|
||||
},
|
||||
p;
|
||||
|
||||
for (p in eases) {
|
||||
if (!eases[p].config) {
|
||||
createConfig(eases[p]);
|
||||
}
|
||||
}
|
||||
|
||||
_registerEase("slow", SlowMo);
|
||||
|
||||
_registerEase("expoScale", ExpoScaleEase);
|
||||
|
||||
_registerEase("rough", RoughEase);
|
||||
|
||||
for (p in EasePack) {
|
||||
p !== "version" && gsap.core.globals(p, EasePack[p]);
|
||||
}
|
||||
}
|
||||
},
|
||||
_createSlowMo = function _createSlowMo(linearRatio, power, yoyoMode) {
|
||||
linearRatio = Math.min(1, linearRatio || 0.7);
|
||||
|
||||
var pow = linearRatio < 1 ? power || power === 0 ? power : 0.7 : 0,
|
||||
p1 = (1 - linearRatio) / 2,
|
||||
p3 = p1 + linearRatio,
|
||||
calcEnd = _boolean(yoyoMode);
|
||||
|
||||
return function (p) {
|
||||
var r = p + (0.5 - p) * pow;
|
||||
return p < p1 ? calcEnd ? 1 - (p = 1 - p / p1) * p : r - (p = 1 - p / p1) * p * p * p * r : p > p3 ? calcEnd ? p === 1 ? 0 : 1 - (p = (p - p3) / p1) * p : r + (p - r) * (p = (p - p3) / p1) * p * p * p : calcEnd ? 1 : r;
|
||||
};
|
||||
},
|
||||
_createExpoScale = function _createExpoScale(start, end, ease) {
|
||||
var p1 = Math.log(end / start),
|
||||
p2 = end - start;
|
||||
ease && (ease = gsap.parseEase(ease));
|
||||
return function (p) {
|
||||
return (start * Math.exp(p1 * (ease ? ease(p) : p)) - start) / p2;
|
||||
};
|
||||
},
|
||||
EasePoint = function EasePoint(time, value, next) {
|
||||
this.t = time;
|
||||
this.v = value;
|
||||
|
||||
if (next) {
|
||||
this.next = next;
|
||||
next.prev = this;
|
||||
this.c = next.v - value;
|
||||
this.gap = next.t - time;
|
||||
}
|
||||
},
|
||||
_createRoughEase = function _createRoughEase(vars) {
|
||||
if (typeof vars !== "object") {
|
||||
vars = {
|
||||
points: +vars || 20
|
||||
};
|
||||
}
|
||||
|
||||
var taper = vars.taper || "none",
|
||||
a = [],
|
||||
cnt = 0,
|
||||
points = (+vars.points || 20) | 0,
|
||||
i = points,
|
||||
randomize = _boolean(vars.randomize, true),
|
||||
clamp = _boolean(vars.clamp),
|
||||
template = gsap ? gsap.parseEase(vars.template) : 0,
|
||||
strength = (+vars.strength || 1) * 0.4,
|
||||
x,
|
||||
y,
|
||||
bump,
|
||||
invX,
|
||||
obj,
|
||||
pnt,
|
||||
recent;
|
||||
|
||||
while (--i > -1) {
|
||||
x = randomize ? Math.random() : 1 / points * i;
|
||||
y = template ? template(x) : x;
|
||||
|
||||
if (taper === "none") {
|
||||
bump = strength;
|
||||
} else if (taper === "out") {
|
||||
invX = 1 - x;
|
||||
bump = invX * invX * strength;
|
||||
} else if (taper === "in") {
|
||||
bump = x * x * strength;
|
||||
} else if (x < 0.5) {
|
||||
invX = x * 2;
|
||||
bump = invX * invX * 0.5 * strength;
|
||||
} else {
|
||||
invX = (1 - x) * 2;
|
||||
bump = invX * invX * 0.5 * strength;
|
||||
}
|
||||
|
||||
if (randomize) {
|
||||
y += Math.random() * bump - bump * 0.5;
|
||||
} else if (i % 2) {
|
||||
y += bump * 0.5;
|
||||
} else {
|
||||
y -= bump * 0.5;
|
||||
}
|
||||
|
||||
if (clamp) {
|
||||
if (y > 1) {
|
||||
y = 1;
|
||||
} else if (y < 0) {
|
||||
y = 0;
|
||||
}
|
||||
}
|
||||
|
||||
a[cnt++] = {
|
||||
x: x,
|
||||
y: y
|
||||
};
|
||||
}
|
||||
|
||||
a.sort(function (a, b) {
|
||||
return a.x - b.x;
|
||||
});
|
||||
pnt = new EasePoint(1, 1, null);
|
||||
i = points;
|
||||
|
||||
while (i--) {
|
||||
obj = a[i];
|
||||
pnt = new EasePoint(obj.x, obj.y, pnt);
|
||||
}
|
||||
|
||||
recent = new EasePoint(0, 0, pnt.t ? pnt : pnt.next);
|
||||
return function (p) {
|
||||
var pnt = recent;
|
||||
|
||||
if (p > pnt.t) {
|
||||
while (pnt.next && p >= pnt.t) {
|
||||
pnt = pnt.next;
|
||||
}
|
||||
|
||||
pnt = pnt.prev;
|
||||
} else {
|
||||
while (pnt.prev && p <= pnt.t) {
|
||||
pnt = pnt.prev;
|
||||
}
|
||||
}
|
||||
|
||||
recent = pnt;
|
||||
return pnt.v + (p - pnt.t) / pnt.gap * pnt.c;
|
||||
};
|
||||
};
|
||||
|
||||
var SlowMo = _createSlowMo(0.7);
|
||||
SlowMo.ease = SlowMo;
|
||||
SlowMo.config = _createSlowMo;
|
||||
var ExpoScaleEase = _createExpoScale(1, 2);
|
||||
ExpoScaleEase.config = _createExpoScale;
|
||||
var RoughEase = _createRoughEase();
|
||||
RoughEase.ease = RoughEase;
|
||||
RoughEase.config = _createRoughEase;
|
||||
var EasePack = {
|
||||
SlowMo: SlowMo,
|
||||
RoughEase: RoughEase,
|
||||
ExpoScaleEase: ExpoScaleEase
|
||||
};
|
||||
|
||||
for (var p in EasePack) {
|
||||
EasePack[p].register = _initCore;
|
||||
EasePack[p].version = "3.14.2";
|
||||
}
|
||||
|
||||
_getGSAP() && gsap.registerPlugin(SlowMo);
|
||||
|
||||
exports.EasePack = EasePack;
|
||||
exports.ExpoScaleEase = ExpoScaleEase;
|
||||
exports.RoughEase = RoughEase;
|
||||
exports.SlowMo = SlowMo;
|
||||
exports.default = EasePack;
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
})));
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
/*!
|
||||
* EasePack 3.14.2
|
||||
* https://gsap.com
|
||||
*
|
||||
* @license Copyright 2025, GreenSock. All rights reserved.
|
||||
* Subject to the terms at https://gsap.com/standard-license.
|
||||
* @author: Jack Doyle, jack@greensock.com
|
||||
*/
|
||||
|
||||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e=e||self).window=e.window||{})}(this,function(e){"use strict";function f(){return w||"undefined"!=typeof window&&(w=window.gsap)&&w.registerPlugin&&w}function g(e,n){return!!(void 0===e?n:e&&!~(e+"").indexOf("false"))}function h(e){if(w=e||f()){r=w.registerEase;var n,t=w.parseEase(),o=function createConfig(t){return function(e){var n=.5+e/2;t.config=function(e){return t(2*(1-e)*e*n+e*e)}}};for(n in t)t[n].config||o(t[n]);for(n in r("slow",a),r("expoScale",s),r("rough",u),c)"version"!==n&&w.core.globals(n,c[n])}}function i(e,n,t){var o=(e=Math.min(1,e||.7))<1?n||0===n?n:.7:0,r=(1-e)/2,i=r+e,a=g(t);return function(e){var n=e+(.5-e)*o;return e<r?a?1-(e=1-e/r)*e:n-(e=1-e/r)*e*e*e*n:i<e?a?1===e?0:1-(e=(e-i)/r)*e:n+(e-n)*(e=(e-i)/r)*e*e*e:a?1:n}}function j(n,e,t){var o=Math.log(e/n),r=e-n;return t=t&&w.parseEase(t),function(e){return(n*Math.exp(o*(t?t(e):e))-n)/r}}function k(e,n,t){this.t=e,this.v=n,t&&(((this.next=t).prev=this).c=t.v-n,this.gap=t.t-e)}function l(e){"object"!=typeof e&&(e={points:+e||20});for(var n,t,o,r,i,a,f,s=e.taper||"none",u=[],c=0,p=0|(+e.points||20),l=p,v=g(e.randomize,!0),d=g(e.clamp),h=w?w.parseEase(e.template):0,x=.4*(+e.strength||1);-1<--l;)n=v?Math.random():1/p*l,t=h?h(n):n,o="none"===s?x:"out"===s?(r=1-n)*r*x:"in"===s?n*n*x:n<.5?(r=2*n)*r*.5*x:(r=2*(1-n))*r*.5*x,v?t+=Math.random()*o-.5*o:l%2?t+=.5*o:t-=.5*o,d&&(1<t?t=1:t<0&&(t=0)),u[c++]={x:n,y:t};for(u.sort(function(e,n){return e.x-n.x}),a=new k(1,1,null),l=p;l--;)i=u[l],a=new k(i.x,i.y,a);return f=new k(0,0,a.t?a:a.next),function(e){var n=f;if(e>n.t){for(;n.next&&e>=n.t;)n=n.next;n=n.prev}else for(;n.prev&&e<=n.t;)n=n.prev;return(f=n).v+(e-n.t)/n.gap*n.c}}var w,r,a=i(.7);(a.ease=a).config=i;var s=j(1,2);s.config=j;var u=l();(u.ease=u).config=l;var c={SlowMo:a,RoughEase:u,ExpoScaleEase:s};for(var n in c)c[n].register=h,c[n].version="3.14.2";f()&&w.registerPlugin(a),e.EasePack=c,e.ExpoScaleEase=s,e.RoughEase=u,e.SlowMo=a,e.default=c;if (typeof(window)==="undefined"||window!==e){Object.defineProperty(e,"__esModule",{value:!0})} else {delete e.default}});
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"EasePack.min.js","sources":["../src/EasePack.js"],"sourcesContent":["/*!\n * EasePack 3.14.2\n * https://gsap.com\n *\n * @license Copyright 2008-2025, GreenSock. All rights reserved.\n * Subject to the terms at https://gsap.com/standard-license\n * @author: Jack Doyle, jack@greensock.com\n*/\n/* eslint-disable */\n\nlet gsap, _coreInitted, _registerEase,\n\t_getGSAP = () => gsap || (typeof(window) !== \"undefined\" && (gsap = window.gsap) && gsap.registerPlugin && gsap),\n\t_boolean = (value, defaultValue) => !!(typeof(value) === \"undefined\" ? defaultValue : value && !~((value + \"\").indexOf(\"false\"))),\n\t_initCore = core => {\n\t\tgsap = core || _getGSAP();\n\t\tif (gsap) {\n\t\t\t_registerEase = gsap.registerEase;\n\t\t\t//add weighted ease capabilities to standard eases so users can do \"power2.inOut(0.8)\" for example to push everything toward the \"out\", or (-0.8) to push it toward the \"in\" (0 is neutral)\n\t\t\tlet eases = gsap.parseEase(),\n\t\t\t\tcreateConfig = ease => ratio => {\n\t\t\t\t\tlet y = 0.5 + ratio / 2;\n\t\t\t\t\tease.config = p => ease(2 * (1 - p) * p * y + p * p);\n\t\t\t\t},\n\t\t\t\tp;\n\t\t\tfor (p in eases) {\n\t\t\t\tif (!eases[p].config) {\n\t\t\t\t\tcreateConfig(eases[p]);\n\t\t\t\t}\n\t\t\t}\n\t\t\t_registerEase(\"slow\", SlowMo);\n\t\t\t_registerEase(\"expoScale\", ExpoScaleEase);\n\t\t\t_registerEase(\"rough\", RoughEase);\n\t\t\tfor (p in EasePack) {\n\t\t\t\tp !== \"version\" && gsap.core.globals(p, EasePack[p]);\n\t\t\t}\n\t\t\t_coreInitted = 1;\n\t\t}\n\t},\n\t_createSlowMo = (linearRatio, power, yoyoMode) => {\n\t\tlinearRatio = Math.min(1, linearRatio || 0.7);\n\t\tlet pow = linearRatio < 1 ? ((power || power === 0) ? power : 0.7) : 0,\n\t\t\tp1 = (1 - linearRatio) / 2,\n\t\t\tp3 = p1 + linearRatio,\n\t\t\tcalcEnd = _boolean(yoyoMode);\n\t\treturn p => {\n\t\t\tlet r = p + (0.5 - p) * pow;\n\t\t\treturn (p < p1) ? (calcEnd ? 1 - ((p = 1 - (p / p1)) * p) : r - ((p = 1 - (p / p1)) * p * p * p * r)) : (p > p3) ? (calcEnd ? (p === 1 ? 0 : 1 - (p = (p - p3) / p1) * p) : r + ((p - r) * (p = (p - p3) / p1) * p * p * p)) : (calcEnd ? 1 : r);\n\t\t}\n\t},\n\t_createExpoScale = (start, end, ease) => {\n\t\tlet p1 = Math.log(end / start),\n\t\t\tp2 = end - start;\n\t\tease && (ease = gsap.parseEase(ease));\n\t\treturn p => (start * Math.exp(p1 * (ease ? ease(p) : p)) - start) / p2;\n\t},\n\tEasePoint = function(time, value, next) {\n\t\tthis.t = time;\n\t\tthis.v = value;\n\t\tif (next) {\n\t\t\tthis.next = next;\n\t\t\tnext.prev = this;\n\t\t\tthis.c = next.v - value;\n\t\t\tthis.gap = next.t - time;\n\t\t}\n\t},\n\t_createRoughEase = vars => {\n\t\tif (typeof(vars) !== \"object\") { //users may pass in via a string, like \"rough(30)\"\n\t\t\tvars = {points: +vars || 20};\n\t\t}\n\t\tlet taper = vars.taper || \"none\",\n\t\t\ta = [],\n\t\t\tcnt = 0,\n\t\t\tpoints = (+vars.points || 20) | 0,\n\t\t\ti = points,\n\t\t\trandomize = _boolean(vars.randomize, true),\n\t\t\tclamp = _boolean(vars.clamp),\n\t\t\ttemplate = gsap ? gsap.parseEase(vars.template) : 0,\n\t\t\tstrength = (+vars.strength || 1) * 0.4,\n\t\t\tx, y, bump, invX, obj, pnt, recent;\n\t\twhile (--i > -1) {\n\t\t\tx = randomize ? Math.random() : (1 / points) * i;\n\t\t\ty = template ? template(x) : x;\n\t\t\tif (taper === \"none\") {\n\t\t\t\tbump = strength;\n\t\t\t} else if (taper === \"out\") {\n\t\t\t\tinvX = 1 - x;\n\t\t\t\tbump = invX * invX * strength;\n\t\t\t} else if (taper === \"in\") {\n\t\t\t\tbump = x * x * strength;\n\t\t\t} else if (x < 0.5) { //\"both\" (start)\n\t\t\t\tinvX = x * 2;\n\t\t\t\tbump = invX * invX * 0.5 * strength;\n\t\t\t} else {\t\t\t\t//\"both\" (end)\n\t\t\t\tinvX = (1 - x) * 2;\n\t\t\t\tbump = invX * invX * 0.5 * strength;\n\t\t\t}\n\t\t\tif (randomize) {\n\t\t\t\ty += (Math.random() * bump) - (bump * 0.5);\n\t\t\t} else if (i % 2) {\n\t\t\t\ty += bump * 0.5;\n\t\t\t} else {\n\t\t\t\ty -= bump * 0.5;\n\t\t\t}\n\t\t\tif (clamp) {\n\t\t\t\tif (y > 1) {\n\t\t\t\t\ty = 1;\n\t\t\t\t} else if (y < 0) {\n\t\t\t\t\ty = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\ta[cnt++] = {x:x, y:y};\n\t\t}\n\t\ta.sort((a, b) => a.x - b.x);\n\t\tpnt = new EasePoint(1, 1, null);\n\t\ti = points;\n\t\twhile (i--) {\n\t\t\tobj = a[i];\n\t\t\tpnt = new EasePoint(obj.x, obj.y, pnt);\n\t\t}\n\t\trecent = new EasePoint(0, 0, pnt.t ? pnt : pnt.next);\n\t\treturn p => {\n\t\t\tlet pnt = recent;\n\t\t\tif (p > pnt.t) {\n\t\t\t\twhile (pnt.next && p >= pnt.t) {\n\t\t\t\t\tpnt = pnt.next;\n\t\t\t\t}\n\t\t\t\tpnt = pnt.prev;\n\t\t\t} else {\n\t\t\t\twhile (pnt.prev && p <= pnt.t) {\n\t\t\t\t\tpnt = pnt.prev;\n\t\t\t\t}\n\t\t\t}\n\t\t\trecent = pnt;\n\t\t\treturn pnt.v + ((p - pnt.t) / pnt.gap) * pnt.c;\n\t\t};\n\t};\n\nexport const SlowMo = _createSlowMo(0.7);\nSlowMo.ease = SlowMo; //for backward compatibility\nSlowMo.config = _createSlowMo;\n\nexport const ExpoScaleEase = _createExpoScale(1, 2);\nExpoScaleEase.config = _createExpoScale;\n\nexport const RoughEase = _createRoughEase();\nRoughEase.ease Line truncated
|
||||
+350
@@ -0,0 +1,350 @@
|
||||
(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';
|
||||
|
||||
/*!
|
||||
* EaselPlugin 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 gsap,
|
||||
_coreInitted,
|
||||
_win,
|
||||
_createJS,
|
||||
_ColorFilter,
|
||||
_ColorMatrixFilter,
|
||||
_colorProps = "redMultiplier,greenMultiplier,blueMultiplier,alphaMultiplier,redOffset,greenOffset,blueOffset,alphaOffset".split(","),
|
||||
_windowExists = function _windowExists() {
|
||||
return typeof window !== "undefined";
|
||||
},
|
||||
_getGSAP = function _getGSAP() {
|
||||
return gsap || _windowExists() && (gsap = window.gsap) && gsap.registerPlugin && gsap;
|
||||
},
|
||||
_getCreateJS = function _getCreateJS() {
|
||||
return _createJS || _win && _win.createjs || _win || {};
|
||||
},
|
||||
_warn = function _warn(message) {
|
||||
return console.warn(message);
|
||||
},
|
||||
_cache = function _cache(target) {
|
||||
var b = target.getBounds && target.getBounds();
|
||||
|
||||
if (!b) {
|
||||
b = target.nominalBounds || {
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: 100,
|
||||
height: 100
|
||||
};
|
||||
target.setBounds && target.setBounds(b.x, b.y, b.width, b.height);
|
||||
}
|
||||
|
||||
target.cache && target.cache(b.x, b.y, b.width, b.height);
|
||||
|
||||
_warn("EaselPlugin: for filters to display in EaselJS, you must call the object's cache() method first. GSAP attempted to use the target's getBounds() for the cache but that may not be completely accurate. " + target);
|
||||
},
|
||||
_parseColorFilter = function _parseColorFilter(target, v, plugin) {
|
||||
if (!_ColorFilter) {
|
||||
_ColorFilter = _getCreateJS().ColorFilter;
|
||||
|
||||
if (!_ColorFilter) {
|
||||
_warn("EaselPlugin error: The EaselJS ColorFilter JavaScript file wasn't loaded.");
|
||||
}
|
||||
}
|
||||
|
||||
var filters = target.filters || [],
|
||||
i = filters.length,
|
||||
c,
|
||||
s,
|
||||
e,
|
||||
a,
|
||||
p,
|
||||
pt;
|
||||
|
||||
while (i--) {
|
||||
if (filters[i] instanceof _ColorFilter) {
|
||||
s = filters[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!s) {
|
||||
s = new _ColorFilter();
|
||||
filters.push(s);
|
||||
target.filters = filters;
|
||||
}
|
||||
|
||||
e = s.clone();
|
||||
|
||||
if (v.tint != null) {
|
||||
c = gsap.utils.splitColor(v.tint);
|
||||
a = v.tintAmount != null ? +v.tintAmount : 1;
|
||||
e.redOffset = +c[0] * a;
|
||||
e.greenOffset = +c[1] * a;
|
||||
e.blueOffset = +c[2] * a;
|
||||
e.redMultiplier = e.greenMultiplier = e.blueMultiplier = 1 - a;
|
||||
} else {
|
||||
for (p in v) {
|
||||
if (p !== "exposure") if (p !== "brightness") {
|
||||
e[p] = +v[p];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (v.exposure != null) {
|
||||
e.redOffset = e.greenOffset = e.blueOffset = 255 * (+v.exposure - 1);
|
||||
e.redMultiplier = e.greenMultiplier = e.blueMultiplier = 1;
|
||||
} else if (v.brightness != null) {
|
||||
a = +v.brightness - 1;
|
||||
e.redOffset = e.greenOffset = e.blueOffset = a > 0 ? a * 255 : 0;
|
||||
e.redMultiplier = e.greenMultiplier = e.blueMultiplier = 1 - Math.abs(a);
|
||||
}
|
||||
|
||||
i = 8;
|
||||
|
||||
while (i--) {
|
||||
p = _colorProps[i];
|
||||
|
||||
if (s[p] !== e[p]) {
|
||||
pt = plugin.add(s, p, s[p], e[p], 0, 0, 0, 0, 0, 1);
|
||||
|
||||
if (pt) {
|
||||
pt.op = "easel_colorFilter";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
plugin._props.push("easel_colorFilter");
|
||||
|
||||
if (!target.cacheID) {
|
||||
_cache(target);
|
||||
}
|
||||
},
|
||||
_idMatrix = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0],
|
||||
_lumR = 0.212671,
|
||||
_lumG = 0.715160,
|
||||
_lumB = 0.072169,
|
||||
_applyMatrix = function _applyMatrix(m, m2) {
|
||||
if (!(m instanceof Array) || !(m2 instanceof Array)) {
|
||||
return m2;
|
||||
}
|
||||
|
||||
var temp = [],
|
||||
i = 0,
|
||||
z = 0,
|
||||
y,
|
||||
x;
|
||||
|
||||
for (y = 0; y < 4; y++) {
|
||||
for (x = 0; x < 5; x++) {
|
||||
z = x === 4 ? m[i + 4] : 0;
|
||||
temp[i + x] = m[i] * m2[x] + m[i + 1] * m2[x + 5] + m[i + 2] * m2[x + 10] + m[i + 3] * m2[x + 15] + z;
|
||||
}
|
||||
|
||||
i += 5;
|
||||
}
|
||||
|
||||
return temp;
|
||||
},
|
||||
_setSaturation = function _setSaturation(m, n) {
|
||||
if (isNaN(n)) {
|
||||
return m;
|
||||
}
|
||||
|
||||
var inv = 1 - n,
|
||||
r = inv * _lumR,
|
||||
g = inv * _lumG,
|
||||
b = inv * _lumB;
|
||||
return _applyMatrix([r + n, g, b, 0, 0, r, g + n, b, 0, 0, r, g, b + n, 0, 0, 0, 0, 0, 1, 0], m);
|
||||
},
|
||||
_colorize = function _colorize(m, color, amount) {
|
||||
if (isNaN(amount)) {
|
||||
amount = 1;
|
||||
}
|
||||
|
||||
var c = gsap.utils.splitColor(color),
|
||||
r = c[0] / 255,
|
||||
g = c[1] / 255,
|
||||
b = c[2] / 255,
|
||||
inv = 1 - amount;
|
||||
return _applyMatrix([inv + amount * r * _lumR, amount * r * _lumG, amount * r * _lumB, 0, 0, amount * g * _lumR, inv + amount * g * _lumG, amount * g * _lumB, 0, 0, amount * b * _lumR, amount * b * _lumG, inv + amount * b * _lumB, 0, 0, 0, 0, 0, 1, 0], m);
|
||||
},
|
||||
_setHue = function _setHue(m, n) {
|
||||
if (isNaN(n)) {
|
||||
return m;
|
||||
}
|
||||
|
||||
n *= Math.PI / 180;
|
||||
var c = Math.cos(n),
|
||||
s = Math.sin(n);
|
||||
return _applyMatrix([_lumR + c * (1 - _lumR) + s * -_lumR, _lumG + c * -_lumG + s * -_lumG, _lumB + c * -_lumB + s * (1 - _lumB), 0, 0, _lumR + c * -_lumR + s * 0.143, _lumG + c * (1 - _lumG) + s * 0.14, _lumB + c * -_lumB + s * -0.283, 0, 0, _lumR + c * -_lumR + s * -(1 - _lumR), _lumG + c * -_lumG + s * _lumG, _lumB + c * (1 - _lumB) + s * _lumB, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1], m);
|
||||
},
|
||||
_setContrast = function _setContrast(m, n) {
|
||||
if (isNaN(n)) {
|
||||
return m;
|
||||
}
|
||||
|
||||
n += 0.01;
|
||||
return _applyMatrix([n, 0, 0, 0, 128 * (1 - n), 0, n, 0, 0, 128 * (1 - n), 0, 0, n, 0, 128 * (1 - n), 0, 0, 0, 1, 0], m);
|
||||
},
|
||||
_parseColorMatrixFilter = function _parseColorMatrixFilter(target, v, plugin) {
|
||||
if (!_ColorMatrixFilter) {
|
||||
_ColorMatrixFilter = _getCreateJS().ColorMatrixFilter;
|
||||
|
||||
if (!_ColorMatrixFilter) {
|
||||
_warn("EaselPlugin: The EaselJS ColorMatrixFilter JavaScript file wasn't loaded.");
|
||||
}
|
||||
}
|
||||
|
||||
var filters = target.filters || [],
|
||||
i = filters.length,
|
||||
matrix,
|
||||
startMatrix,
|
||||
s,
|
||||
pg;
|
||||
|
||||
while (--i > -1) {
|
||||
if (filters[i] instanceof _ColorMatrixFilter) {
|
||||
s = filters[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!s) {
|
||||
s = new _ColorMatrixFilter(_idMatrix.slice());
|
||||
filters.push(s);
|
||||
target.filters = filters;
|
||||
}
|
||||
|
||||
startMatrix = s.matrix;
|
||||
matrix = _idMatrix.slice();
|
||||
|
||||
if (v.colorize != null) {
|
||||
matrix = _colorize(matrix, v.colorize, Number(v.colorizeAmount));
|
||||
}
|
||||
|
||||
if (v.contrast != null) {
|
||||
matrix = _setContrast(matrix, Number(v.contrast));
|
||||
}
|
||||
|
||||
if (v.hue != null) {
|
||||
matrix = _setHue(matrix, Number(v.hue));
|
||||
}
|
||||
|
||||
if (v.saturation != null) {
|
||||
matrix = _setSaturation(matrix, Number(v.saturation));
|
||||
}
|
||||
|
||||
i = matrix.length;
|
||||
|
||||
while (--i > -1) {
|
||||
if (matrix[i] !== startMatrix[i]) {
|
||||
pg = plugin.add(startMatrix, i, startMatrix[i], matrix[i], 0, 0, 0, 0, 0, 1);
|
||||
|
||||
if (pg) {
|
||||
pg.op = "easel_colorMatrixFilter";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
plugin._props.push("easel_colorMatrixFilter");
|
||||
|
||||
if (!target.cacheID) {
|
||||
_cache();
|
||||
}
|
||||
|
||||
plugin._matrix = startMatrix;
|
||||
},
|
||||
_initCore = function _initCore(core) {
|
||||
gsap = core || _getGSAP();
|
||||
|
||||
if (_windowExists()) {
|
||||
_win = window;
|
||||
}
|
||||
|
||||
if (gsap) {
|
||||
_coreInitted = 1;
|
||||
}
|
||||
};
|
||||
|
||||
var EaselPlugin = {
|
||||
version: "3.14.2",
|
||||
name: "easel",
|
||||
init: function init(target, value, tween, index, targets) {
|
||||
if (!_coreInitted) {
|
||||
_initCore();
|
||||
|
||||
if (!gsap) {
|
||||
_warn("Please gsap.registerPlugin(EaselPlugin)");
|
||||
}
|
||||
}
|
||||
|
||||
this.target = target;
|
||||
var p, pt, tint, colorMatrix, end, labels, i;
|
||||
|
||||
for (p in value) {
|
||||
end = value[p];
|
||||
|
||||
if (p === "colorFilter" || p === "tint" || p === "tintAmount" || p === "exposure" || p === "brightness") {
|
||||
if (!tint) {
|
||||
_parseColorFilter(target, value.colorFilter || value, this);
|
||||
|
||||
tint = true;
|
||||
}
|
||||
} else if (p === "saturation" || p === "contrast" || p === "hue" || p === "colorize" || p === "colorizeAmount") {
|
||||
if (!colorMatrix) {
|
||||
_parseColorMatrixFilter(target, value.colorMatrixFilter || value, this);
|
||||
|
||||
colorMatrix = true;
|
||||
}
|
||||
} else if (p === "frame") {
|
||||
if (typeof end === "string" && end.charAt(1) !== "=" && (labels = target.labels)) {
|
||||
for (i = 0; i < labels.length; i++) {
|
||||
if (labels[i].label === end) {
|
||||
end = labels[i].position;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pt = this.add(target, "gotoAndStop", target.currentFrame, end, index, targets, Math.round, 0, 0, 1);
|
||||
|
||||
if (pt) {
|
||||
pt.op = p;
|
||||
}
|
||||
} else if (target[p] != null) {
|
||||
this.add(target, p, "get", end);
|
||||
}
|
||||
}
|
||||
},
|
||||
render: function render(ratio, data) {
|
||||
var pt = data._pt;
|
||||
|
||||
while (pt) {
|
||||
pt.r(ratio, pt.d);
|
||||
pt = pt._next;
|
||||
}
|
||||
|
||||
if (data.target.cacheID) {
|
||||
data.target.updateCache();
|
||||
}
|
||||
},
|
||||
register: _initCore
|
||||
};
|
||||
|
||||
EaselPlugin.registerCreateJS = function (createjs) {
|
||||
_createJS = createjs;
|
||||
};
|
||||
|
||||
_getGSAP() && gsap.registerPlugin(EaselPlugin);
|
||||
|
||||
exports.EaselPlugin = EaselPlugin;
|
||||
exports.default = EaselPlugin;
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
})));
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
/*!
|
||||
* EaselPlugin 3.14.2
|
||||
* https://gsap.com
|
||||
*
|
||||
* @license Copyright 2025, GreenSock. All rights reserved.
|
||||
* Subject to the terms at https://gsap.com/standard-license.
|
||||
* @author: Jack Doyle, jack@greensock.com
|
||||
*/
|
||||
|
||||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).window=e.window||{})}(this,function(e){"use strict";function k(){return"undefined"!=typeof window}function l(){return h||k()&&(h=window.gsap)&&h.registerPlugin&&h}function m(){return r||t&&t.createjs||t||{}}function n(e){return console.warn(e)}function o(e){var t=e.getBounds&&e.getBounds();t||(t=e.nominalBounds||{x:0,y:0,width:100,height:100},e.setBounds&&e.setBounds(t.x,t.y,t.width,t.height)),e.cache&&e.cache(t.x,t.y,t.width,t.height),n("EaselPlugin: for filters to display in EaselJS, you must call the object's cache() method first. GSAP attempted to use the target's getBounds() for the cache but that may not be completely accurate. "+e)}function p(e,t,r){(b=b||m().ColorFilter)||n("EaselPlugin error: The EaselJS ColorFilter JavaScript file wasn't loaded.");for(var i,l,s,u,a,f,c=e.filters||[],d=c.length;d--;)if(c[d]instanceof b){l=c[d];break}if(l||(l=new b,c.push(l),e.filters=c),s=l.clone(),null!=t.tint)i=h.utils.splitColor(t.tint),u=null!=t.tintAmount?+t.tintAmount:1,s.redOffset=i[0]*u,s.greenOffset=i[1]*u,s.blueOffset=i[2]*u,s.redMultiplier=s.greenMultiplier=s.blueMultiplier=1-u;else for(a in t)"exposure"!==a&&"brightness"!==a&&(s[a]=+t[a]);for(null!=t.exposure?(s.redOffset=s.greenOffset=s.blueOffset=255*(t.exposure-1),s.redMultiplier=s.greenMultiplier=s.blueMultiplier=1):null!=t.brightness&&(u=t.brightness-1,s.redOffset=s.greenOffset=s.blueOffset=0<u?255*u:0,s.redMultiplier=s.greenMultiplier=s.blueMultiplier=1-Math.abs(u)),d=8;d--;)l[a=M[d]]!==s[a]&&(f=r.add(l,a,l[a],s[a],0,0,0,0,0,1))&&(f.op="easel_colorFilter");r._props.push("easel_colorFilter"),e.cacheID||o(e)}function u(e,t){if(!(e instanceof Array&&t instanceof Array))return t;var r,i,n=[],l=0,o=0;for(r=0;r<4;r++){for(i=0;i<5;i++)o=4===i?e[l+4]:0,n[l+i]=e[l]*t[i]+e[l+1]*t[i+5]+e[l+2]*t[i+10]+e[l+3]*t[i+15]+o;l+=5}return n}function z(e,t,r){(d=d||m().ColorMatrixFilter)||n("EaselPlugin: The EaselJS ColorMatrixFilter JavaScript file wasn't loaded.");for(var i,l,s,a,f=e.filters||[],c=f.length;-1<--c;)if(f[c]instanceof d){s=f[c];break}for(s||(s=new d(w.slice()),f.push(s),e.filters=f),l=s.matrix,i=w.slice(),null!=t.colorize&&(i=function _colorize(e,t,r){isNaN(r)&&(r=1);var i=h.utils.splitColor(t),n=i[0]/255,l=i[1]/255,o=i[2]/255,s=1-r;return u([s+r*n*x,r*n*y,r*n*_,0,0,r*l*x,s+r*l*y,r*l*_,0,0,r*o*x,r*o*y,s+r*o*_,0,0,0,0,0,1,0],e)}(i,t.colorize,Number(t.colorizeAmount))),null!=t.contrast&&(i=function _setContrast(e,t){return isNaN(t)?e:u([t+=.01,0,0,0,128*(1-t),0,t,0,0,128*(1-t),0,0,t,0,128*(1-t),0,0,0,1,0],e)}(i,Number(t.contrast))),null!=t.hue&&(i=function _setHue(e,t){if(isNaN(t))return e;t*=Math.PI/180;var r=Math.cos(t),i=Math.sin(t);return u([x+r*(1-x)+i*-x,y+r*-y+i*-y,_+r*-_+i*(1-_),0,0,x+r*-x+.143*i,y+r*(1-y)+.14*i,_+r*-_+-.283*i,0,0,x+r*-x+i*-(1-x),y+r*-y+i*y,_+r*(1-_)+i*_,0,0,0,0,0,1,0,0,0,0,0,1],e)}(i,Number(t.hue))),null!=t.saturation&&(i=function _setSaturation(e,t){if(isNaN(t))return e;var r=1-t,i=r*x,n=r*y,l=r*_;return u([i+t,n,l,0,0,i,n+t,l,0,0,i,n,l+t,0,0,0,0,0,1,0],e)}(i,Number(t.saturation))),c=i.length;-1<--c;)i[c]!==l[c]&&(a=r.add(l,c,l[c],i[c],0,0,0,0,0,1))&&(a.op="easel_colorMatrixFilter");r._props.push("easel_colorMatrixFilter"),e.cacheID||o(),r._matrix=l}function A(e){h=e||l(),k()&&(t=window),h&&(g=1)}var h,g,t,r,b,d,M="redMultiplier,greenMultiplier,blueMultiplier,alphaMultiplier,redOffset,greenOffset,blueOffset,alphaOffset".split(","),w=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],x=.212671,y=.71516,_=.072169,i={version:"3.14.2",name:"easel",init:function init(e,t,r,i,l){var o,s,u,a,f,c,d;for(o in g||(A(),h||n("Please gsap.registerPlugin(EaselPlugin)")),this.target=e,t)if(f=t[o],"colorFilter"===o||"tint"===o||"tintAmount"===o||"exposure"===o||"brightness"===o)u||(p(e,t.colorFilter||t,this),u=!0);else if("saturation"===o||"contrast"===o||"hue"===o||"colorize"===o||"colorizeAmount"===o)a||(z(e,t.colorMatrixFilter||t,this),a=!0);else if("frame"===o){if("string"==typeof f&&"="!==f.charAt(1)&&(c=e.labels))for(d=0;d<c.length;d++)c[d].label===f&&(f=c[d].position);(s=this.add(e,"gotoAndStop",e.currentFrame,f,i,l,Math.round,0,0,1))&&(s.op=o)}else null!=e[o]&&this.add(e,o,"get",f)},render:function render(e,t){for(var r=t._pt;r;)r.r(e,r.d),r=r._next;t.target.cacheID&&t.target.updateCache()},register:A,registerCreateJS:function(e){r=e}};l()&&h.registerPlugin(i),e.EaselPlugin=i,e.default=i;if (typeof(window)==="undefined"||window!==e){Object.defineProperty(e,"__esModule",{value:!0})} else {delete e.default}});
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"EaselPlugin.min.js","sources":["../src/EaselPlugin.js"],"sourcesContent":["/*!\n * EaselPlugin 3.14.2\n * https://gsap.com\n *\n * @license Copyright 2008-2025, GreenSock. All rights reserved.\n * Subject to the terms at https://gsap.com/standard-license\n * @author: Jack Doyle, jack@greensock.com\n*/\n/* eslint-disable */\n\nlet gsap, _coreInitted, _win, _createJS, _ColorFilter, _ColorMatrixFilter,\n\t_colorProps = \"redMultiplier,greenMultiplier,blueMultiplier,alphaMultiplier,redOffset,greenOffset,blueOffset,alphaOffset\".split(\",\"),\n\t_windowExists = () => typeof(window) !== \"undefined\",\n\t_getGSAP = () => gsap || (_windowExists() && (gsap = window.gsap) && gsap.registerPlugin && gsap),\n\t_getCreateJS = () => _createJS || (_win && _win.createjs) || _win || {},\n\t_warn = message => console.warn(message),\n\t_cache = target => {\n\t\tlet b = target.getBounds && target.getBounds();\n\t\tif (!b) {\n\t\t\tb = target.nominalBounds || {x:0, y:0, width: 100, height: 100};\n\t\t\ttarget.setBounds && target.setBounds(b.x, b.y, b.width, b.height);\n\t\t}\n\t\ttarget.cache && target.cache(b.x, b.y, b.width, b.height);\n\t\t_warn(\"EaselPlugin: for filters to display in EaselJS, you must call the object's cache() method first. GSAP attempted to use the target's getBounds() for the cache but that may not be completely accurate. \" + target);\n\t},\n\t_parseColorFilter = (target, v, plugin) => {\n\t\tif (!_ColorFilter) {\n\t\t\t_ColorFilter = _getCreateJS().ColorFilter;\n\t\t\tif (!_ColorFilter) {\n\t\t\t\t_warn(\"EaselPlugin error: The EaselJS ColorFilter JavaScript file wasn't loaded.\");\n\t\t\t}\n\t\t}\n\t\tlet filters = target.filters || [],\n\t\t\ti = filters.length,\n\t\t\tc, s, e, a, p, pt;\n\t\twhile (i--) {\n\t\t\tif (filters[i] instanceof _ColorFilter) {\n\t\t\t\ts = filters[i];\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (!s) {\n\t\t\ts = new _ColorFilter();\n\t\t\tfilters.push(s);\n\t\t\ttarget.filters = filters;\n\t\t}\n\t\te = s.clone();\n\t\tif (v.tint != null) {\n\t\t\tc = gsap.utils.splitColor(v.tint);\n\t\t\ta = (v.tintAmount != null) ? +v.tintAmount : 1;\n\t\t\te.redOffset = +c[0] * a;\n\t\t\te.greenOffset = +c[1] * a;\n\t\t\te.blueOffset = +c[2] * a;\n\t\t\te.redMultiplier = e.greenMultiplier = e.blueMultiplier = 1 - a;\n\t\t} else {\n\t\t\tfor (p in v) {\n\t\t\t\tif (p !== \"exposure\") if (p !== \"brightness\") {\n\t\t\t\t\te[p] = +v[p];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (v.exposure != null) {\n\t\t\te.redOffset = e.greenOffset = e.blueOffset = 255 * (+v.exposure - 1);\n\t\t\te.redMultiplier = e.greenMultiplier = e.blueMultiplier = 1;\n\t\t} else if (v.brightness != null) {\n\t\t\ta = +v.brightness - 1;\n\t\t\te.redOffset = e.greenOffset = e.blueOffset = (a > 0) ? a * 255 : 0;\n\t\t\te.redMultiplier = e.greenMultiplier = e.blueMultiplier = 1 - Math.abs(a);\n\t\t}\n\t\ti = 8;\n\t\twhile (i--) {\n\t\t\tp = _colorProps[i];\n\t\t\tif (s[p] !== e[p]) {\n\t\t\t\tpt = plugin.add(s, p, s[p], e[p], 0, 0, 0, 0, 0, 1);\n\t\t\t\tif (pt) {\n\t\t\t\t\tpt.op = \"easel_colorFilter\";\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tplugin._props.push(\"easel_colorFilter\");\n\t\tif (!target.cacheID) {\n\t\t\t_cache(target);\n\t\t}\n\t},\n\n\t_idMatrix = [1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],\n\t_lumR = 0.212671,\n\t_lumG = 0.715160,\n\t_lumB = 0.072169,\n\n\t_applyMatrix = (m, m2) => {\n\t\tif (!(m instanceof Array) || !(m2 instanceof Array)) {\n\t\t\treturn m2;\n\t\t}\n\t\tlet temp = [],\n\t\t\ti = 0,\n\t\t\tz = 0,\n\t\t\ty, x;\n\t\tfor (y = 0; y < 4; y++) {\n\t\t\tfor (x = 0; x < 5; x++) {\n\t\t\t\tz = (x === 4) ? m[i + 4] : 0;\n\t\t\t\ttemp[i + x] = m[i] * m2[x] + m[i+1] * m2[x + 5] +\tm[i+2] * m2[x + 10] + m[i+3] * m2[x + 15] +\tz;\n\t\t\t}\n\t\t\ti += 5;\n\t\t}\n\t\treturn temp;\n\t},\n\n\t_setSaturation = (m, n) => {\n\t\tif (isNaN(n)) {\n\t\t\treturn m;\n\t\t}\n\t\tlet inv = 1 - n,\n\t\t\tr = inv * _lumR,\n\t\t\tg = inv * _lumG,\n\t\t\tb = inv * _lumB;\n\t\treturn _applyMatrix([r + n, g, b, 0, 0, r, g + n, b, 0, 0, r, g, b + n, 0, 0, 0, 0, 0, 1, 0], m);\n\t},\n\n\t_colorize = (m, color, amount) => {\n\t\tif (isNaN(amount)) {\n\t\t\tamount = 1;\n\t\t}\n\t\tlet c = gsap.utils.splitColor(color),\n\t\t\tr = c[0] / 255,\n\t\t\tg = c[1] / 255,\n\t\t\tb = c[2] / 255,\n\t\t\tinv = 1 - amount;\n\t\treturn _applyMatrix([inv + amount * r * _lumR, amount * r * _lumG, amount * r * _lumB, 0, 0, amount * g * _lumR, inv + amount * g * _lumG, amount * g * _lumB, 0, 0, amount * b * _lumR, amount * b * _lumG, inv + amount * b * _lumB, 0, 0, 0, 0, 0, 1, 0], m);\n\t},\n\n\t_setHue = (m, n) => {\n\t\tif (isNaN(n)) {\n\t\t\treturn m;\n\t\t}\n\t\tn *= Math.PI / 180;\n\t\tlet c = Math.cos(n),\n\t\t\ts = Math.sin(n);\n\t\treturn _applyMatrix([(_lumR + (c * (1 - _lumR))) + (s * (-_lumR)), (_lumG + (c * (-_lumG))) + (s * (-_lumG)), (_lumB + (c * (-_lumB))) + (s * (1 - _lumB)), 0, 0, (_lumR + (c * (-_lumR))) + (s * 0.143), (_lumG + (c * (1 - _lumG))) + (s * 0.14), (_lumB + (c * (-_lumB))) + (s * -0.283), 0, 0, (_lumR Line truncated
|
||||
+1874
File diff suppressed because it is too large.
Load diff
+11
@@ -0,0 +1,11 @@
|
||||
/*!
|
||||
* Flip 3.14.2
|
||||
* https://gsap.com
|
||||
*
|
||||
* @license Copyright 2025, GreenSock. All rights reserved.
|
||||
* Subject to the terms at https://gsap.com/standard-license.
|
||||
* @author: Jack Doyle, jack@greensock.com
|
||||
*/
|
||||
|
||||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).window=t.window||{})}(this,function(e){"use strict";function p(t){var e=t.ownerDocument||t;!(C in t.style)&&"msTransform"in t.style&&(k=(C="msTransform")+"Origin");for(;e.parentNode&&(e=e.parentNode););if(y=window,m=new F,e){a=(g=e).documentElement,b=e.body,(s=g.createElementNS("http://www.w3.org/2000/svg","g")).style.transform="none";var i=e.createElement("div"),n=e.createElement("div"),r=e&&(e.body||e.firstElementChild);r&&r.appendChild&&(r.appendChild(i),i.appendChild(n),i.style.position="static",i.style.transform="translate3d(0,0,1px)",w=n.offsetParent!==i,r.removeChild(i))}return e}function t(){return y.pageYOffset||g.scrollTop||a.scrollTop||b.scrollTop||0}function u(){return y.pageXOffset||g.scrollLeft||a.scrollLeft||b.scrollLeft||0}function v(t){return t.ownerSVGElement||("svg"===(t.tagName+"").toLowerCase()?t:null)}function x(t,e){if(t.parentNode&&(g||p(t))){var i=v(t),n=i?i.getAttribute("xmlns")||"http://www.w3.org/2000/svg":"http://www.w3.org/1999/xhtml",r=i?e?"rect":"g":"div",a=2!==e?0:100,s=3===e?100:0,o={position:"absolute",display:"block",pointerEvents:"none",margin:"0",padding:"0"},l=g.createElementNS?g.createElementNS(n.replace(/^https/,"http"),r):g.createElement(r);return e&&(i?(d=d||x(t),l.setAttribute("width",.01),l.setAttribute("height",.01),l.setAttribute("transform","translate("+a+","+s+")"),l.setAttribute("fill","transparent"),d.appendChild(l)):(f||(f=x(t),Object.assign(f.style,o)),Object.assign(l.style,o,{width:"0.1px",height:"0.1px",top:s+"px",left:a+"px"}),f.appendChild(l))),l}throw"Need document and parent."}function z(t){var e,i=t.getCTM();return i||(e=t.style[C],t.style[C]="none",t.appendChild(s),i=s.getCTM(),t.removeChild(s),e?t.style[C]=e:t.style.removeProperty(C.replace(/([A-Z])/g,"-$1").toLowerCase())),i||m.clone()}function A(t,e){var i,n,r,a,s,o,l=v(t),u=t===l,h=l?E:M,p=t.parentNode,c=p&&!l&&p.shadowRoot&&p.shadowRoot.appendChild?p.shadowRoot:p;if(t===y)return t;if(h.length||h.push(x(t,1),x(t,2),x(t,3)),i=l?d:f,l)u?(a=-(r=z(t)).e/r.a,s=-r.f/r.d,n=m):t.getBBox?(r=t.getBBox(),a=(n=(n=t.transform?t.transform.baseVal:{}).numberOfItems?1<n.numberOfItems?function _consolidate(t){for(var e=new F,i=0;i<t.numberOfItems;i++)e.multiply(t.getItem(i).matrix);return e}(n):n.getItem(0).matrix:m).a*r.x+n.c*r.y,s=n.b*r.x+n.d*r.y):(n=new F,a=s=0),e&&"g"===t.tagName.toLowerCase()&&(a=s=0),(u||!t.getBoundingClientRect().width?l:p).appendChild(i),i.setAttribute("transform","matrix("+n.a+","+n.b+","+n.c+","+n.d+","+(n.e+a)+","+(n.f+s)+")");else{if(a=s=0,w)for(n=t.offsetParent,r=t;(r=r&&r.parentNode)&&r!==n&&r.parentNode;)4<(y.getComputedStyle(r)[C]+"").length&&(a=r.offsetLeft,s=r.offsetTop,r=0);if("absolute"!==(o=y.getComputedStyle(t)).position&&"fixed"!==o.position)for(n=t.offsetParent;p&&p!==n;)a+=p.scrollLeft||0,s+=p.scrollTop||0,p=p.parentNode;(r=i.style).top=t.offsetTop-s+"px",r.left=t.offsetLeft-a+"px",r[C]=o[C],r[k]=o[k],r.position="fixed"===o.position?"fixed":"absolute",c.appendChild(i)}return i}function B(t,e,i,n,r,a,s){return t.a=e,t.b=i,t.c=n,t.d=r,t.e=a,t.f=s,t}var g,y,a,b,f,d,m,s,w,i,C="transform",k=C+"Origin",E=[],M=[],F=((i=Matrix2D.prototype).inverse=function inverse(){var t=this.a,e=this.b,i=this.c,n=this.d,r=this.e,a=this.f,s=t*n-e*i||1e-10;return B(this,n/s,-e/s,-i/s,t/s,(i*a-n*r)/s,-(t*a-e*r)/s)},i.multiply=function multiply(t){var e=this.a,i=this.b,n=this.c,r=this.d,a=this.e,s=this.f,o=t.a,l=t.c,u=t.b,h=t.d,p=t.e,c=t.f;return B(this,o*e+u*n,o*i+u*r,l*e+h*n,l*i+h*r,a+p*e+c*n,s+p*i+c*r)},i.clone=function clone(){return new Matrix2D(this.a,this.b,this.c,this.d,this.e,this.f)},i.equals=function equals(t){var e=this.a,i=this.b,n=this.c,r=this.d,a=this.e,s=this.f;return e===t.a&&i===t.b&&n===t.c&&r===t.d&&a===t.e&&s===t.f},i.apply=function apply(t,e){void 0===e&&(e={});var i=t.x,n=t.y,r=this.a,a=this.b,s=this.c,o=this.d,l=this.e,u=this.f;return e.x=i*r+n*s+l||0,e.y=i*a+n*o+u||0,e},Matrix2D);function Matrix2D(t,e,i,n,r,a){void 0===t&&(t=1),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=1),void 0===r&&(r=0),void 0===a&&(a=0),B(this,t,e,i,n,r,a)}function getGlobalMatrix(e,i,n,r){if(!e||!e.parentNode||(g||p(e)).documentElement===e)return new F;var a=function _forceNonZeroScale(t){for(var e,i;t&&t!==b;)(i=t._gsap)&&i.uncache&&i.get(t,"x"),i&&!i.scaleX&&!i.scaleY&&i.renderTransform&&(i.scaleX=i.scaleY=1e-4,i.renderTransform(1,i),e?e.push(i):e=[i]),t=t.parentNode;return e}(e),s=v(e)?E:M,o=A(e,n),l=s[0].getBoundingClientRect(),h=s[1].getBoundingClientRect(),c=s[2].getBoundingClientRect(),f=o.parentNode,d=!r&&function _isFixed(t){return"fixed"===y.getComputedStyle(t).position||((t=t.parentNode)&&1===t.nodeType?_isFixed(t):void 0)}(e),m=new F((h.left-l.left)/100,(h.top-l.top)/100,(c.left-l.left)/100,(c.top-l.top)/100,l.left+(d?0:u()),l.top+(d?0:t()));if(f.removeChild(o),a)for(l=a.length;l--;)(h=a[l]).scaleX=h.scaleY=0,h.renderTransformLine truncated
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Flip.min.js","sources":["../src/utils/matrix.js","../src/Flip.js"],"sourcesContent":["/*!\n * matrix 3.14.2\n * https://gsap.com\n *\n * Copyright 2008-2025, GreenSock. All rights reserved.\n * Subject to the terms at https://gsap.com/standard-license\n * @author: Jack Doyle, jack@greensock.com\n*/\n/* eslint-disable */\n\nlet _doc, _win, _docElement, _body,\t_divContainer, _svgContainer, _identityMatrix, _gEl,\n\t_transformProp = \"transform\",\n\t_transformOriginProp = _transformProp + \"Origin\",\n\t_hasOffsetBug,\n\t_setDoc = element => {\n\t\tlet doc = element.ownerDocument || element;\n\t\tif (!(_transformProp in element.style) && \"msTransform\" in element.style) { //to improve compatibility with old Microsoft browsers\n\t\t\t_transformProp = \"msTransform\";\n\t\t\t_transformOriginProp = _transformProp + \"Origin\";\n\t\t}\n\t\twhile (doc.parentNode && (doc = doc.parentNode)) {\t}\n\t\t_win = window;\n\t\t_identityMatrix = new Matrix2D();\n\t\tif (doc) {\n\t\t\t_doc = doc;\n\t\t\t_docElement = doc.documentElement;\n\t\t\t_body = doc.body;\n\t\t\t_gEl = _doc.createElementNS(\"http://www.w3.org/2000/svg\", \"g\");\n\t\t\t// prevent any existing CSS from transforming it\n\t\t\t_gEl.style.transform = \"none\";\n\t\t\t// 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.\n\t\t\tlet d1 = doc.createElement(\"div\"),\n\t\t\t\td2 = doc.createElement(\"div\"),\n\t\t\t\troot = doc && (doc.body || doc.firstElementChild);\n\t\t\tif (root && root.appendChild) {\n\t\t\t\troot.appendChild(d1);\n\t\t\t\td1.appendChild(d2);\n\t\t\t\td1.style.position = \"static\";\n\t\t\t\td1.style.transform = \"translate3d(0,0,1px)\";\n\t\t\t\t_hasOffsetBug = (d2.offsetParent !== d1);\n\t\t\t\troot.removeChild(d1);\n\t\t\t}\n\t\t}\n\t\treturn doc;\n\t},\n\t_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.\n\t\tlet a, cache;\n\t\twhile (e && e !== _body) {\n\t\t\tcache = e._gsap;\n\t\t\tcache && cache.uncache && cache.get(e, \"x\"); // force re-parsing of transforms if necessary\n\t\t\tif (cache && !cache.scaleX && !cache.scaleY && cache.renderTransform) {\n\t\t\t\tcache.scaleX = cache.scaleY = 1e-4;\n\t\t\t\tcache.renderTransform(1, cache);\n\t\t\t\ta ? a.push(cache) : (a = [cache]);\n\t\t\t}\n\t\t\te = e.parentNode;\n\t\t}\n\t\treturn a;\n\t},\n\t// 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.\n\t// _forceDisplay = e => {\n\t// \tlet a = [],\n\t// \t\tparent;\n\t// \twhile (e && e !== _body) {\n\t// \t\tparent = e.parentNode;\n\t// \t\t(_win.getComputedStyle(e).display === \"none\" || !parent) && a.push(e, e.style.display, parent) && (e.style.display = \"block\");\n\t// \t\tparent || _body.appendChild(e);\n\t// \t\te = parent;\n\t// \t}\n\t// \treturn a;\n\t// },\n\t// _revertDisplay = a => {\n\t// \tfor (let i = 0; i < a.length; i+=3) {\n\t// \t\ta[i+1] ? (a[i].style.display = a[i+1]) : a[i].style.removeProperty(\"display\");\n\t// \t\ta[i+2] || a[i].parentNode.removeChild(a[i]);\n\t// \t}\n\t// },\n\t_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.\n\t_divTemps = [],\n\t_getDocScrollTop = () => _win.pageYOffset || _doc.scrollTop || _docElement.scrollTop || _body.scrollTop || 0,\n\t_getDocScrollLeft = () => _win.pageXOffset || _doc.scrollLeft || _docElement.scrollLeft || _body.scrollLeft || 0,\n\t_svgOwner = element => element.ownerSVGElement || ((element.tagName + \"\").toLowerCase() === \"svg\" ? element : null),\n\t_isFixed = element => {\n\t\tif (_win.getComputedStyle(element).position === \"fixed\") {\n\t\t\treturn true;\n\t\t}\n\t\telement = element.parentNode;\n\t\tif (element && element.nodeType === 1) { // avoid document fragments which will throw an error.\n\t\t\treturn _isFixed(element);\n\t\t}\n\t},\n\t_createSibling = (element, i) => {\n\t\tif (element.parentNode && (_doc || _setDoc(element))) {\n\t\t\tlet svg = _svgOwner(element),\n\t\t\t\tns = svg ? (svg.getAttribute(\"xmlns\") || \"http://www.w3.org/2000/svg\") : \"http://www.w3.org/1999/xhtml\",\n\t\t\t\ttype = svg ? (i ? \"rect\" : \"g\") : \"div\",\n\t\t\t\tx = i !== 2 ? 0 : 100,\n\t\t\t\ty = i === 3 ? 100 : 0,\n\t\t\t\tcss = {position: \"absolute\", display: \"block\", pointerEvents: \"none\", margiLine truncated
|
||||
+4468
File diff suppressed because it is too large.
Load diff
+11
@@ -0,0 +1,11 @@
|
||||
/*!
|
||||
* GSDevTools 3.14.2
|
||||
* https://gsap.com
|
||||
*
|
||||
* @license Copyright 2025, GreenSock. All rights reserved.
|
||||
* Subject to the terms at https://gsap.com/standard-license.
|
||||
* @author: Jack Doyle, jack@greensock.com
|
||||
*/
|
||||
|
||||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).window=e.window||{})}(this,function(e){"use strict";function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function w(e,t){if(e.parentNode&&(g||M(e))){var o=P(e),n=o?o.getAttribute("xmlns")||"http://www.w3.org/2000/svg":"http://www.w3.org/1999/xhtml",i=o?t?"rect":"g":"div",r=2!==t?0:100,a=3===t?100:0,s={position:"absolute",display:"block",pointerEvents:"none",margin:"0",padding:"0"},l=g.createElementNS?g.createElementNS(n.replace(/^https/,"http"),i):g.createElement(i);return t&&(o?(m=m||w(e),l.setAttribute("width",.01),l.setAttribute("height",.01),l.setAttribute("transform","translate("+r+","+a+")"),l.setAttribute("fill","transparent"),m.appendChild(l)):(h||(h=w(e),Object.assign(h.style,s)),Object.assign(l.style,s,{width:"0.1px",height:"0.1px",top:a+"px",left:r+"px"}),h.appendChild(l))),l}throw"Need document and parent."}function A(e,t,o,n,i,r,a){return e.a=t,e.b=o,e.c=n,e.d=i,e.e=r,e.f=a,e}var g,f,r,a,h,m,v,x,y,t,b="transform",T=b+"Origin",M=function _setDoc(e){var t=e.ownerDocument||e;!(b in e.style)&&"msTransform"in e.style&&(T=(b="msTransform")+"Origin");for(;t.parentNode&&(t=t.parentNode););if(f=window,v=new he,t){r=(g=t).documentElement,a=t.body,(x=g.createElementNS("http://www.w3.org/2000/svg","g")).style.transform="none";var o=t.createElement("div"),n=t.createElement("div"),i=t&&(t.body||t.firstElementChild);i&&i.appendChild&&(i.appendChild(o),o.appendChild(n),o.style.position="static",o.style.transform="translate3d(0,0,1px)",y=n.offsetParent!==o,i.removeChild(o))}return t},k=function _forceNonZeroScale(e){for(var t,o;e&&e!==a;)(o=e._gsap)&&o.uncache&&o.get(e,"x"),o&&!o.scaleX&&!o.scaleY&&o.renderTransform&&(o.scaleX=o.scaleY=1e-4,o.renderTransform(1,o),t?t.push(o):t=[o]),e=e.parentNode;return t},D=[],C=[],S=function _getDocScrollTop(){return f.pageYOffset||g.scrollTop||r.scrollTop||a.scrollTop||0},E=function _getDocScrollLeft(){return f.pageXOffset||g.scrollLeft||r.scrollLeft||a.scrollLeft||0},P=function _svgOwner(e){return e.ownerSVGElement||("svg"===(e.tagName+"").toLowerCase()?e:null)},L=function _isFixed(e){return"fixed"===f.getComputedStyle(e).position||((e=e.parentNode)&&1===e.nodeType?_isFixed(e):void 0)},N=function _placeSiblings(e,t){var o,n,i,r,a,s,l=P(e),d=e===l,c=l?D:C,p=e.parentNode,u=p&&!l&&p.shadowRoot&&p.shadowRoot.appendChild?p.shadowRoot:p;if(e===f)return e;if(c.length||c.push(w(e,1),w(e,2),w(e,3)),o=l?m:h,l)d?(r=-(i=function _getCTM(e){var t,o=e.getCTM();return o||(t=e.style[b],e.style[b]="none",e.appendChild(x),o=x.getCTM(),e.removeChild(x),t?e.style[b]=t:e.style.removeProperty(b.replace(/([A-Z])/g,"-$1").toLowerCase())),o||v.clone()}(e)).e/i.a,a=-i.f/i.d,n=v):e.getBBox?(i=e.getBBox(),r=(n=(n=e.transform?e.transform.baseVal:{}).numberOfItems?1<n.numberOfItems?function _consolidate(e){for(var t=new he,o=0;o<e.numberOfItems;o++)t.multiply(e.getItem(o).matrix);return t}(n):n.getItem(0).matrix:v).a*i.x+n.c*i.y,a=n.b*i.x+n.d*i.y):(n=new he,r=a=0),t&&"g"===e.tagName.toLowerCase()&&(r=a=0),(d||!e.getBoundingClientRect().width?l:p).appendChild(o),o.setAttribute("transform","matrix("+n.a+","+n.b+","+n.c+","+n.d+","+(n.e+r)+","+(n.f+a)+")");else{if(r=a=0,y)for(n=e.offsetParent,i=e;(i=i&&i.parentNode)&&i!==n&&i.parentNode;)4<(f.getComputedStyle(i)[b]+"").length&&(r=i.offsetLeft,a=i.offsetTop,i=0);if("absolute"!==(s=f.getComputedStyle(e)).position&&"fixed"!==s.position)for(n=e.offsetParent;p&&p!==n;)r+=p.scrollLeft||0,a+=p.scrollTop||0,p=p.parentNode;(i=o.style).top=e.offsetTop-a+"px",i.left=e.offsetLeft-r+"px",i[b]=s[b],i[T]=s[T],i.position="fixed"===s.position?"fixed":"absolute",u.appendChild(o)}return o},he=((t=Matrix2D.prototype).inverse=function inverse(){var e=this.a,t=this.b,o=this.c,n=this.d,i=this.e,r=this.f,a=e*n-t*o||1e-10;return A(this,n/a,-t/a,-o/a,e/a,(o*r-n*i)/a,-(e*r-t*i)/a)},t.multiply=function multiply(e){var t=this.a,o=this.b,n=this.c,i=this.d,r=this.e,a=this.f,s=e.a,l=e.c,d=e.b,c=e.d,p=e.e,u=e.f;return A(this,s*t+d*n,s*o+d*i,l*t+c*n,l*o+c*i,r+p*t+u*n,a+p*o+u*i)},t.clone=function clone(){return new Matrix2D(this.a,this.b,this.c,this.d,this.e,this.f)},t.equals=function equals(e){var t=this.a,o=this.b,n=this.c,i=this.d,r=this.e,a=this.f;return t===e.a&&o===e.b&&n===e.c&&i===e.d&&r===e.e&&a===e.f},t.apply=function apply(e,t){void 0===t&&(t={});var o=e.x,n=e.y,i=this.a,r=this.b,a=this.c,s=this.d,l=this.e,d=this.f;return t.x=o*i+n*a+l||0,t.y=o*r+n*s+d||0,t},Matrix2D);function Matrix2D(e,t,o,n,i,r){void 0===e&&(e=1),void 0===t&&(t=0),void 0===o&&(o=0),void 0===n&&(n=1),void 0===i&&(i=0),void 0===r&&(r=0),A(this,e,t,o,n,i,r)}function getGlobalMatrix(e,t,o,n){if(!e||!e.parentNode||(g||M(e)).documentElement===e)return new he;var i=k(e),r=P(e)?D:C,a=N(e,o),s=r[0].getBoundingClientRect(),l=r[1].getBoundingClientRect(),d=r[2].getBoundingClientReLine truncated
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"GSDevTools.min.js","sources":["../src/utils/matrix.js","../src/Draggable.js","../src/GSDevTools.js"],"sourcesContent":["/*!\n * matrix 3.14.2\n * https://gsap.com\n *\n * Copyright 2008-2025, GreenSock. All rights reserved.\n * Subject to the terms at https://gsap.com/standard-license\n * @author: Jack Doyle, jack@greensock.com\n*/\n/* eslint-disable */\n\nlet _doc, _win, _docElement, _body,\t_divContainer, _svgContainer, _identityMatrix, _gEl,\n\t_transformProp = \"transform\",\n\t_transformOriginProp = _transformProp + \"Origin\",\n\t_hasOffsetBug,\n\t_setDoc = element => {\n\t\tlet doc = element.ownerDocument || element;\n\t\tif (!(_transformProp in element.style) && \"msTransform\" in element.style) { //to improve compatibility with old Microsoft browsers\n\t\t\t_transformProp = \"msTransform\";\n\t\t\t_transformOriginProp = _transformProp + \"Origin\";\n\t\t}\n\t\twhile (doc.parentNode && (doc = doc.parentNode)) {\t}\n\t\t_win = window;\n\t\t_identityMatrix = new Matrix2D();\n\t\tif (doc) {\n\t\t\t_doc = doc;\n\t\t\t_docElement = doc.documentElement;\n\t\t\t_body = doc.body;\n\t\t\t_gEl = _doc.createElementNS(\"http://www.w3.org/2000/svg\", \"g\");\n\t\t\t// prevent any existing CSS from transforming it\n\t\t\t_gEl.style.transform = \"none\";\n\t\t\t// 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.\n\t\t\tlet d1 = doc.createElement(\"div\"),\n\t\t\t\td2 = doc.createElement(\"div\"),\n\t\t\t\troot = doc && (doc.body || doc.firstElementChild);\n\t\t\tif (root && root.appendChild) {\n\t\t\t\troot.appendChild(d1);\n\t\t\t\td1.appendChild(d2);\n\t\t\t\td1.style.position = \"static\";\n\t\t\t\td1.style.transform = \"translate3d(0,0,1px)\";\n\t\t\t\t_hasOffsetBug = (d2.offsetParent !== d1);\n\t\t\t\troot.removeChild(d1);\n\t\t\t}\n\t\t}\n\t\treturn doc;\n\t},\n\t_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.\n\t\tlet a, cache;\n\t\twhile (e && e !== _body) {\n\t\t\tcache = e._gsap;\n\t\t\tcache && cache.uncache && cache.get(e, \"x\"); // force re-parsing of transforms if necessary\n\t\t\tif (cache && !cache.scaleX && !cache.scaleY && cache.renderTransform) {\n\t\t\t\tcache.scaleX = cache.scaleY = 1e-4;\n\t\t\t\tcache.renderTransform(1, cache);\n\t\t\t\ta ? a.push(cache) : (a = [cache]);\n\t\t\t}\n\t\t\te = e.parentNode;\n\t\t}\n\t\treturn a;\n\t},\n\t// 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.\n\t// _forceDisplay = e => {\n\t// \tlet a = [],\n\t// \t\tparent;\n\t// \twhile (e && e !== _body) {\n\t// \t\tparent = e.parentNode;\n\t// \t\t(_win.getComputedStyle(e).display === \"none\" || !parent) && a.push(e, e.style.display, parent) && (e.style.display = \"block\");\n\t// \t\tparent || _body.appendChild(e);\n\t// \t\te = parent;\n\t// \t}\n\t// \treturn a;\n\t// },\n\t// _revertDisplay = a => {\n\t// \tfor (let i = 0; i < a.length; i+=3) {\n\t// \t\ta[i+1] ? (a[i].style.display = a[i+1]) : a[i].style.removeProperty(\"display\");\n\t// \t\ta[i+2] || a[i].parentNode.removeChild(a[i]);\n\t// \t}\n\t// },\n\t_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.\n\t_divTemps = [],\n\t_getDocScrollTop = () => _win.pageYOffset || _doc.scrollTop || _docElement.scrollTop || _body.scrollTop || 0,\n\t_getDocScrollLeft = () => _win.pageXOffset || _doc.scrollLeft || _docElement.scrollLeft || _body.scrollLeft || 0,\n\t_svgOwner = element => element.ownerSVGElement || ((element.tagName + \"\").toLowerCase() === \"svg\" ? element : null),\n\t_isFixed = element => {\n\t\tif (_win.getComputedStyle(element).position === \"fixed\") {\n\t\t\treturn true;\n\t\t}\n\t\telement = element.parentNode;\n\t\tif (element && element.nodeType === 1) { // avoid document fragments which will throw an error.\n\t\t\treturn _isFixed(element);\n\t\t}\n\t},\n\t_createSibling = (element, i) => {\n\t\tif (element.parentNode && (_doc || _setDoc(element))) {\n\t\t\tlet svg = _svgOwner(element),\n\t\t\t\tns = svg ? (svg.getAttribute(\"xmlns\") || \"http://www.w3.org/2000/svg\") : \"http://www.w3.org/1999/xhtml\",\n\t\t\t\ttype = svg ? (i ? \"rect\" : \"g\") : \"div\",\n\t\t\t\tx = i !== 2 ? 0 : 100,\n\t\t\t\ty = i === 3 ? 100 : 0,\n\t\t\t\tcss = {position: \"absolute\", display: \"blockLine truncated
|
||||
+714
@@ -0,0 +1,714 @@
|
||||
(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 gsap,
|
||||
_coreInitted,
|
||||
_toArray,
|
||||
_getUnit,
|
||||
_first,
|
||||
_ticker,
|
||||
_time1,
|
||||
_time2,
|
||||
_getCache,
|
||||
_getGSAP = function _getGSAP() {
|
||||
return gsap || typeof window !== "undefined" && (gsap = window.gsap);
|
||||
},
|
||||
_lookup = {},
|
||||
_round = function _round(value) {
|
||||
return Math.round(value * 10000) / 10000;
|
||||
},
|
||||
_getID = function _getID(target) {
|
||||
return _getCache(target).id;
|
||||
},
|
||||
_getByTarget = function _getByTarget(target) {
|
||||
return _lookup[_getID(typeof target === "string" ? _toArray(target)[0] : target)];
|
||||
},
|
||||
_onTick = function _onTick(time) {
|
||||
var pt = _first,
|
||||
val;
|
||||
|
||||
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) {
|
||||
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 = function _initCore() {
|
||||
gsap = _getGSAP();
|
||||
|
||||
if (gsap) {
|
||||
_toArray = gsap.utils.toArray;
|
||||
_getUnit = gsap.utils.getUnit;
|
||||
_getCache = gsap.core.getCache;
|
||||
_ticker = gsap.ticker;
|
||||
_coreInitted = 1;
|
||||
}
|
||||
};
|
||||
|
||||
var PropTracker = function PropTracker(target, property, type, next) {
|
||||
this.t = target;
|
||||
this.p = property;
|
||||
this.g = target._gsap.get;
|
||||
this.rCap = _types[type || _getUnit(this.g(target, property))];
|
||||
this.v1 = this.v2 = this.g(target, property);
|
||||
this.t1 = this.t2 = _ticker.time;
|
||||
|
||||
if (next) {
|
||||
this._next = next;
|
||||
next._prev = this;
|
||||
}
|
||||
};
|
||||
|
||||
var VelocityTracker = function () {
|
||||
function VelocityTracker(target, property) {
|
||||
_coreInitted || _initCore();
|
||||
this.target = _toArray(target)[0];
|
||||
_lookup[_getID(this.target)] = this;
|
||||
this._props = {};
|
||||
property && this.add(property);
|
||||
}
|
||||
|
||||
VelocityTracker.register = function register(core) {
|
||||
gsap = core;
|
||||
|
||||
_initCore();
|
||||
};
|
||||
|
||||
var _proto = VelocityTracker.prototype;
|
||||
|
||||
_proto.get = function get(property, skipRecentTick) {
|
||||
var 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) {
|
||||
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));
|
||||
};
|
||||
|
||||
_proto.getAll = function getAll() {
|
||||
var result = {},
|
||||
props = this._props,
|
||||
p;
|
||||
|
||||
for (p in props) {
|
||||
result[p] = this.get(p);
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
_proto.isTracking = function isTracking(property) {
|
||||
return property in this._props;
|
||||
};
|
||||
|
||||
_proto.add = function add(property, type) {
|
||||
var pt = this._props[property];
|
||||
|
||||
if (pt) {
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
||||
_proto.remove = function remove(property) {
|
||||
var 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];
|
||||
}
|
||||
};
|
||||
|
||||
_proto.kill = function kill(shallow) {
|
||||
for (var p in this._props) {
|
||||
this.remove(p);
|
||||
}
|
||||
|
||||
if (!shallow) {
|
||||
delete _lookup[_getID(this.target)];
|
||||
}
|
||||
};
|
||||
|
||||
VelocityTracker.track = function track(targets, properties, types) {
|
||||
_coreInitted || _initCore();
|
||||
|
||||
var 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;
|
||||
};
|
||||
|
||||
VelocityTracker.untrack = function untrack(targets, properties) {
|
||||
var props = properties && properties.split(",");
|
||||
|
||||
_toArray(targets).forEach(function (target) {
|
||||
var tracker = _getByTarget(target);
|
||||
|
||||
if (tracker) {
|
||||
props ? props.forEach(function (p) {
|
||||
return tracker.remove(p);
|
||||
}) : tracker.kill(1);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
VelocityTracker.isTracking = function isTracking(target, property) {
|
||||
var tracker = _getByTarget(target);
|
||||
|
||||
return tracker && tracker.isTracking(property);
|
||||
};
|
||||
|
||||
VelocityTracker.getVelocity = function getVelocity(target, property) {
|
||||
var tracker = _getByTarget(target);
|
||||
|
||||
return !tracker || !tracker.isTracking(property) ? console.warn("Not tracking velocity of " + property) : tracker.get(property);
|
||||
};
|
||||
|
||||
return VelocityTracker;
|
||||
}();
|
||||
VelocityTracker.getByTarget = _getByTarget;
|
||||
_getGSAP() && gsap.registerPlugin(VelocityTracker);
|
||||
|
||||
/*!
|
||||
* InertiaPlugin 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 gsap$1,
|
||||
_coreInitted$1,
|
||||
_parseEase,
|
||||
_toArray$1,
|
||||
_power3,
|
||||
_config,
|
||||
_getUnit$1,
|
||||
PropTween,
|
||||
_getCache$1,
|
||||
_checkPointRatio,
|
||||
_clamp,
|
||||
_processingVars,
|
||||
_getStyleSaver,
|
||||
_reverting,
|
||||
_getTracker = VelocityTracker.getByTarget,
|
||||
_getGSAP$1 = function _getGSAP() {
|
||||
return gsap$1 || typeof window !== "undefined" && (gsap$1 = window.gsap) && gsap$1.registerPlugin && gsap$1;
|
||||
},
|
||||
_isString = function _isString(value) {
|
||||
return typeof value === "string";
|
||||
},
|
||||
_isNumber = function _isNumber(value) {
|
||||
return typeof value === "number";
|
||||
},
|
||||
_isObject = function _isObject(value) {
|
||||
return typeof value === "object";
|
||||
},
|
||||
_isFunction = function _isFunction(value) {
|
||||
return typeof value === "function";
|
||||
},
|
||||
_bonusValidated = 1,
|
||||
_isArray = Array.isArray,
|
||||
_emptyFunc = function _emptyFunc(p) {
|
||||
return p;
|
||||
},
|
||||
_bigNum = 1e10,
|
||||
_tinyNum = 1 / _bigNum,
|
||||
_checkPoint = 0.05,
|
||||
_round$1 = function _round(value) {
|
||||
return Math.round(value * 10000) / 10000;
|
||||
},
|
||||
_extend = function _extend(obj, defaults, exclude) {
|
||||
for (var p in defaults) {
|
||||
if (!(p in obj) && p !== exclude) {
|
||||
obj[p] = defaults[p];
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
},
|
||||
_deepClone = function _deepClone(obj) {
|
||||
var copy = {},
|
||||
p,
|
||||
v;
|
||||
|
||||
for (p in obj) {
|
||||
copy[p] = _isObject(v = obj[p]) && !_isArray(v) ? _deepClone(v) : v;
|
||||
}
|
||||
|
||||
return copy;
|
||||
},
|
||||
_getClosest = function _getClosest(n, values, max, min, radius) {
|
||||
var i = values.length,
|
||||
closest = 0,
|
||||
absDif = _bigNum,
|
||||
val,
|
||||
dif,
|
||||
p,
|
||||
dist;
|
||||
|
||||
if (_isObject(n)) {
|
||||
while (i--) {
|
||||
val = values[i];
|
||||
dif = 0;
|
||||
|
||||
for (p in n) {
|
||||
dist = val[p] - n[p];
|
||||
dif += dist * dist;
|
||||
}
|
||||
|
||||
if (dif < absDif) {
|
||||
closest = i;
|
||||
absDif = dif;
|
||||
}
|
||||
}
|
||||
|
||||
if ((radius || _bigNum) < _bigNum && radius < Math.sqrt(absDif)) {
|
||||
return n;
|
||||
}
|
||||
} else {
|
||||
while (i--) {
|
||||
val = values[i];
|
||||
dif = val - n;
|
||||
|
||||
if (dif < 0) {
|
||||
dif = -dif;
|
||||
}
|
||||
|
||||
if (dif < absDif && val >= min && val <= max) {
|
||||
closest = i;
|
||||
absDif = dif;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return values[closest];
|
||||
},
|
||||
_parseEnd = function _parseEnd(curProp, end, max, min, name, radius, velocity) {
|
||||
if (curProp.end === "auto") {
|
||||
return curProp;
|
||||
}
|
||||
|
||||
var endVar = curProp.end,
|
||||
adjustedEnd,
|
||||
p;
|
||||
max = isNaN(max) ? _bigNum : max;
|
||||
min = isNaN(min) ? -_bigNum : min;
|
||||
|
||||
if (_isObject(end)) {
|
||||
adjustedEnd = end.calculated ? end : (_isFunction(endVar) ? endVar(end, velocity) : _getClosest(end, endVar, max, min, radius)) || end;
|
||||
|
||||
if (!end.calculated) {
|
||||
for (p in adjustedEnd) {
|
||||
end[p] = adjustedEnd[p];
|
||||
}
|
||||
|
||||
end.calculated = true;
|
||||
}
|
||||
|
||||
adjustedEnd = adjustedEnd[name];
|
||||
} else {
|
||||
adjustedEnd = _isFunction(endVar) ? endVar(end, velocity) : _isArray(endVar) ? _getClosest(end, endVar, max, min, radius) : parseFloat(endVar);
|
||||
}
|
||||
|
||||
if (adjustedEnd > max) {
|
||||
adjustedEnd = max;
|
||||
} else if (adjustedEnd < min) {
|
||||
adjustedEnd = min;
|
||||
}
|
||||
|
||||
return {
|
||||
max: adjustedEnd,
|
||||
min: adjustedEnd,
|
||||
unitFactor: curProp.unitFactor
|
||||
};
|
||||
},
|
||||
_getNumOrDefault = function _getNumOrDefault(vars, property, defaultValue) {
|
||||
return isNaN(vars[property]) ? defaultValue : +vars[property];
|
||||
},
|
||||
_calculateChange = function _calculateChange(velocity, duration) {
|
||||
return duration * _checkPoint * velocity / _checkPointRatio;
|
||||
},
|
||||
_calculateDuration = function _calculateDuration(start, end, velocity) {
|
||||
return Math.abs((end - start) * _checkPointRatio / velocity / _checkPoint);
|
||||
},
|
||||
_reservedProps = {
|
||||
resistance: 1,
|
||||
checkpoint: 1,
|
||||
preventOvershoot: 1,
|
||||
linkedProps: 1,
|
||||
radius: 1,
|
||||
duration: 1
|
||||
},
|
||||
_processLinkedProps = function _processLinkedProps(target, vars, getVal, resistance) {
|
||||
if (vars.linkedProps) {
|
||||
var linkedPropNames = vars.linkedProps.split(","),
|
||||
linkedProps = {},
|
||||
i,
|
||||
p,
|
||||
curProp,
|
||||
curVelocity,
|
||||
tracker,
|
||||
curDuration;
|
||||
|
||||
for (i = 0; i < linkedPropNames.length; i++) {
|
||||
p = linkedPropNames[i];
|
||||
curProp = vars[p];
|
||||
|
||||
if (curProp) {
|
||||
if (_isNumber(curProp.velocity)) {
|
||||
curVelocity = curProp.velocity;
|
||||
} else {
|
||||
tracker = tracker || _getTracker(target);
|
||||
curVelocity = tracker && tracker.isTracking(p) ? tracker.get(p) : 0;
|
||||
}
|
||||
|
||||
curDuration = Math.abs(curVelocity / _getNumOrDefault(curProp, "resistance", resistance));
|
||||
linkedProps[p] = parseFloat(getVal(target, p)) + _calculateChange(curVelocity, curDuration);
|
||||
}
|
||||
}
|
||||
|
||||
return linkedProps;
|
||||
}
|
||||
},
|
||||
_calculateTweenDuration = function _calculateTweenDuration(target, vars, maxDuration, minDuration, overshootTolerance, recordEnd) {
|
||||
if (maxDuration === void 0) {
|
||||
maxDuration = 10;
|
||||
}
|
||||
|
||||
if (minDuration === void 0) {
|
||||
minDuration = 0.2;
|
||||
}
|
||||
|
||||
if (overshootTolerance === void 0) {
|
||||
overshootTolerance = 1;
|
||||
}
|
||||
|
||||
if (recordEnd === void 0) {
|
||||
recordEnd = 0;
|
||||
}
|
||||
|
||||
_isString(target) && (target = _toArray$1(target)[0]);
|
||||
|
||||
if (!target) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
var duration = 0,
|
||||
clippedDuration = _bigNum,
|
||||
inertiaVars = vars.inertia || vars,
|
||||
getVal = _getCache$1(target).get,
|
||||
resistance = _getNumOrDefault(inertiaVars, "resistance", _config.resistance),
|
||||
p,
|
||||
curProp,
|
||||
curDuration,
|
||||
curVelocity,
|
||||
curVal,
|
||||
end,
|
||||
curClippedDuration,
|
||||
tracker,
|
||||
unitFactor,
|
||||
linkedProps;
|
||||
|
||||
linkedProps = _processLinkedProps(target, inertiaVars, getVal, resistance);
|
||||
|
||||
for (p in inertiaVars) {
|
||||
if (!_reservedProps[p]) {
|
||||
curProp = inertiaVars[p];
|
||||
|
||||
if (!_isObject(curProp)) {
|
||||
tracker = tracker || _getTracker(target);
|
||||
|
||||
if (tracker && tracker.isTracking(p)) {
|
||||
curProp = _isNumber(curProp) ? {
|
||||
velocity: curProp
|
||||
} : {
|
||||
velocity: tracker.get(p)
|
||||
};
|
||||
} else {
|
||||
curVelocity = +curProp || 0;
|
||||
curDuration = Math.abs(curVelocity / resistance);
|
||||
}
|
||||
}
|
||||
|
||||
if (_isObject(curProp)) {
|
||||
if (_isNumber(curProp.velocity)) {
|
||||
curVelocity = curProp.velocity;
|
||||
} else {
|
||||
tracker = tracker || _getTracker(target);
|
||||
curVelocity = tracker && tracker.isTracking(p) ? tracker.get(p) : 0;
|
||||
}
|
||||
|
||||
curDuration = _clamp(minDuration, maxDuration, Math.abs(curVelocity / _getNumOrDefault(curProp, "resistance", resistance)));
|
||||
curVal = parseFloat(getVal(target, p)) || 0;
|
||||
end = curVal + _calculateChange(curVelocity, curDuration);
|
||||
|
||||
if ("end" in curProp) {
|
||||
curProp = _parseEnd(curProp, linkedProps && p in linkedProps ? linkedProps : end, curProp.max, curProp.min, p, inertiaVars.radius, curVelocity);
|
||||
|
||||
if (recordEnd) {
|
||||
_processingVars === vars && (_processingVars = inertiaVars = _deepClone(vars));
|
||||
inertiaVars[p] = _extend(curProp, inertiaVars[p], "end");
|
||||
}
|
||||
}
|
||||
|
||||
if ("max" in curProp && end > +curProp.max + _tinyNum) {
|
||||
unitFactor = curProp.unitFactor || _config.unitFactors[p] || 1;
|
||||
curClippedDuration = curVal > curProp.max && curProp.min !== curProp.max || curVelocity * unitFactor > -15 && curVelocity * unitFactor < 45 ? minDuration + (maxDuration - minDuration) * 0.1 : _calculateDuration(curVal, curProp.max, curVelocity);
|
||||
|
||||
if (curClippedDuration + overshootTolerance < clippedDuration) {
|
||||
clippedDuration = curClippedDuration + overshootTolerance;
|
||||
}
|
||||
} else if ("min" in curProp && end < +curProp.min - _tinyNum) {
|
||||
unitFactor = curProp.unitFactor || _config.unitFactors[p] || 1;
|
||||
curClippedDuration = curVal < curProp.min && curProp.min !== curProp.max || curVelocity * unitFactor > -45 && curVelocity * unitFactor < 15 ? minDuration + (maxDuration - minDuration) * 0.1 : _calculateDuration(curVal, curProp.min, curVelocity);
|
||||
|
||||
if (curClippedDuration + overshootTolerance < clippedDuration) {
|
||||
clippedDuration = curClippedDuration + overshootTolerance;
|
||||
}
|
||||
}
|
||||
|
||||
curClippedDuration > duration && (duration = curClippedDuration);
|
||||
}
|
||||
|
||||
curDuration > duration && (duration = curDuration);
|
||||
}
|
||||
}
|
||||
|
||||
duration > clippedDuration && (duration = clippedDuration);
|
||||
return duration > maxDuration ? maxDuration : duration < minDuration ? minDuration : duration;
|
||||
},
|
||||
_initCore$1 = function _initCore() {
|
||||
gsap$1 = _getGSAP$1();
|
||||
|
||||
if (gsap$1) {
|
||||
_parseEase = gsap$1.parseEase;
|
||||
_toArray$1 = gsap$1.utils.toArray;
|
||||
_getUnit$1 = gsap$1.utils.getUnit;
|
||||
_getCache$1 = gsap$1.core.getCache;
|
||||
_clamp = gsap$1.utils.clamp;
|
||||
_getStyleSaver = gsap$1.core.getStyleSaver;
|
||||
|
||||
_reverting = gsap$1.core.reverting || function () {};
|
||||
|
||||
_power3 = _parseEase("power3");
|
||||
_checkPointRatio = _power3(0.05);
|
||||
PropTween = gsap$1.core.PropTween;
|
||||
gsap$1.config({
|
||||
resistance: 100,
|
||||
unitFactors: {
|
||||
time: 1000,
|
||||
totalTime: 1000,
|
||||
progress: 1000,
|
||||
totalProgress: 1000
|
||||
}
|
||||
});
|
||||
_config = gsap$1.config();
|
||||
gsap$1.registerPlugin(VelocityTracker);
|
||||
_coreInitted$1 = 1;
|
||||
}
|
||||
};
|
||||
|
||||
var InertiaPlugin = {
|
||||
version: "3.14.2",
|
||||
name: "inertia",
|
||||
register: function register(core) {
|
||||
gsap$1 = core;
|
||||
|
||||
_initCore$1();
|
||||
},
|
||||
init: function init(target, vars, tween, index, targets) {
|
||||
_coreInitted$1 || _initCore$1();
|
||||
|
||||
var tracker = _getTracker(target);
|
||||
|
||||
if (vars === "auto") {
|
||||
if (!tracker) {
|
||||
console.warn("No inertia tracking on " + target + ". InertiaPlugin.track(target) first.");
|
||||
return;
|
||||
}
|
||||
|
||||
vars = tracker.getAll();
|
||||
}
|
||||
|
||||
this.styles = _getStyleSaver && typeof target.style === "object" && _getStyleSaver(target);
|
||||
this.target = target;
|
||||
this.tween = tween;
|
||||
_processingVars = vars;
|
||||
|
||||
var cache = target._gsap,
|
||||
getVal = cache.get,
|
||||
dur = vars.duration,
|
||||
durIsObj = _isObject(dur),
|
||||
preventOvershoot = vars.preventOvershoot || durIsObj && dur.overshoot === 0,
|
||||
resistance = _getNumOrDefault(vars, "resistance", _config.resistance),
|
||||
duration = _isNumber(dur) ? dur : _calculateTweenDuration(target, vars, durIsObj && dur.max || 10, durIsObj && dur.min || 0.2, durIsObj && "overshoot" in dur ? +dur.overshoot : preventOvershoot ? 0 : 1, true),
|
||||
p,
|
||||
curProp,
|
||||
curVal,
|
||||
unit,
|
||||
velocity,
|
||||
change1,
|
||||
end,
|
||||
change2,
|
||||
linkedProps;
|
||||
|
||||
vars = _processingVars;
|
||||
_processingVars = 0;
|
||||
linkedProps = _processLinkedProps(target, vars, getVal, resistance);
|
||||
|
||||
for (p in vars) {
|
||||
if (!_reservedProps[p]) {
|
||||
curProp = vars[p];
|
||||
_isFunction(curProp) && (curProp = curProp(index, target, targets));
|
||||
|
||||
if (_isNumber(curProp)) {
|
||||
velocity = curProp;
|
||||
} else if (_isObject(curProp) && !isNaN(curProp.velocity)) {
|
||||
velocity = +curProp.velocity;
|
||||
} else {
|
||||
if (tracker && tracker.isTracking(p)) {
|
||||
velocity = tracker.get(p);
|
||||
} else {
|
||||
console.warn("ERROR: No velocity was defined for " + target + " property: " + p);
|
||||
}
|
||||
}
|
||||
|
||||
change1 = _calculateChange(velocity, duration);
|
||||
change2 = 0;
|
||||
curVal = getVal(target, p);
|
||||
unit = _getUnit$1(curVal);
|
||||
curVal = parseFloat(curVal);
|
||||
|
||||
if (_isObject(curProp)) {
|
||||
end = curVal + change1;
|
||||
|
||||
if ("end" in curProp) {
|
||||
curProp = _parseEnd(curProp, linkedProps && p in linkedProps ? linkedProps : end, curProp.max, curProp.min, p, vars.radius, velocity);
|
||||
}
|
||||
|
||||
if ("max" in curProp && +curProp.max < end) {
|
||||
if (preventOvershoot || curProp.preventOvershoot) {
|
||||
change1 = curProp.max - curVal;
|
||||
} else {
|
||||
change2 = curProp.max - curVal - change1;
|
||||
}
|
||||
} else if ("min" in curProp && +curProp.min > end) {
|
||||
if (preventOvershoot || curProp.preventOvershoot) {
|
||||
change1 = curProp.min - curVal;
|
||||
} else {
|
||||
change2 = curProp.min - curVal - change1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this._props.push(p);
|
||||
|
||||
this.styles && this.styles.save(p);
|
||||
this._pt = new PropTween(this._pt, target, p, curVal, 0, _emptyFunc, 0, cache.set(target, p, this));
|
||||
this._pt.u = unit || 0;
|
||||
this._pt.c1 = change1;
|
||||
this._pt.c2 = change2;
|
||||
}
|
||||
}
|
||||
|
||||
tween.duration(duration);
|
||||
return _bonusValidated;
|
||||
},
|
||||
render: function render(ratio, data) {
|
||||
var pt = data._pt;
|
||||
ratio = _power3(data.tween._time / data.tween._dur);
|
||||
|
||||
if (ratio || !_reverting()) {
|
||||
while (pt) {
|
||||
pt.set(pt.t, pt.p, _round$1(pt.s + pt.c1 * ratio + pt.c2 * ratio * ratio) + pt.u, pt.d, ratio);
|
||||
pt = pt._next;
|
||||
}
|
||||
} else {
|
||||
data.styles.revert();
|
||||
}
|
||||
}
|
||||
};
|
||||
"track,untrack,isTracking,getVelocity,getByTarget".split(",").forEach(function (name) {
|
||||
return InertiaPlugin[name] = VelocityTracker[name];
|
||||
});
|
||||
_getGSAP$1() && gsap$1.registerPlugin(InertiaPlugin);
|
||||
|
||||
exports.InertiaPlugin = InertiaPlugin;
|
||||
exports.VelocityTracker = VelocityTracker;
|
||||
exports.default = InertiaPlugin;
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
})));
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
/*!
|
||||
* InertiaPlugin 3.14.2
|
||||
* https://gsap.com
|
||||
*
|
||||
* @license Copyright 2025, GreenSock. All rights reserved.
|
||||
* Subject to the terms at https://gsap.com/standard-license.
|
||||
* @author: Jack Doyle, jack@greensock.com
|
||||
*/
|
||||
|
||||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).window=t.window||{})}(this,function(e){"use strict";function m(){return i||"undefined"!=typeof window&&(i=window.gsap)}function p(t){return c(t).id}function q(t){return f[p("string"==typeof t?g(t)[0]:t)]}function r(t){var e,r=o;if(.05<=t-s)for(s=t;r;)((e=r.g(r.t,r.p))!==r.v1||.2<t-r.t1)&&(r.v2=r.v1,r.v1=e,r.t2=r.t1,r.t1=t),r=r._next}function t(){(i=m())&&(g=i.utils.toArray,n=i.utils.getUnit,c=i.core.getCache,a=i.ticker,l=1)}function u(t,e,r,i){this.t=t,this.p=e,this.g=t._gsap.get,this.rCap=v[r||n(this.g(t,e))],this.v1=this.v2=this.g(t,e),this.t1=this.t2=a.time,i&&((this._next=i)._prev=this)}var i,l,g,n,o,a,s,c,f={},v={deg:360,rad:2*Math.PI},d=function(){function VelocityTracker(e,r){l||t(),this.target=g(e)[0],(f[p(this.target)]=this)._props={},r&&this.add(r)}VelocityTracker.register=function register(e){i=e,t()};var e=VelocityTracker.prototype;return e.get=function get(t,e){var r,i,n=this._props[t]||console.warn("Not tracking "+t+" velocity.");return r=parseFloat(e?n.v1:n.g(n.t,n.p))-parseFloat(n.v2),(i=n.rCap)&&(r%=i)!==r%(i/2)&&(r=r<0?r+i:r-i),function _round(t){return Math.round(1e4*t)/1e4}(r/((e?n.t1:a.time)-n.t2))},e.getAll=function getAll(){var t,e={},r=this._props;for(t in r)e[t]=this.get(t);return e},e.isTracking=function isTracking(t){return t in this._props},e.add=function add(t,e){var i=this._props[t];i?(i.v1=i.v2=i.g(i.t,i.p),i.t1=i.t2=a.time):(o||(a.add(r),s=a.time),o=this._props[t]=new u(this.target,t,e,o))},e.remove=function remove(t){var e,i,n=this._props[t];n&&(e=n._prev,i=n._next,e&&(e._next=i),i?i._prev=e:o===n&&(a.remove(r),o=0),delete this._props[t])},e.kill=function kill(t){for(var e in this._props)this.remove(e);t||delete f[p(this.target)]},VelocityTracker.track=function track(e,r,i){l||t();for(var n,o,a=[],s=g(e),c=r.split(","),u=(i||"").split(","),f=s.length;f--;){for(n=q(s[f])||new VelocityTracker(s[f]),o=c.length;o--;)n.add(c[o],u[o]||u[0]);a.push(n)}return a},VelocityTracker.untrack=function untrack(t,e){var r=e&&e.split(",");g(t).forEach(function(t){var e=q(t);e&&(r?r.forEach(function(t){return e.remove(t)}):e.kill(1))})},VelocityTracker.isTracking=function isTracking(t,e){var r=q(t);return r&&r.isTracking(e)},VelocityTracker.getVelocity=function getVelocity(t,e){var r=q(t);return r&&r.isTracking(e)?r.get(e):console.warn("Not tracking velocity of "+e)},VelocityTracker}();d.getByTarget=q,m()&&i.registerPlugin(d);function L(){return h||"undefined"!=typeof window&&(h=window.gsap)&&h.registerPlugin&&h}function N(t){return"number"==typeof t}function O(t){return"object"==typeof t}function P(t){return"function"==typeof t}function S(t){return t}function W(t){return Math.round(1e4*t)/1e4}function X(t,e,r){for(var i in e)i in t||i===r||(t[i]=e[i]);return t}function Y(t){var e,r,i={};for(e in t)i[e]=O(r=t[e])&&!I(r)?Y(r):r;return i}function Z(t,e,r,i,n){var o,a,s,c,u=e.length,f=0,l=R;if(O(t)){for(;u--;){for(s in o=e[u],a=0,t)a+=(c=o[s]-t[s])*c;a<l&&(f=u,l=a)}if((n||R)<R&&n<Math.sqrt(l))return t}else for(;u--;)(a=(o=e[u])-t)<0&&(a=-a),a<l&&i<=o&&o<=r&&(f=u,l=a);return e[f]}function $(t,e,r,i,n,o,a){if("auto"===t.end)return t;var s,c,u=t.end;if(r=isNaN(r)?R:r,i=isNaN(i)?-R:i,O(e)){if(s=e.calculated?e:(P(u)?u(e,a):Z(e,u,r,i,o))||e,!e.calculated){for(c in s)e[c]=s[c];e.calculated=!0}s=s[n]}else s=P(u)?u(e,a):I(u)?Z(e,u,r,i,o):parseFloat(u);return r<s?s=r:s<i&&(s=i),{max:s,min:s,unitFactor:t.unitFactor}}function _(t,e,r){return isNaN(t[e])?r:+t[e]}function aa(t,e){return.05*e*t/T}function ba(t,e,r){return Math.abs((e-t)*T/r/.05)}function da(t,e,r,i){if(e.linkedProps){var n,o,a,s,c,u,f=e.linkedProps.split(","),l={};for(n=0;n<f.length;n++)(a=e[o=f[n]])&&(s=N(a.velocity)?a.velocity:(c=c||B(t))&&c.isTracking(o)?c.get(o):0,u=Math.abs(s/_(a,"resistance",i)),l[o]=parseFloat(r(t,o))+aa(s,u));return l}}function fa(){(h=L())&&(y=h.parseEase,F=h.utils.toArray,b=h.utils.getUnit,A=h.core.getCache,E=h.utils.clamp,C=h.core.getStyleSaver,w=h.core.reverting||function(){},k=y("power3"),T=k(.05),M=h.core.PropTween,h.config({resistance:100,unitFactors:{time:1e3,totalTime:1e3,progress:1e3,totalProgress:1e3}}),V=h.config(),h.registerPlugin(d),x=1)}var h,x,y,F,k,V,b,M,A,T,E,j,C,w,B=d.getByTarget,I=Array.isArray,R=1e10,U={resistance:1,checkpoint:1,preventOvershoot:1,linkedProps:1,radius:1,duration:1},D={version:"3.14.2",name:"inertia",register:function register(t){h=t,fa()},init:function init(t,e,r,i,n){x||fa();var o=B(t);if("auto"===e){if(!o)return void console.warn("No inertia tracking on "+t+". InertiaPlugin.track(target) first.");e=o.getAll()}this.styles=C&&"object"==typeof t.style&&C(t),this.target=t,this.tween=r,j=e;var a,s,c,u,f,l,p,g,v,d=t._gsap,h=d.get,y=e.duration,m=O(y),k=e.preventOvershoot||m&&0===y.overshoot,T=_(e,"resistance",V.resistance),w=N(y)?y:function _calculateTweenDuration(t,e,r,i,n,o){if(void 0===r&&(r=10),void 0===i&&(i=.2),void 0===n&&(n=1),vLine truncated
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"InertiaPlugin.min.js","sources":["../src/utils/VelocityTracker.js","../src/InertiaPlugin.js"],"sourcesContent":["/*!\n * VelocityTracker: 3.14.2\n * https://gsap.com\n *\n * Copyright 2008-2025, GreenSock. All rights reserved.\n * Subject to the terms at https://gsap.com/standard-license\n * @author: Jack Doyle, jack@greensock.com\n*/\n/* eslint-disable */\n\nlet gsap, _coreInitted, _toArray, _getUnit, _first, _ticker, _time1, _time2, _getCache,\n\t_getGSAP = () => gsap || typeof(window) !== \"undefined\" && (gsap = window.gsap),\n\t_lookup = {},\n\t_round = value => Math.round(value * 10000) / 10000,\n\t_getID = target => _getCache(target).id,\n\t_getByTarget = target => _lookup[_getID(typeof(target) === \"string\" ? _toArray(target)[0] : target)],\n\t_onTick = (time) => {\n\t\tlet pt = _first,\n\t\t\tval;\n\t\t//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\n\t\tif (time - _time1 >= 0.05) {\n\t\t\t_time2 = _time1;\n\t\t\t_time1 = time;\n\t\t\twhile (pt) {\n\t\t\t\tval = pt.g(pt.t, pt.p);\n\t\t\t\tif (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.\n\t\t\t\t\tpt.v2 = pt.v1;\n\t\t\t\t\tpt.v1 = val;\n\t\t\t\t\tpt.t2 = pt.t1;\n\t\t\t\t\tpt.t1 = time;\n\t\t\t\t}\n\t\t\t\tpt = pt._next;\n\t\t\t}\n\t\t}\n\t},\n\t_types = {deg: 360, rad: Math.PI * 2},\n\n\t_initCore = () => {\n\t\tgsap = _getGSAP();\n\t\tif (gsap) {\n\t\t\t_toArray = gsap.utils.toArray;\n\t\t\t_getUnit = gsap.utils.getUnit;\n\t\t\t_getCache = gsap.core.getCache;\n\t\t\t_ticker = gsap.ticker;\n\t\t\t_coreInitted = 1;\n\t\t}\n\t};\n\nclass PropTracker {\n\n\tconstructor(target, property, type, next) {\n\t\tthis.t = target;\n\t\tthis.p = property;\n\t\tthis.g = target._gsap.get;\n\t\tthis.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)\n\t\tthis.v1 = this.v2 = this.g(target, property);\n\t\tthis.t1 = this.t2 = _ticker.time;\n\t\tif (next) {\n\t\t\tthis._next = next;\n\t\t\tnext._prev = this;\n\t\t}\n\t}\n\n}\n\nexport class VelocityTracker {\n\n\tconstructor(target, property) {\n\t\t_coreInitted || _initCore();\n\t\tthis.target = _toArray(target)[0];\n\t\t_lookup[_getID(this.target)] = this;\n\t\tthis._props = {};\n\t\tproperty && this.add(property);\n\t}\n\n\tstatic register(core) {\n\t\tgsap = core;\n\t\t_initCore();\n\t}\n\n\tget(property, skipRecentTick) {\n\t\tlet pt = this._props[property] || console.warn(\"Not tracking \" + property + \" velocity.\"),\n\t\t\tval, dif, rotationCap;\n\t\tval = parseFloat(skipRecentTick ? pt.v1 : pt.g(pt.t, pt.p));\n\t\tdif = (val - parseFloat(pt.v2));\n\t\trotationCap = pt.rCap;\n\t\tif (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.\n\t\t\tdif = dif % rotationCap;\n\t\t\tif (dif !== dif % (rotationCap / 2)) {\n\t\t\t\tdif = (dif < 0) ? dif + rotationCap : dif - rotationCap;\n\t\t\t}\n\t\t}\n\t\treturn _round(dif / ((skipRecentTick ? pt.t1 : _ticker.time) - pt.t2));\n\t}\n\n\tgetAll() {\n\t\tlet result = {},\n\t\t\tprops = this._props,\n\t\t\tp;\n\t\tfor (p in props) {\n\t\t\tresult[p] = this.get(p);\n\t\t}\n\t\treturn result;\n\t}\n\n\tisTracking(property) {\n\t\treturn (property in this._props);\n\t}\n\n\tadd(property, type) {\n\t\tlet pt = this._props[property];\n\t\tif (pt) { // reset\n\t\t\tpt.v1 = pt.v2 = pt.g(pt.t, pt.p);\n\t\t\tpt.t1 = pt.t2 = _ticker.time;\n\t\t} else {\n\t\t\tif (!_first) {\n\t\t\t\t_ticker.add(_onTick);\n\t\t\t\t_time1 = _time2 = _ticker.time;\n\t\t\t}\n\t\t\t_first = this._props[property] = new PropTracker(this.target, property, type, _first);\n\t\t}\n\t}\n\n\tremove(property) {\n\t\tlet pt = this._props[property],\n\t\t\tprev, next;\n\t\tif (pt) {\n\t\t\tprev = pt._prev;\n\t\t\tnext = pt._next;\n\t\t\tif (prev) {\n\t\t\t\tprev._next = next;\n\t\t\t}\n\t\t\tif (next) {\n\t\t\t\tnext._prev = prev;\n\t\t\t} else if (_first === pt) {\n\t\t\t\t_ticker.remove(_onTick);\n\t\t\t\t_first = 0;\n\t\t\t}\n\t\t\tdelete this._props[property];\n\t\t}\n\t}\n\n\tkill(shallow) {\n\t\tfor (let p in this._props) {\n\t\t\tthis.remove(p);\n\t\t}\n\t\tif (!shallow) {\n\t\t\tdelete _lookup[_getID(this.target)];\n\t\t}\n\t}\n\n\tstatic track(targets, properties, types) {\n\t\t_coreInitted || _initCore();\n\t\tleLine truncated
|
||||
+1911
File diff suppressed because it is too large.
Load diff
+11
@@ -0,0 +1,11 @@
|
||||
/*!
|
||||
* MorphSVGPlugin 3.14.2
|
||||
* https://gsap.com
|
||||
*
|
||||
* @license Copyright 2025, GreenSock. All rights reserved.
|
||||
* Subject to the terms at https://gsap.com/standard-license.
|
||||
* @author: Jack Doyle, jack@greensock.com
|
||||
*/
|
||||
|
||||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).window=t.window||{})}(this,function(t){"use strict";function _extends(){return(_extends=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}function o(t){return"string"==typeof t}var y=/[achlmqstvz]|(-?\d*\.?\d*(?:e[\-+]?\d+)?)[0-9]/gi,N=/(?:(-)?\d*\.?\d*(?:e[\-+]?\d+)?)[0-9]/gi,b=/[\+\-]?\d*\.?\d+e[\+\-]?\d+/gi,r=/(^[#\.][a-z]|[a-y][a-z])/i,H=Math.PI/180,k=Math.sin,B=Math.cos,Q=Math.abs,J=Math.sqrt,z=Math.atan2,L=1e8,h=function _isNumber(t){return"number"==typeof t},A=function _round(t){return Math.round(1e5*t)/1e5||0},O=function _segmentIsClosed(t){return t.closed=Math.abs(t[0]-t[t.length-2])<.001&&Math.abs(t[1]-t[t.length-1])<.001},j=function _getSampleIndex(t,e,n){var r=t.length,a=~~(n*r);if(t[a]>e){for(;--a&&t[a]>e;);a<0&&(a=0)}else for(;t[++a]<e&&a<r;);return a<r?a:r-1};function reverseSegment(t){var e,n=0;for(t.reverse();n<t.length;n+=2)e=t[n],t[n]=t[n+1],t[n+1]=e;t.reversed=!t.reversed}var C={rect:"rx,ry,x,y,width,height",circle:"r,cx,cy",ellipse:"rx,ry,cx,cy",line:"x1,x2,y1,y2"};function convertToPath(t,e){var n,r,a,o,i,h,s,l,g,u,p,f,c,d,m,v,P,_,M,x,w,y,S=t.tagName.toLowerCase(),b=.552284749831;return"path"!==S&&t.getBBox?(h=function _createPath(t,e){var n,r=document.createElementNS("http://www.w3.org/2000/svg","path"),a=[].slice.call(t.attributes),o=a.length;for(e=","+e+",";-1<--o;)n=a[o].nodeName.toLowerCase(),e.indexOf(","+n+",")<0&&r.setAttributeNS(null,n,a[o].nodeValue);return r}(t,"x,y,width,height,cx,cy,rx,ry,r,x1,x2,y1,y2,points"),y=function _attrToObj(t,e){for(var n=e?e.split(","):[],r={},a=n.length;-1<--a;)r[n[a]]=+t.getAttribute(n[a])||0;return r}(t,C[S]),"rect"===S?(o=y.rx,i=y.ry||o,r=y.x,a=y.y,u=y.width-2*o,p=y.height-2*i,n=o||i?"M"+(v=(d=(c=r+o)+u)+o)+","+(_=a+i)+" V"+(M=_+p)+" C"+[v,x=M+i*b,m=d+o*b,w=M+i,d,w,d-(d-c)/3,w,c+(d-c)/3,w,c,w,f=r+o*(1-b),w,r,x,r,M,r,M-(M-_)/3,r,_+(M-_)/3,r,_,r,P=a+i*(1-b),f,a,c,a,c+(d-c)/3,a,d-(d-c)/3,a,d,a,m,a,v,P,v,_].join(",")+"z":"M"+(r+u)+","+a+" v"+p+" h"+-u+" v"+-p+" h"+u+"z"):"circle"===S||"ellipse"===S?(l="circle"===S?(o=i=y.r)*b:(o=y.rx,(i=y.ry)*b),n="M"+((r=y.cx)+o)+","+(a=y.cy)+" C"+[r+o,a+l,r+(s=o*b),a+i,r,a+i,r-s,a+i,r-o,a+l,r-o,a,r-o,a-l,r-s,a-i,r,a-i,r+s,a-i,r+o,a-l,r+o,a].join(",")+"z"):"line"===S?n="M"+y.x1+","+y.y1+" L"+y.x2+","+y.y2:"polyline"!==S&&"polygon"!==S||(n="M"+(r=(g=(t.getAttribute("points")+"").match(N)||[]).shift())+","+(a=g.shift())+" L"+g.join(","),"polygon"===S&&(n+=","+r+","+a+"z")),h.setAttribute("d",rawPathToString(h._gsRawPath=stringToRawPath(n))),e&&t.parentNode&&(t.parentNode.insertBefore(h,t),t.parentNode.removeChild(t)),h):t}function measureSegment(t,e,n){e=e||0,t.samples||(t.samples=[],t.lookup=[]);var r,a,o,i,h,s,l,g,u,p,f,c,d,m,v,P,_,M=~~t.resolution||12,x=1/M,w=n?e+6*n+1:t.length,y=t[e],S=t[e+1],b=e?e/6*M:0,T=t.samples,R=t.lookup,N=(e?t.minLength:L)||L,z=T[b+n*M-1],A=e?T[b-1]:0;for(T.length=R.length=0,a=e+2;a<w;a+=6){if(o=t[a+4]-y,i=t[a+2]-y,h=t[a]-y,g=t[a+5]-S,u=t[a+3]-S,p=t[a+1]-S,s=l=f=c=0,Q(o)<.01&&Q(g)<.01&&Q(h)+Q(p)<.01)8<t.length&&(t.splice(a,6),a-=6,w-=6);else for(r=1;r<=M;r++)s=l-(l=((m=x*r)*m*o+3*(d=1-m)*(m*i+d*h))*m),f=c-(c=(m*m*g+3*d*(m*u+d*p))*m),(P=J(f*f+s*s))<N&&(N=P),A+=P,T[b++]=A;y+=o,S+=g}if(z)for(z-=A;b<T.length;b++)T[b]+=z;if(T.length&&N){if(t.totalLength=_=T[T.length-1]||0,_/(t.minLength=N)<9999)for(P=v=0,r=0;r<_;r+=N)R[P++]=T[v]<r?++v:v}else t.totalLength=T[0]=0;return e?A-T[e/2-1]:A}function cacheRawPathMeasurements(t,e){var n,r,a;for(a=n=r=0;a<t.length;a++)t[a].resolution=~~e||12,n+=measureSegment(t[a]),r+=t[a].length;return t.totalPoints=r,t.totalLength=n,t}function arcToSegment(t,e,n,r,a,o,i,h,s){if(t!==h||e!==s){n=Q(n),r=Q(r);var l=a%360*H,g=B(l),u=k(l),p=Math.PI,f=2*p,c=(t-h)/2,d=(e-s)/2,m=g*c+u*d,v=-u*c+g*d,P=m*m,_=v*v,M=P/(n*n)+_/(r*r);1<M&&(n=J(M)*n,r=J(M)*r);var x=n*n,w=r*r,y=(x*w-x*_-w*P)/(x*_+w*P);y<0&&(y=0);var S=(o===i?-1:1)*J(y),b=n*v/r*S,T=-r*m/n*S,R=g*b-u*T+(t+h)/2,N=u*b+g*T+(e+s)/2,z=(m-b)/n,A=(v-T)/r,L=(-m-b)/n,O=(-v-T)/r,j=z*z+A*A,V=(A<0?-1:1)*Math.acos(z/J(j)),C=(z*O-A*L<0?-1:1)*Math.acos((z*L+A*O)/J(j*(L*L+O*O)));isNaN(C)&&(C=p),!i&&0<C?C-=f:i&&C<0&&(C+=f),V%=f,C%=f;var I,Y=Math.ceil(Q(C)/(f/4)),U=[],F=C/Y,X=4/3*k(F/2)/(1+B(F/2)),q=g*n,D=u*n,G=u*-r,E=g*r;for(I=0;I<Y;I++)m=B(a=V+I*F),v=k(a),z=B(a+=F),A=k(a),U.push(m-X*v,v+X*m,z+X*A,A-X*z,z,A);for(I=0;I<U.length;I+=2)m=U[I],v=U[I+1],U[I]=m*q+v*G+R,U[I+1]=m*D+v*E+N;return U[I-2]=h,U[I-1]=s,U}}function stringToRawPath(t){function xd(t,e,n,r){g=(n-t)/3,u=(r-e)/3,h.push(t+g,e+u,n-g,r-u,n,r)}var e,n,r,a,o,i,h,s,l,g,u,p,f,c,d,m=(t+"").replace(b,function(t){var e=+t;return e<1e-4&&-1e-4<e?0:e}).match(y)||[],v=[],P=0,_=0,M=m.length,x=0,w="ERROR: malformed path: "+t;if(!t||!isNaN(m[0])||isNaN(m[1]))return console.log(w),v;for(e=0;e<M;e++)if(f=o,isLine truncated
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"MorphSVGPlugin.min.js","sources":["../src/utils/paths.js","../src/MorphSVGPlugin.js"],"sourcesContent":["/*!\n * paths 3.14.2\n * https://gsap.com\n *\n * Copyright 2008-2025, GreenSock. All rights reserved.\n * Subject to the terms at https://gsap.com/standard-license\n * @author: Jack Doyle, jack@greensock.com\n*/\n/* eslint-disable */\n\nlet _svgPathExp = /[achlmqstvz]|(-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?)[0-9]/ig,\n\t_numbersExp = /(?:(-)?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?)[0-9]/ig,\n\t_scientific = /[\\+\\-]?\\d*\\.?\\d+e[\\+\\-]?\\d+/ig,\n\t_selectorExp = /(^[#\\.][a-z]|[a-y][a-z])/i,\n\t_DEG2RAD = Math.PI / 180,\n\t_RAD2DEG = 180 / Math.PI,\n\t_sin = Math.sin,\n\t_cos = Math.cos,\n\t_abs = Math.abs,\n\t_sqrt = Math.sqrt,\n\t_atan2 = Math.atan2,\n\t_largeNum = 1e8,\n\t_isString = value => typeof(value) === \"string\",\n\t_isNumber = value => typeof(value) === \"number\",\n\t_isUndefined = value => typeof(value) === \"undefined\",\n\t_temp = {},\n\t_temp2 = {},\n\t_roundingNum = 1e5,\n\t_wrapProgress = progress => (Math.round((progress + _largeNum) % 1 * _roundingNum) / _roundingNum) || ((progress < 0) ? 0 : 1), //if progress lands on 1, the % will make it 0 which is why we || 1, but not if it's negative because it makes more sense for motion to end at 0 in that case.\n\t_round = value => (Math.round(value * _roundingNum) / _roundingNum) || 0,\n\t_roundPrecise = value => (Math.round(value * 1e10) / 1e10) || 0,\n\t_segmentIsClosed = segment => (segment.closed = Math.abs(segment[0] - segment[segment.length-2]) < 0.001 && Math.abs(segment[1] - segment[segment.length-1]) < 0.001),\n\t_splitSegment = (rawPath, segIndex, i, t) => {\n\t\tlet segment = rawPath[segIndex],\n\t\t\tshift = t === 1 ? 6 : subdivideSegment(segment, i, t);\n\t\tif ((shift || !t) && shift + i + 2 < segment.length) {\n\t\t\trawPath.splice(segIndex, 0, segment.slice(0, i + shift + 2));\n\t\t\tsegment.splice(0, i + shift);\n\t\t\treturn 1;\n\t\t}\n\t},\n\t_getSampleIndex = (samples, length, progress) => {\n\t\t// slightly slower way than doing this (when there's no lookup): segment.lookup[progress < 1 ? ~~(length / segment.minLength) : segment.lookup.length - 1] || 0;\n\t\tlet l = samples.length,\n\t\t\ti = ~~(progress * l);\n\t\tif (samples[i] > length) {\n\t\t\twhile (--i && samples[i] > length) {}\n\t\t\ti < 0 && (i = 0);\n\t\t} else {\n\t\t\twhile (samples[++i] < length && i < l) {}\n\t\t}\n\t\treturn i < l ? i : l - 1;\n\t},\n\t_reverseRawPath = (rawPath, skipOuter) => {\n\t\tlet i = rawPath.length;\n\t\tskipOuter || rawPath.reverse();\n\t\twhile (i--) {\n\t\t\trawPath[i].reversed || reverseSegment(rawPath[i]);\n\t\t}\n\t},\n\t_copyMetaData = (source, copy) => {\n\t\tcopy.totalLength = source.totalLength;\n\t\tif (source.samples) { //segment\n\t\t\tcopy.samples = source.samples.slice(0);\n\t\t\tcopy.lookup = source.lookup.slice(0);\n\t\t\tcopy.minLength = source.minLength;\n\t\t\tcopy.resolution = source.resolution;\n\t\t} else if (source.totalPoints) { //rawPath\n\t\t\tcopy.totalPoints = source.totalPoints;\n\t\t}\n\t\treturn copy;\n\t},\n\t//pushes a new segment into a rawPath, but if its starting values match the ending values of the last segment, it'll merge it into that same segment (to reduce the number of segments)\n\t_appendOrMerge = (rawPath, segment) => {\n\t\tlet index = rawPath.length,\n\t\t\tprevSeg = rawPath[index - 1] || [],\n\t\t\tl = prevSeg.length;\n\t\tif (index && segment[0] === prevSeg[l-2] && segment[1] === prevSeg[l-1]) {\n\t\t\tsegment = prevSeg.concat(segment.slice(2));\n\t\t\tindex--;\n\t\t}\n\t\trawPath[index] = segment;\n\t},\n\t_bestDistance;\n\n/* TERMINOLOGY\n - RawPath - an array of arrays, one for each Segment. A single RawPath could have multiple \"M\" commands, defining Segments (paths aren't always connected).\n - Segment - an array containing a sequence of Cubic Bezier coordinates in alternating x, y, x, y format. Starting anchor, then control point 1, control point 2, and ending anchor, then the next control point 1, control point 2, anchor, etc. Uses less memory than an array with a bunch of {x, y} points.\n - Bezier - a single cubic Bezier with a starting anchor, two control points, and an ending anchor.\n - the variable \"t\" is typically the position along an individual Bezier path (time) and it's NOT linear, meaning it could accelerate/decelerate based on the control points whereas the \"p\" or \"progress\" value is linearly mapped to the whole path, so it shouldn't really accelerate/decelerate based on control points. So a progress of 0.2 would be almost exactly 20% along the path. \"t\" is ONLY in an individual Bezier piece.\n */\n\n//accepts basic selector text, a path instance, a RawPath instance, or a Segment and returns a RawPath (makes it easy to homogenize things). If an element or selector text is passed in, it'll also cache the value so that if it's queried again, it'll just take the path data from there instead of parsing it all over again (as long as the path data itLine truncated
|
||||
+3195
File diff suppressed because it is too large.
Load diff
+11
@@ -0,0 +1,11 @@
|
||||
/*!
|
||||
* MotionPathHelper 3.14.2
|
||||
* https://gsap.com
|
||||
*
|
||||
* @license Copyright 2025, GreenSock. All rights reserved.
|
||||
* Subject to the terms at https://gsap.com/standard-license.
|
||||
* @author: Jack Doyle, jack@greensock.com
|
||||
*/
|
||||
|
||||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).window=t.window||{})}(this,function(t){"use strict";function n(t){return Math.round(1e5*t)/1e5||0}function o(t){return t.closed=Math.abs(t[0]-t[t.length-2])<.001&&Math.abs(t[1]-t[t.length-1])<.001}function p(t,e){return e.totalLength=t.totalLength,t.samples?(e.samples=t.samples.slice(0),e.lookup=t.lookup.slice(0),e.minLength=t.minLength,e.resolution=t.resolution):t.totalPoints&&(e.totalPoints=t.totalPoints),e}var P,w=/[achlmqstvz]|(-?\d*\.?\d*(?:e[\-+]?\d+)?)[0-9]/gi,S=/[\+\-]?\d*\.?\d+e[\+\-]?\d+/gi,B=Math.PI/180,F=Math.sin,W=Math.cos,U=Math.abs,Z=Math.sqrt,A=1e8;function copyRawPath(t){for(var e=[],n=0;n<t.length;n++)e[n]=p(t[n],t[n].slice(0));return p(t,e)}function transformRawPath(t,e,n,i,s,a,o){for(var r,h,l,c,d,u=t.length;-1<--u;)for(h=(r=t[u]).length,l=0;l<h;l+=2)c=r[l],d=r[l+1],r[l]=c*e+d*i+a,r[l+1]=c*n+d*s+o;return t._dirty=1,t}function arcToSegment(t,e,n,i,s,a,o,r,h){if(t!==r||e!==h){n=U(n),i=U(i);var l=s%360*B,c=W(l),d=F(l),u=Math.PI,p=2*u,g=(t-r)/2,f=(e-h)/2,_=c*g+d*f,m=-d*g+c*f,v=_*_,b=m*m,y=v/(n*n)+b/(i*i);1<y&&(n=Z(y)*n,i=Z(y)*i);var P=n*n,A=i*i,C=(P*A-P*b-A*v)/(P*b+A*v);C<0&&(C=0);var w=(a===o?-1:1)*Z(C),S=n*m/i*w,x=-i*_/n*w,D=c*S-d*x+(t+r)/2,k=d*S+c*x+(e+h)/2,E=(_-S)/n,M=(m-x)/i,T=(-_-S)/n,H=(-m-x)/i,R=E*E+M*M,N=(M<0?-1:1)*Math.acos(E/Z(R)),I=(E*H-M*T<0?-1:1)*Math.acos((E*T+M*H)/Z(R*(T*T+H*H)));isNaN(I)&&(I=u),!o&&0<I?I-=p:o&&I<0&&(I+=p),N%=p,I%=p;var O,L=Math.ceil(U(I)/(p/4)),X=[],q=I/L,G=4/3*F(q/2)/(1+W(q/2)),j=c*n,z=d*n,V=d*-i,Y=c*i;for(O=0;O<L;O++)_=W(s=N+O*q),m=F(s),E=W(s+=q),M=F(s),X.push(_-G*m,m+G*_,E+G*M,M-G*E,E,M);for(O=0;O<X.length;O+=2)_=X[O],m=X[O+1],X[O]=_*j+m*V+D,X[O+1]=_*z+m*Y+k;return X[O-2]=r,X[O-1]=h,X}}function stringToRawPath(t){function ud(t,e,n,i){d=(n-t)/3,u=(i-e)/3,h.push(t+d,e+u,n-d,i-u,n,i)}var e,n,i,s,a,r,h,l,c,d,u,p,g,f,_,m=(t+"").replace(S,function(t){var e=+t;return e<1e-4&&-1e-4<e?0:e}).match(w)||[],v=[],b=0,y=0,P=m.length,A=0,C="ERROR: malformed path: "+t;if(!t||!isNaN(m[0])||isNaN(m[1]))return console.log(C),v;for(e=0;e<P;e++)if(g=a,isNaN(m[e])?r=(a=m[e].toUpperCase())!==m[e]:e--,i=+m[e+1],s=+m[e+2],r&&(i+=b,s+=y),e||(l=i,c=s),"M"===a)h&&(h.length<8?--v.length:A+=h.length,o(h)),b=l=i,y=c=s,h=[i,s],v.push(h),e+=2,a="L";else if("C"===a)r||(b=y=0),(h=h||[0,0]).push(i,s,b+1*m[e+3],y+1*m[e+4],b+=1*m[e+5],y+=1*m[e+6]),e+=6;else if("S"===a)d=b,u=y,"C"!==g&&"S"!==g||(d+=b-h[h.length-4],u+=y-h[h.length-3]),r||(b=y=0),h.push(d,u,i,s,b+=1*m[e+3],y+=1*m[e+4]),e+=4;else if("Q"===a)d=b+2/3*(i-b),u=y+2/3*(s-y),r||(b=y=0),b+=1*m[e+3],y+=1*m[e+4],h.push(d,u,b+2/3*(i-b),y+2/3*(s-y),b,y),e+=4;else if("T"===a)d=b-h[h.length-4],u=y-h[h.length-3],h.push(b+d,y+u,i+2/3*(b+1.5*d-i),s+2/3*(y+1.5*u-s),b=i,y=s),e+=2;else if("H"===a)ud(b,y,b=i,y),e+=1;else if("V"===a)ud(b,y,b,y=i+(r?y-b:0)),e+=1;else if("L"===a||"Z"===a)"Z"===a&&(i=l,s=c,h.closed=!0),("L"===a||.5<U(b-i)||.5<U(y-s))&&(ud(b,y,i,s),"L"===a&&(e+=2)),b=i,y=s;else if("A"===a){if(f=m[e+4],_=m[e+5],d=m[e+6],u=m[e+7],n=7,1<f.length&&(f.length<3?(u=d,d=_,n--):(u=_,d=f.substr(2),n-=2),_=f.charAt(1),f=f.charAt(0)),p=arcToSegment(b,y,+m[e+1],+m[e+2],+m[e+3],+f,+_,(r?b:0)+1*d,(r?y:0)+1*u),e+=n,p)for(n=0;n<p.length;n++)h.push(p[n]);b=h[h.length-2],y=h[h.length-1]}else console.log(C);return(e=h.length)<6?(v.pop(),e=0):o(h),v.totalPoints=A+e,v}function bezierToPoints(t,e,n,i,s,a,o,r,h,l,c){var d,u=(t+n)/2,p=(e+i)/2,g=(n+s)/2,f=(i+a)/2,_=(s+o)/2,m=(a+r)/2,v=(u+g)/2,b=(p+f)/2,y=(g+_)/2,P=(f+m)/2,A=(v+y)/2,C=(b+P)/2,w=o-t,S=r-e,x=U((n-o)*S-(i-r)*w),D=U((s-o)*S-(a-r)*w);return l||(l=[t,e,o,r],c=2),l.splice(c||l.length-2,0,A,C),h*(w*w+S*S)<(x+D)*(x+D)&&(d=l.length,bezierToPoints(t,e,u,p,v,b,A,C,h,l,c),bezierToPoints(A,C,y,P,_,m,o,r,h,l,c+2+(l.length-d))),l}function pointsToSegment(t,e){U(t[0]-t[2])<1e-4&&U(t[1]-t[3])<1e-4&&(t=t.slice(2));var i,s,a,o,r,h,l,c,d,u,p,g,f,_,m=t.length-2,v=+t[0],b=+t[1],y=+t[2],P=+t[3],A=[v,b,v,b],C=y-v,w=P-b,S=t.nonSmooth||[],x=Math.abs(t[m]-v)<.001&&Math.abs(t[m+1]-b)<.001;if(!m)return[v,b,v,b,v,b,v,b];for(x&&(t.push(y,P),y=v,P=b,v=t[m-2],b=t[m-1],t.unshift(v,b),m+=4,S=[0,0].concat(S)),e=e||0===e?+e:1,a=2;a<m;a+=2)i=v,s=b,v=y,b=P,y=+t[a+2],P=+t[a+3],v===y&&b===P||(o=C,r=w,C=y-v,w=P-b,S[a]?A.push(v-(v-i)/4,b-(b-s)/4,v,b,v+(y-v)/4,b+(P-b)/4):(c=((h=Z(o*o+r*r))+(l=Z(C*C+w*w)))*e*.25/Z(Math.pow(C/l+o/h,2)+Math.pow(w/l+r/h,2)),p=v-((d=v-(v-i)*(h?c/h:0))+(((u=v+(y-v)*(l?c/l:0))-d)*(3*h/(h+l)+.5)/4||0)),_=b-((g=b-(b-s)*(h?c/h:0))+(((f=b+(P-b)*(l?c/l:0))-g)*(3*h/(h+l)+.5)/4||0)),A.push(n(d+p),n(g+_),n(v),n(b),n(u+p),n(f+_))));return v!==y||b!==P||A.length<4?A.push(n(y),n(P),n(y),n(P)):A.length-=2,2===A.length?A.push(v,b,v,b,v,b):x&&(A.splice(0,6),A.length-=6),A.closed=x,A}function simplifyPoints(t,e){var n,i,s,a,o,r,h,l=parseFloat(t[0]),c=parseFloat(t[1]),d=[l,c],u=t.length-2;for(e=Math.pow(e||1,2),n=2;n<u;n+=2)e<(a=l-(i=parseFloat(t[n])))*a+(o=c-(s=parseFloat(t[n+1]))Line truncated
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"MotionPathHelper.min.js","sources":["../src/utils/paths.js","../src/utils/matrix.js","../src/utils/PathEditor.js","../src/MotionPathHelper.js"],"sourcesContent":["/*!\n * paths 3.14.2\n * https://gsap.com\n *\n * Copyright 2008-2025, GreenSock. All rights reserved.\n * Subject to the terms at https://gsap.com/standard-license\n * @author: Jack Doyle, jack@greensock.com\n*/\n/* eslint-disable */\n\nlet _svgPathExp = /[achlmqstvz]|(-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?)[0-9]/ig,\n\t_numbersExp = /(?:(-)?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?)[0-9]/ig,\n\t_scientific = /[\\+\\-]?\\d*\\.?\\d+e[\\+\\-]?\\d+/ig,\n\t_selectorExp = /(^[#\\.][a-z]|[a-y][a-z])/i,\n\t_DEG2RAD = Math.PI / 180,\n\t_RAD2DEG = 180 / Math.PI,\n\t_sin = Math.sin,\n\t_cos = Math.cos,\n\t_abs = Math.abs,\n\t_sqrt = Math.sqrt,\n\t_atan2 = Math.atan2,\n\t_largeNum = 1e8,\n\t_isString = value => typeof(value) === \"string\",\n\t_isNumber = value => typeof(value) === \"number\",\n\t_isUndefined = value => typeof(value) === \"undefined\",\n\t_temp = {},\n\t_temp2 = {},\n\t_roundingNum = 1e5,\n\t_wrapProgress = progress => (Math.round((progress + _largeNum) % 1 * _roundingNum) / _roundingNum) || ((progress < 0) ? 0 : 1), //if progress lands on 1, the % will make it 0 which is why we || 1, but not if it's negative because it makes more sense for motion to end at 0 in that case.\n\t_round = value => (Math.round(value * _roundingNum) / _roundingNum) || 0,\n\t_roundPrecise = value => (Math.round(value * 1e10) / 1e10) || 0,\n\t_segmentIsClosed = segment => (segment.closed = Math.abs(segment[0] - segment[segment.length-2]) < 0.001 && Math.abs(segment[1] - segment[segment.length-1]) < 0.001),\n\t_splitSegment = (rawPath, segIndex, i, t) => {\n\t\tlet segment = rawPath[segIndex],\n\t\t\tshift = t === 1 ? 6 : subdivideSegment(segment, i, t);\n\t\tif ((shift || !t) && shift + i + 2 < segment.length) {\n\t\t\trawPath.splice(segIndex, 0, segment.slice(0, i + shift + 2));\n\t\t\tsegment.splice(0, i + shift);\n\t\t\treturn 1;\n\t\t}\n\t},\n\t_getSampleIndex = (samples, length, progress) => {\n\t\t// slightly slower way than doing this (when there's no lookup): segment.lookup[progress < 1 ? ~~(length / segment.minLength) : segment.lookup.length - 1] || 0;\n\t\tlet l = samples.length,\n\t\t\ti = ~~(progress * l);\n\t\tif (samples[i] > length) {\n\t\t\twhile (--i && samples[i] > length) {}\n\t\t\ti < 0 && (i = 0);\n\t\t} else {\n\t\t\twhile (samples[++i] < length && i < l) {}\n\t\t}\n\t\treturn i < l ? i : l - 1;\n\t},\n\t_reverseRawPath = (rawPath, skipOuter) => {\n\t\tlet i = rawPath.length;\n\t\tskipOuter || rawPath.reverse();\n\t\twhile (i--) {\n\t\t\trawPath[i].reversed || reverseSegment(rawPath[i]);\n\t\t}\n\t},\n\t_copyMetaData = (source, copy) => {\n\t\tcopy.totalLength = source.totalLength;\n\t\tif (source.samples) { //segment\n\t\t\tcopy.samples = source.samples.slice(0);\n\t\t\tcopy.lookup = source.lookup.slice(0);\n\t\t\tcopy.minLength = source.minLength;\n\t\t\tcopy.resolution = source.resolution;\n\t\t} else if (source.totalPoints) { //rawPath\n\t\t\tcopy.totalPoints = source.totalPoints;\n\t\t}\n\t\treturn copy;\n\t},\n\t//pushes a new segment into a rawPath, but if its starting values match the ending values of the last segment, it'll merge it into that same segment (to reduce the number of segments)\n\t_appendOrMerge = (rawPath, segment) => {\n\t\tlet index = rawPath.length,\n\t\t\tprevSeg = rawPath[index - 1] || [],\n\t\t\tl = prevSeg.length;\n\t\tif (index && segment[0] === prevSeg[l-2] && segment[1] === prevSeg[l-1]) {\n\t\t\tsegment = prevSeg.concat(segment.slice(2));\n\t\t\tindex--;\n\t\t}\n\t\trawPath[index] = segment;\n\t},\n\t_bestDistance;\n\n/* TERMINOLOGY\n - RawPath - an array of arrays, one for each Segment. A single RawPath could have multiple \"M\" commands, defining Segments (paths aren't always connected).\n - Segment - an array containing a sequence of Cubic Bezier coordinates in alternating x, y, x, y format. Starting anchor, then control point 1, control point 2, and ending anchor, then the next control point 1, control point 2, anchor, etc. Uses less memory than an array with a bunch of {x, y} points.\n - Bezier - a single cubic Bezier with a starting anchor, two control points, and an ending anchor.\n - the variable \"t\" is typically the position along an individual Bezier path (time) and it's NOT linear, meaning it could accelerate/decelerate based on the control points whereas the \"p\" or \"progress\" value is linearly mapped to the whole path, so it shouldn't really accelerate/decelerate based on control points. So a progress of 0.2 would be almost exactly 20% along the path. \"t\" is ONLY in an individual Bezier piece.\n */\n\n//accepts basic selector text, a path instance, a RawPath instance, or a Segment and returns a RawPath (makes it easy to homogenize things). If an element or selector text is passed in, it'll also cache the value so that if it's queried again, it'll just take the path data from there insteadLine truncated
|
||||
+1837
File diff suppressed because it is too large.
Load diff
+11
@@ -0,0 +1,11 @@
|
||||
/*!
|
||||
* MotionPathPlugin 3.14.2
|
||||
* https://gsap.com
|
||||
*
|
||||
* @license Copyright 2025, GreenSock. All rights reserved.
|
||||
* Subject to the terms at https://gsap.com/standard-license.
|
||||
* @author: Jack Doyle, jack@greensock.com
|
||||
*/
|
||||
|
||||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).window=t.window||{})}(this,function(t){"use strict";function p(t){return"string"==typeof t}function x(t){return Math.round(1e10*t)/1e10||0}function z(t,e,n,r){var a=t[e],o=1===r?6:subdivideSegment(a,n,r);if((o||!r)&&o+n+2<a.length)return t.splice(e,0,a.slice(0,n+o+2)),a.splice(0,n+o),1}function D(t,e){var n=t.length,r=t[n-1]||[],a=r.length;n&&e[0]===r[a-2]&&e[1]===r[a-1]&&(e=r.concat(e.slice(2)),n--),t[n]=e}var M=/[achlmqstvz]|(-?\d*\.?\d*(?:e[\-+]?\d+)?)[0-9]/gi,T=/(?:(-)?\d*\.?\d*(?:e[\-+]?\d+)?)[0-9]/gi,R=/[\+\-]?\d*\.?\d+e[\+\-]?\d+/gi,r=/(^[#\.][a-z]|[a-y][a-z])/i,V=Math.PI/180,s=180/Math.PI,F=Math.sin,Z=Math.cos,U=Math.abs,H=Math.sqrt,l=Math.atan2,A=1e8,h=function _isNumber(t){return"number"==typeof t},C={},_={},e=1e5,d=function _wrapProgress(t){return Math.round((t+A)%1*e)/e||(t<0?0:1)},N=function _round(t){return Math.round(t*e)/e||0},L=function _segmentIsClosed(t){return t.closed=Math.abs(t[0]-t[t.length-2])<.001&&Math.abs(t[1]-t[t.length-1])<.001},m=function _getSampleIndex(t,e,n){var r=t.length,a=~~(n*r);if(t[a]>e){for(;--a&&t[a]>e;);a<0&&(a=0)}else for(;t[++a]<e&&a<r;);return a<r?a:r-1},O=function _copyMetaData(t,e){return e.totalLength=t.totalLength,t.samples?(e.samples=t.samples.slice(0),e.lookup=t.lookup.slice(0),e.minLength=t.minLength,e.resolution=t.resolution):t.totalPoints&&(e.totalPoints=t.totalPoints),e};function getRawPath(t){var e,n=(t=p(t)&&r.test(t)&&document.querySelector(t)||t).getAttribute?t:0;return n&&(t=t.getAttribute("d"))?(n._gsPath||(n._gsPath={}),(e=n._gsPath[t])&&!e._dirty?e:n._gsPath[t]=stringToRawPath(t)):t?p(t)?stringToRawPath(t):h(t[0])?[t]:t:console.warn("Expecting a <path> element or an SVG path data string")}function reverseSegment(t){var e,n=0;for(t.reverse();n<t.length;n+=2)e=t[n],t[n]=t[n+1],t[n+1]=e;t.reversed=!t.reversed}var B={rect:"rx,ry,x,y,width,height",circle:"r,cx,cy",ellipse:"rx,ry,cx,cy",line:"x1,x2,y1,y2"};function convertToPath(t,e){var n,r,a,o,i,s,l,h,u,g,f,c,p,d,m,v,w,y,x,P,b,M,R=t.tagName.toLowerCase(),L=.552284749831;return"path"!==R&&t.getBBox?(s=function _createPath(t,e){var n,r=document.createElementNS("http://www.w3.org/2000/svg","path"),a=[].slice.call(t.attributes),o=a.length;for(e=","+e+",";-1<--o;)n=a[o].nodeName.toLowerCase(),e.indexOf(","+n+",")<0&&r.setAttributeNS(null,n,a[o].nodeValue);return r}(t,"x,y,width,height,cx,cy,rx,ry,r,x1,x2,y1,y2,points"),M=function _attrToObj(t,e){for(var n=e?e.split(","):[],r={},a=n.length;-1<--a;)r[n[a]]=+t.getAttribute(n[a])||0;return r}(t,B[R]),"rect"===R?(o=M.rx,i=M.ry||o,r=M.x,a=M.y,g=M.width-2*o,f=M.height-2*i,n=o||i?"M"+(v=(d=(p=r+o)+g)+o)+","+(y=a+i)+" V"+(x=y+f)+" C"+[v,P=x+i*L,m=d+o*L,b=x+i,d,b,d-(d-p)/3,b,p+(d-p)/3,b,p,b,c=r+o*(1-L),b,r,P,r,x,r,x-(x-y)/3,r,y+(x-y)/3,r,y,r,w=a+i*(1-L),c,a,p,a,p+(d-p)/3,a,d-(d-p)/3,a,d,a,m,a,v,w,v,y].join(",")+"z":"M"+(r+g)+","+a+" v"+f+" h"+-g+" v"+-f+" h"+g+"z"):"circle"===R||"ellipse"===R?(h="circle"===R?(o=i=M.r)*L:(o=M.rx,(i=M.ry)*L),n="M"+((r=M.cx)+o)+","+(a=M.cy)+" C"+[r+o,a+h,r+(l=o*L),a+i,r,a+i,r-l,a+i,r-o,a+h,r-o,a,r-o,a-h,r-l,a-i,r,a-i,r+l,a-i,r+o,a-h,r+o,a].join(",")+"z"):"line"===R?n="M"+M.x1+","+M.y1+" L"+M.x2+","+M.y2:"polyline"!==R&&"polygon"!==R||(n="M"+(r=(u=(t.getAttribute("points")+"").match(T)||[]).shift())+","+(a=u.shift())+" L"+u.join(","),"polygon"===R&&(n+=","+r+","+a+"z")),s.setAttribute("d",rawPathToString(s._gsRawPath=stringToRawPath(n))),e&&t.parentNode&&(t.parentNode.insertBefore(s,t),t.parentNode.removeChild(t)),s):t}function getRotationAtBezierT(t,e,n){var r,a=t[e],o=t[e+2],i=t[e+4];return a+=(o-a)*n,a+=((o+=(i-o)*n)-a)*n,r=o+(i+(t[e+6]-i)*n-o)*n-a,a=t[e+1],a+=((o=t[e+3])-a)*n,a+=((o+=((i=t[e+5])-o)*n)-a)*n,N(l(o+(i+(t[e+7]-i)*n-o)*n-a,r)*s)}function sliceRawPath(t,e,n){n=function _isUndefined(t){return void 0===t}(n)?1:x(n)||0,e=x(e)||0;var r=Math.max(0,~~(U(n-e)-1e-8)),a=function copyRawPath(t){for(var e=[],n=0;n<t.length;n++)e[n]=O(t[n],t[n].slice(0));return O(t,e)}(t);if(n<e&&(e=1-e,n=1-n,function _reverseRawPath(t,e){var n=t.length;for(e||t.reverse();n--;)t[n].reversed||reverseSegment(t[n])}(a),a.totalLength=0),e<0||n<0){var o=Math.abs(~~Math.min(e,n))+1;e+=o,n+=o}a.totalLength||cacheRawPathMeasurements(a);var i,s,l,h,u,g,f,c,p=1<n,d=getProgressData(a,e,C,!0),m=getProgressData(a,n,_),v=m.segment,w=d.segment,y=m.segIndex,P=d.segIndex,b=m.i,M=d.i,R=P===y,L=b===M&&R;if(p||r){for(i=y<P||R&&b<M||L&&m.t<d.t,z(a,P,M,d.t)&&(P++,i||(y++,L?(m.t=(m.t-d.t)/(1-d.t),b=0):R&&(b-=M))),Math.abs(1-(n-e))<1e-5?y=P-1:!m.t&&y?y--:z(a,y,b,m.t)&&i&&P++,1===d.t&&(P=(P+1)%a.length),u=[],f=1+(g=a.length)*r,f+=(g-(c=P)+y)%g,h=0;h<f;h++)D(u,a[c++%g]);a=u}else if(l=1===m.t?6:subdivideSegment(v,b,m.t),e!==n)for(s=subdivideSegment(w,M,L?d.t/m.t:d.t),R&&(l+=s),v.splice(b+l+2),(s||M)&&w.splice(0,M+s),h=a.length;h--;)(h<P||y<h)&&a.splice(h,1);else v.angle=getRotationAtBezierT(v,b+l,0),d=v[b+=l],m=v[b+1],v.lenLine truncated
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"MotionPathPlugin.min.js","sources":["../src/utils/paths.js","../src/utils/matrix.js","../src/MotionPathPlugin.js"],"sourcesContent":["/*!\n * paths 3.14.2\n * https://gsap.com\n *\n * Copyright 2008-2025, GreenSock. All rights reserved.\n * Subject to the terms at https://gsap.com/standard-license\n * @author: Jack Doyle, jack@greensock.com\n*/\n/* eslint-disable */\n\nlet _svgPathExp = /[achlmqstvz]|(-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?)[0-9]/ig,\n\t_numbersExp = /(?:(-)?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?)[0-9]/ig,\n\t_scientific = /[\\+\\-]?\\d*\\.?\\d+e[\\+\\-]?\\d+/ig,\n\t_selectorExp = /(^[#\\.][a-z]|[a-y][a-z])/i,\n\t_DEG2RAD = Math.PI / 180,\n\t_RAD2DEG = 180 / Math.PI,\n\t_sin = Math.sin,\n\t_cos = Math.cos,\n\t_abs = Math.abs,\n\t_sqrt = Math.sqrt,\n\t_atan2 = Math.atan2,\n\t_largeNum = 1e8,\n\t_isString = value => typeof(value) === \"string\",\n\t_isNumber = value => typeof(value) === \"number\",\n\t_isUndefined = value => typeof(value) === \"undefined\",\n\t_temp = {},\n\t_temp2 = {},\n\t_roundingNum = 1e5,\n\t_wrapProgress = progress => (Math.round((progress + _largeNum) % 1 * _roundingNum) / _roundingNum) || ((progress < 0) ? 0 : 1), //if progress lands on 1, the % will make it 0 which is why we || 1, but not if it's negative because it makes more sense for motion to end at 0 in that case.\n\t_round = value => (Math.round(value * _roundingNum) / _roundingNum) || 0,\n\t_roundPrecise = value => (Math.round(value * 1e10) / 1e10) || 0,\n\t_segmentIsClosed = segment => (segment.closed = Math.abs(segment[0] - segment[segment.length-2]) < 0.001 && Math.abs(segment[1] - segment[segment.length-1]) < 0.001),\n\t_splitSegment = (rawPath, segIndex, i, t) => {\n\t\tlet segment = rawPath[segIndex],\n\t\t\tshift = t === 1 ? 6 : subdivideSegment(segment, i, t);\n\t\tif ((shift || !t) && shift + i + 2 < segment.length) {\n\t\t\trawPath.splice(segIndex, 0, segment.slice(0, i + shift + 2));\n\t\t\tsegment.splice(0, i + shift);\n\t\t\treturn 1;\n\t\t}\n\t},\n\t_getSampleIndex = (samples, length, progress) => {\n\t\t// slightly slower way than doing this (when there's no lookup): segment.lookup[progress < 1 ? ~~(length / segment.minLength) : segment.lookup.length - 1] || 0;\n\t\tlet l = samples.length,\n\t\t\ti = ~~(progress * l);\n\t\tif (samples[i] > length) {\n\t\t\twhile (--i && samples[i] > length) {}\n\t\t\ti < 0 && (i = 0);\n\t\t} else {\n\t\t\twhile (samples[++i] < length && i < l) {}\n\t\t}\n\t\treturn i < l ? i : l - 1;\n\t},\n\t_reverseRawPath = (rawPath, skipOuter) => {\n\t\tlet i = rawPath.length;\n\t\tskipOuter || rawPath.reverse();\n\t\twhile (i--) {\n\t\t\trawPath[i].reversed || reverseSegment(rawPath[i]);\n\t\t}\n\t},\n\t_copyMetaData = (source, copy) => {\n\t\tcopy.totalLength = source.totalLength;\n\t\tif (source.samples) { //segment\n\t\t\tcopy.samples = source.samples.slice(0);\n\t\t\tcopy.lookup = source.lookup.slice(0);\n\t\t\tcopy.minLength = source.minLength;\n\t\t\tcopy.resolution = source.resolution;\n\t\t} else if (source.totalPoints) { //rawPath\n\t\t\tcopy.totalPoints = source.totalPoints;\n\t\t}\n\t\treturn copy;\n\t},\n\t//pushes a new segment into a rawPath, but if its starting values match the ending values of the last segment, it'll merge it into that same segment (to reduce the number of segments)\n\t_appendOrMerge = (rawPath, segment) => {\n\t\tlet index = rawPath.length,\n\t\t\tprevSeg = rawPath[index - 1] || [],\n\t\t\tl = prevSeg.length;\n\t\tif (index && segment[0] === prevSeg[l-2] && segment[1] === prevSeg[l-1]) {\n\t\t\tsegment = prevSeg.concat(segment.slice(2));\n\t\t\tindex--;\n\t\t}\n\t\trawPath[index] = segment;\n\t},\n\t_bestDistance;\n\n/* TERMINOLOGY\n - RawPath - an array of arrays, one for each Segment. A single RawPath could have multiple \"M\" commands, defining Segments (paths aren't always connected).\n - Segment - an array containing a sequence of Cubic Bezier coordinates in alternating x, y, x, y format. Starting anchor, then control point 1, control point 2, and ending anchor, then the next control point 1, control point 2, anchor, etc. Uses less memory than an array with a bunch of {x, y} points.\n - Bezier - a single cubic Bezier with a starting anchor, two control points, and an ending anchor.\n - the variable \"t\" is typically the position along an individual Bezier path (time) and it's NOT linear, meaning it could accelerate/decelerate based on the control points whereas the \"p\" or \"progress\" value is linearly mapped to the whole path, so it shouldn't really accelerate/decelerate based on control points. So a progress of 0.2 would be almost exactly 20% along the path. \"t\" is ONLY in an individual Bezier piece.\n */\n\n//accepts basic selector text, a path instance, a RawPath instance, or a Segment and returns a RawPath (makes it easy to homogenize things). If an element or selector text is passed in, it'll also cache the value so that if it's queried again, it'll just take the path data from there instead of parsing it all over againLine truncated
|
||||
+716
@@ -0,0 +1,716 @@
|
||||
(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';
|
||||
|
||||
function _defineProperties(target, props) {
|
||||
for (var i = 0; i < props.length; i++) {
|
||||
var descriptor = props[i];
|
||||
descriptor.enumerable = descriptor.enumerable || false;
|
||||
descriptor.configurable = true;
|
||||
if ("value" in descriptor) descriptor.writable = true;
|
||||
Object.defineProperty(target, descriptor.key, descriptor);
|
||||
}
|
||||
}
|
||||
|
||||
function _createClass(Constructor, protoProps, staticProps) {
|
||||
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
||||
if (staticProps) _defineProperties(Constructor, staticProps);
|
||||
return Constructor;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Observer 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 gsap,
|
||||
_coreInitted,
|
||||
_clamp,
|
||||
_win,
|
||||
_doc,
|
||||
_docEl,
|
||||
_body,
|
||||
_isTouch,
|
||||
_pointerType,
|
||||
ScrollTrigger,
|
||||
_root,
|
||||
_normalizer,
|
||||
_eventTypes,
|
||||
_context,
|
||||
_getGSAP = function _getGSAP() {
|
||||
return gsap || typeof window !== "undefined" && (gsap = window.gsap) && gsap.registerPlugin && gsap;
|
||||
},
|
||||
_startup = 1,
|
||||
_observers = [];
|
||||
exports._scrollers = [];
|
||||
exports._proxies = [];
|
||||
var _getTime = Date.now,
|
||||
_bridge = function _bridge(name, value) {
|
||||
return value;
|
||||
},
|
||||
_integrate = function _integrate() {
|
||||
var core = ScrollTrigger.core,
|
||||
data = core.bridge || {},
|
||||
scrollers = core._scrollers,
|
||||
proxies = core._proxies;
|
||||
scrollers.push.apply(scrollers, exports._scrollers);
|
||||
proxies.push.apply(proxies, exports._proxies);
|
||||
exports._scrollers = scrollers;
|
||||
exports._proxies = proxies;
|
||||
|
||||
_bridge = function _bridge(name, value) {
|
||||
return data[name](value);
|
||||
};
|
||||
},
|
||||
_getProxyProp = function _getProxyProp(element, property) {
|
||||
return ~exports._proxies.indexOf(element) && exports._proxies[exports._proxies.indexOf(element) + 1][property];
|
||||
},
|
||||
_isViewport = function _isViewport(el) {
|
||||
return !!~_root.indexOf(el);
|
||||
},
|
||||
_addListener = function _addListener(element, type, func, passive, capture) {
|
||||
return element.addEventListener(type, func, {
|
||||
passive: passive !== false,
|
||||
capture: !!capture
|
||||
});
|
||||
},
|
||||
_removeListener = function _removeListener(element, type, func, capture) {
|
||||
return element.removeEventListener(type, func, !!capture);
|
||||
},
|
||||
_scrollLeft = "scrollLeft",
|
||||
_scrollTop = "scrollTop",
|
||||
_onScroll = function _onScroll() {
|
||||
return _normalizer && _normalizer.isPressed || exports._scrollers.cache++;
|
||||
},
|
||||
_scrollCacheFunc = function _scrollCacheFunc(f, doNotCache) {
|
||||
var cachingFunc = function cachingFunc(value) {
|
||||
if (value || value === 0) {
|
||||
_startup && (_win.history.scrollRestoration = "manual");
|
||||
var isNormalizing = _normalizer && _normalizer.isPressed;
|
||||
value = cachingFunc.v = Math.round(value) || (_normalizer && _normalizer.iOS ? 1 : 0);
|
||||
f(value);
|
||||
cachingFunc.cacheID = exports._scrollers.cache;
|
||||
isNormalizing && _bridge("ss", value);
|
||||
} else if (doNotCache || exports._scrollers.cache !== cachingFunc.cacheID || _bridge("ref")) {
|
||||
cachingFunc.cacheID = exports._scrollers.cache;
|
||||
cachingFunc.v = f();
|
||||
}
|
||||
|
||||
return cachingFunc.v + cachingFunc.offset;
|
||||
};
|
||||
|
||||
cachingFunc.offset = 0;
|
||||
return f && cachingFunc;
|
||||
},
|
||||
_horizontal = {
|
||||
s: _scrollLeft,
|
||||
p: "left",
|
||||
p2: "Left",
|
||||
os: "right",
|
||||
os2: "Right",
|
||||
d: "width",
|
||||
d2: "Width",
|
||||
a: "x",
|
||||
sc: _scrollCacheFunc(function (value) {
|
||||
return arguments.length ? _win.scrollTo(value, _vertical.sc()) : _win.pageXOffset || _doc[_scrollLeft] || _docEl[_scrollLeft] || _body[_scrollLeft] || 0;
|
||||
})
|
||||
},
|
||||
_vertical = {
|
||||
s: _scrollTop,
|
||||
p: "top",
|
||||
p2: "Top",
|
||||
os: "bottom",
|
||||
os2: "Bottom",
|
||||
d: "height",
|
||||
d2: "Height",
|
||||
a: "y",
|
||||
op: _horizontal,
|
||||
sc: _scrollCacheFunc(function (value) {
|
||||
return arguments.length ? _win.scrollTo(_horizontal.sc(), value) : _win.pageYOffset || _doc[_scrollTop] || _docEl[_scrollTop] || _body[_scrollTop] || 0;
|
||||
})
|
||||
},
|
||||
_getTarget = function _getTarget(t, self) {
|
||||
return (self && self._ctx && self._ctx.selector || gsap.utils.toArray)(t)[0] || (typeof t === "string" && gsap.config().nullTargetWarn !== false ? console.warn("Element not found:", t) : null);
|
||||
},
|
||||
_isWithin = function _isWithin(element, list) {
|
||||
var i = list.length;
|
||||
|
||||
while (i--) {
|
||||
if (list[i] === element || list[i].contains(element)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
_getScrollFunc = function _getScrollFunc(element, _ref) {
|
||||
var s = _ref.s,
|
||||
sc = _ref.sc;
|
||||
_isViewport(element) && (element = _doc.scrollingElement || _docEl);
|
||||
|
||||
var i = exports._scrollers.indexOf(element),
|
||||
offset = sc === _vertical.sc ? 1 : 2;
|
||||
|
||||
!~i && (i = exports._scrollers.push(element) - 1);
|
||||
exports._scrollers[i + offset] || _addListener(element, "scroll", _onScroll);
|
||||
var prev = exports._scrollers[i + offset],
|
||||
func = prev || (exports._scrollers[i + offset] = _scrollCacheFunc(_getProxyProp(element, s), true) || (_isViewport(element) ? sc : _scrollCacheFunc(function (value) {
|
||||
return arguments.length ? element[s] = value : element[s];
|
||||
})));
|
||||
func.target = element;
|
||||
prev || (func.smooth = gsap.getProperty(element, "scrollBehavior") === "smooth");
|
||||
return func;
|
||||
},
|
||||
_getVelocityProp = function _getVelocityProp(value, minTimeRefresh, useDelta) {
|
||||
var v1 = value,
|
||||
v2 = value,
|
||||
t1 = _getTime(),
|
||||
t2 = t1,
|
||||
min = minTimeRefresh || 50,
|
||||
dropToZeroTime = Math.max(500, min * 3),
|
||||
update = function update(value, force) {
|
||||
var t = _getTime();
|
||||
|
||||
if (force || t - t1 > min) {
|
||||
v2 = v1;
|
||||
v1 = value;
|
||||
t2 = t1;
|
||||
t1 = t;
|
||||
} else if (useDelta) {
|
||||
v1 += value;
|
||||
} else {
|
||||
v1 = v2 + (value - v2) / (t - t2) * (t1 - t2);
|
||||
}
|
||||
},
|
||||
reset = function reset() {
|
||||
v2 = v1 = useDelta ? 0 : v1;
|
||||
t2 = t1 = 0;
|
||||
},
|
||||
getVelocity = function getVelocity(latestValue) {
|
||||
var tOld = t2,
|
||||
vOld = v2,
|
||||
t = _getTime();
|
||||
|
||||
(latestValue || latestValue === 0) && latestValue !== v1 && update(latestValue);
|
||||
return t1 === t2 || t - t2 > dropToZeroTime ? 0 : (v1 + (useDelta ? vOld : -vOld)) / ((useDelta ? t : t1) - tOld) * 1000;
|
||||
};
|
||||
|
||||
return {
|
||||
update: update,
|
||||
reset: reset,
|
||||
getVelocity: getVelocity
|
||||
};
|
||||
},
|
||||
_getEvent = function _getEvent(e, preventDefault) {
|
||||
preventDefault && !e._gsapAllow && e.preventDefault();
|
||||
return e.changedTouches ? e.changedTouches[0] : e;
|
||||
},
|
||||
_getAbsoluteMax = function _getAbsoluteMax(a) {
|
||||
var max = Math.max.apply(Math, a),
|
||||
min = Math.min.apply(Math, a);
|
||||
return Math.abs(max) >= Math.abs(min) ? max : min;
|
||||
},
|
||||
_setScrollTrigger = function _setScrollTrigger() {
|
||||
ScrollTrigger = gsap.core.globals().ScrollTrigger;
|
||||
ScrollTrigger && ScrollTrigger.core && _integrate();
|
||||
},
|
||||
_initCore = function _initCore(core) {
|
||||
gsap = core || _getGSAP();
|
||||
|
||||
if (!_coreInitted && gsap && typeof document !== "undefined" && document.body) {
|
||||
_win = window;
|
||||
_doc = document;
|
||||
_docEl = _doc.documentElement;
|
||||
_body = _doc.body;
|
||||
_root = [_win, _doc, _docEl, _body];
|
||||
_clamp = gsap.utils.clamp;
|
||||
|
||||
_context = gsap.core.context || function () {};
|
||||
|
||||
_pointerType = "onpointerenter" in _body ? "pointer" : "mouse";
|
||||
_isTouch = Observer.isTouch = _win.matchMedia && _win.matchMedia("(hover: none), (pointer: coarse)").matches ? 1 : "ontouchstart" in _win || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0 ? 2 : 0;
|
||||
_eventTypes = Observer.eventTypes = ("ontouchstart" in _docEl ? "touchstart,touchmove,touchcancel,touchend" : !("onpointerdown" in _docEl) ? "mousedown,mousemove,mouseup,mouseup" : "pointerdown,pointermove,pointercancel,pointerup").split(",");
|
||||
setTimeout(function () {
|
||||
return _startup = 0;
|
||||
}, 500);
|
||||
|
||||
_setScrollTrigger();
|
||||
|
||||
_coreInitted = 1;
|
||||
}
|
||||
|
||||
return _coreInitted;
|
||||
};
|
||||
|
||||
_horizontal.op = _vertical;
|
||||
exports._scrollers.cache = 0;
|
||||
var Observer = function () {
|
||||
function Observer(vars) {
|
||||
this.init(vars);
|
||||
}
|
||||
|
||||
var _proto = Observer.prototype;
|
||||
|
||||
_proto.init = function init(vars) {
|
||||
_coreInitted || _initCore(gsap) || console.warn("Please gsap.registerPlugin(Observer)");
|
||||
ScrollTrigger || _setScrollTrigger();
|
||||
var tolerance = vars.tolerance,
|
||||
dragMinimum = vars.dragMinimum,
|
||||
type = vars.type,
|
||||
target = vars.target,
|
||||
lineHeight = vars.lineHeight,
|
||||
debounce = vars.debounce,
|
||||
preventDefault = vars.preventDefault,
|
||||
onStop = vars.onStop,
|
||||
onStopDelay = vars.onStopDelay,
|
||||
ignore = vars.ignore,
|
||||
wheelSpeed = vars.wheelSpeed,
|
||||
event = vars.event,
|
||||
onDragStart = vars.onDragStart,
|
||||
onDragEnd = vars.onDragEnd,
|
||||
onDrag = vars.onDrag,
|
||||
onPress = vars.onPress,
|
||||
onRelease = vars.onRelease,
|
||||
onRight = vars.onRight,
|
||||
onLeft = vars.onLeft,
|
||||
onUp = vars.onUp,
|
||||
onDown = vars.onDown,
|
||||
onChangeX = vars.onChangeX,
|
||||
onChangeY = vars.onChangeY,
|
||||
onChange = vars.onChange,
|
||||
onToggleX = vars.onToggleX,
|
||||
onToggleY = vars.onToggleY,
|
||||
onHover = vars.onHover,
|
||||
onHoverEnd = vars.onHoverEnd,
|
||||
onMove = vars.onMove,
|
||||
ignoreCheck = vars.ignoreCheck,
|
||||
isNormalizer = vars.isNormalizer,
|
||||
onGestureStart = vars.onGestureStart,
|
||||
onGestureEnd = vars.onGestureEnd,
|
||||
onWheel = vars.onWheel,
|
||||
onEnable = vars.onEnable,
|
||||
onDisable = vars.onDisable,
|
||||
onClick = vars.onClick,
|
||||
scrollSpeed = vars.scrollSpeed,
|
||||
capture = vars.capture,
|
||||
allowClicks = vars.allowClicks,
|
||||
lockAxis = vars.lockAxis,
|
||||
onLockAxis = vars.onLockAxis;
|
||||
this.target = target = _getTarget(target) || _docEl;
|
||||
this.vars = vars;
|
||||
ignore && (ignore = gsap.utils.toArray(ignore));
|
||||
tolerance = tolerance || 1e-9;
|
||||
dragMinimum = dragMinimum || 0;
|
||||
wheelSpeed = wheelSpeed || 1;
|
||||
scrollSpeed = scrollSpeed || 1;
|
||||
type = type || "wheel,touch,pointer";
|
||||
debounce = debounce !== false;
|
||||
lineHeight || (lineHeight = parseFloat(_win.getComputedStyle(_body).lineHeight) || 22);
|
||||
|
||||
var id,
|
||||
onStopDelayedCall,
|
||||
dragged,
|
||||
moved,
|
||||
wheeled,
|
||||
locked,
|
||||
axis,
|
||||
self = this,
|
||||
prevDeltaX = 0,
|
||||
prevDeltaY = 0,
|
||||
passive = vars.passive || !preventDefault && vars.passive !== false,
|
||||
scrollFuncX = _getScrollFunc(target, _horizontal),
|
||||
scrollFuncY = _getScrollFunc(target, _vertical),
|
||||
scrollX = scrollFuncX(),
|
||||
scrollY = scrollFuncY(),
|
||||
limitToTouch = ~type.indexOf("touch") && !~type.indexOf("pointer") && _eventTypes[0] === "pointerdown",
|
||||
isViewport = _isViewport(target),
|
||||
ownerDoc = target.ownerDocument || _doc,
|
||||
deltaX = [0, 0, 0],
|
||||
deltaY = [0, 0, 0],
|
||||
onClickTime = 0,
|
||||
clickCapture = function clickCapture() {
|
||||
return onClickTime = _getTime();
|
||||
},
|
||||
_ignoreCheck = function _ignoreCheck(e, isPointerOrTouch) {
|
||||
return (self.event = e) && ignore && _isWithin(e.target, ignore) || isPointerOrTouch && limitToTouch && e.pointerType !== "touch" || ignoreCheck && ignoreCheck(e, isPointerOrTouch);
|
||||
},
|
||||
onStopFunc = function onStopFunc() {
|
||||
self._vx.reset();
|
||||
|
||||
self._vy.reset();
|
||||
|
||||
onStopDelayedCall.pause();
|
||||
onStop && onStop(self);
|
||||
},
|
||||
update = function update() {
|
||||
var dx = self.deltaX = _getAbsoluteMax(deltaX),
|
||||
dy = self.deltaY = _getAbsoluteMax(deltaY),
|
||||
changedX = Math.abs(dx) >= tolerance,
|
||||
changedY = Math.abs(dy) >= tolerance;
|
||||
|
||||
onChange && (changedX || changedY) && onChange(self, dx, dy, deltaX, deltaY);
|
||||
|
||||
if (changedX) {
|
||||
onRight && self.deltaX > 0 && onRight(self);
|
||||
onLeft && self.deltaX < 0 && onLeft(self);
|
||||
onChangeX && onChangeX(self);
|
||||
onToggleX && self.deltaX < 0 !== prevDeltaX < 0 && onToggleX(self);
|
||||
prevDeltaX = self.deltaX;
|
||||
deltaX[0] = deltaX[1] = deltaX[2] = 0;
|
||||
}
|
||||
|
||||
if (changedY) {
|
||||
onDown && self.deltaY > 0 && onDown(self);
|
||||
onUp && self.deltaY < 0 && onUp(self);
|
||||
onChangeY && onChangeY(self);
|
||||
onToggleY && self.deltaY < 0 !== prevDeltaY < 0 && onToggleY(self);
|
||||
prevDeltaY = self.deltaY;
|
||||
deltaY[0] = deltaY[1] = deltaY[2] = 0;
|
||||
}
|
||||
|
||||
if (moved || dragged) {
|
||||
onMove && onMove(self);
|
||||
|
||||
if (dragged) {
|
||||
onDragStart && dragged === 1 && onDragStart(self);
|
||||
onDrag && onDrag(self);
|
||||
dragged = 0;
|
||||
}
|
||||
|
||||
moved = false;
|
||||
}
|
||||
|
||||
locked && !(locked = false) && onLockAxis && onLockAxis(self);
|
||||
|
||||
if (wheeled) {
|
||||
onWheel(self);
|
||||
wheeled = false;
|
||||
}
|
||||
|
||||
id = 0;
|
||||
},
|
||||
onDelta = function onDelta(x, y, index) {
|
||||
deltaX[index] += x;
|
||||
deltaY[index] += y;
|
||||
|
||||
self._vx.update(x);
|
||||
|
||||
self._vy.update(y);
|
||||
|
||||
debounce ? id || (id = requestAnimationFrame(update)) : update();
|
||||
},
|
||||
onTouchOrPointerDelta = function onTouchOrPointerDelta(x, y) {
|
||||
if (lockAxis && !axis) {
|
||||
self.axis = axis = Math.abs(x) > Math.abs(y) ? "x" : "y";
|
||||
locked = true;
|
||||
}
|
||||
|
||||
if (axis !== "y") {
|
||||
deltaX[2] += x;
|
||||
|
||||
self._vx.update(x, true);
|
||||
}
|
||||
|
||||
if (axis !== "x") {
|
||||
deltaY[2] += y;
|
||||
|
||||
self._vy.update(y, true);
|
||||
}
|
||||
|
||||
debounce ? id || (id = requestAnimationFrame(update)) : update();
|
||||
},
|
||||
_onDrag = function _onDrag(e) {
|
||||
if (_ignoreCheck(e, 1)) {
|
||||
return;
|
||||
}
|
||||
|
||||
e = _getEvent(e, preventDefault);
|
||||
var x = e.clientX,
|
||||
y = e.clientY,
|
||||
dx = x - self.x,
|
||||
dy = y - self.y,
|
||||
isDragging = self.isDragging;
|
||||
self.x = x;
|
||||
self.y = y;
|
||||
|
||||
if (isDragging || (dx || dy) && (Math.abs(self.startX - x) >= dragMinimum || Math.abs(self.startY - y) >= dragMinimum)) {
|
||||
dragged || (dragged = isDragging ? 2 : 1);
|
||||
isDragging || (self.isDragging = true);
|
||||
onTouchOrPointerDelta(dx, dy);
|
||||
}
|
||||
},
|
||||
_onPress = self.onPress = function (e) {
|
||||
if (_ignoreCheck(e, 1) || e && e.button) {
|
||||
return;
|
||||
}
|
||||
|
||||
self.axis = axis = null;
|
||||
onStopDelayedCall.pause();
|
||||
self.isPressed = true;
|
||||
e = _getEvent(e);
|
||||
prevDeltaX = prevDeltaY = 0;
|
||||
self.startX = self.x = e.clientX;
|
||||
self.startY = self.y = e.clientY;
|
||||
|
||||
self._vx.reset();
|
||||
|
||||
self._vy.reset();
|
||||
|
||||
_addListener(isNormalizer ? target : ownerDoc, _eventTypes[1], _onDrag, passive, true);
|
||||
|
||||
self.deltaX = self.deltaY = 0;
|
||||
onPress && onPress(self);
|
||||
},
|
||||
_onRelease = self.onRelease = function (e) {
|
||||
if (_ignoreCheck(e, 1)) {
|
||||
return;
|
||||
}
|
||||
|
||||
_removeListener(isNormalizer ? target : ownerDoc, _eventTypes[1], _onDrag, true);
|
||||
|
||||
var isTrackingDrag = !isNaN(self.y - self.startY),
|
||||
wasDragging = self.isDragging,
|
||||
isDragNotClick = wasDragging && (Math.abs(self.x - self.startX) > 3 || Math.abs(self.y - self.startY) > 3),
|
||||
eventData = _getEvent(e);
|
||||
|
||||
if (!isDragNotClick && isTrackingDrag) {
|
||||
self._vx.reset();
|
||||
|
||||
self._vy.reset();
|
||||
|
||||
if (preventDefault && allowClicks) {
|
||||
gsap.delayedCall(0.08, function () {
|
||||
if (_getTime() - onClickTime > 300 && !e.defaultPrevented) {
|
||||
if (e.target.click) {
|
||||
e.target.click();
|
||||
} else if (ownerDoc.createEvent) {
|
||||
var syntheticEvent = ownerDoc.createEvent("MouseEvents");
|
||||
syntheticEvent.initMouseEvent("click", true, true, _win, 1, eventData.screenX, eventData.screenY, eventData.clientX, eventData.clientY, false, false, false, false, 0, null);
|
||||
e.target.dispatchEvent(syntheticEvent);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
self.isDragging = self.isGesturing = self.isPressed = false;
|
||||
onStop && wasDragging && !isNormalizer && onStopDelayedCall.restart(true);
|
||||
dragged && update();
|
||||
onDragEnd && wasDragging && onDragEnd(self);
|
||||
onRelease && onRelease(self, isDragNotClick);
|
||||
},
|
||||
_onGestureStart = function _onGestureStart(e) {
|
||||
return e.touches && e.touches.length > 1 && (self.isGesturing = true) && onGestureStart(e, self.isDragging);
|
||||
},
|
||||
_onGestureEnd = function _onGestureEnd() {
|
||||
return (self.isGesturing = false) || onGestureEnd(self);
|
||||
},
|
||||
onScroll = function onScroll(e) {
|
||||
if (_ignoreCheck(e)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var x = scrollFuncX(),
|
||||
y = scrollFuncY();
|
||||
onDelta((x - scrollX) * scrollSpeed, (y - scrollY) * scrollSpeed, 1);
|
||||
scrollX = x;
|
||||
scrollY = y;
|
||||
onStop && onStopDelayedCall.restart(true);
|
||||
},
|
||||
_onWheel = function _onWheel(e) {
|
||||
if (_ignoreCheck(e)) {
|
||||
return;
|
||||
}
|
||||
|
||||
e = _getEvent(e, preventDefault);
|
||||
onWheel && (wheeled = true);
|
||||
var multiplier = (e.deltaMode === 1 ? lineHeight : e.deltaMode === 2 ? _win.innerHeight : 1) * wheelSpeed;
|
||||
onDelta(e.deltaX * multiplier, e.deltaY * multiplier, 0);
|
||||
onStop && !isNormalizer && onStopDelayedCall.restart(true);
|
||||
},
|
||||
_onMove = function _onMove(e) {
|
||||
if (_ignoreCheck(e)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var x = e.clientX,
|
||||
y = e.clientY,
|
||||
dx = x - self.x,
|
||||
dy = y - self.y;
|
||||
self.x = x;
|
||||
self.y = y;
|
||||
moved = true;
|
||||
onStop && onStopDelayedCall.restart(true);
|
||||
(dx || dy) && onTouchOrPointerDelta(dx, dy);
|
||||
},
|
||||
_onHover = function _onHover(e) {
|
||||
self.event = e;
|
||||
onHover(self);
|
||||
},
|
||||
_onHoverEnd = function _onHoverEnd(e) {
|
||||
self.event = e;
|
||||
onHoverEnd(self);
|
||||
},
|
||||
_onClick = function _onClick(e) {
|
||||
return _ignoreCheck(e) || _getEvent(e, preventDefault) && onClick(self);
|
||||
};
|
||||
|
||||
onStopDelayedCall = self._dc = gsap.delayedCall(onStopDelay || 0.25, onStopFunc).pause();
|
||||
self.deltaX = self.deltaY = 0;
|
||||
self._vx = _getVelocityProp(0, 50, true);
|
||||
self._vy = _getVelocityProp(0, 50, true);
|
||||
self.scrollX = scrollFuncX;
|
||||
self.scrollY = scrollFuncY;
|
||||
self.isDragging = self.isGesturing = self.isPressed = false;
|
||||
|
||||
_context(this);
|
||||
|
||||
self.enable = function (e) {
|
||||
if (!self.isEnabled) {
|
||||
_addListener(isViewport ? ownerDoc : target, "scroll", _onScroll);
|
||||
|
||||
type.indexOf("scroll") >= 0 && _addListener(isViewport ? ownerDoc : target, "scroll", onScroll, passive, capture);
|
||||
type.indexOf("wheel") >= 0 && _addListener(target, "wheel", _onWheel, passive, capture);
|
||||
|
||||
if (type.indexOf("touch") >= 0 && _isTouch || type.indexOf("pointer") >= 0) {
|
||||
_addListener(target, _eventTypes[0], _onPress, passive, capture);
|
||||
|
||||
_addListener(ownerDoc, _eventTypes[2], _onRelease);
|
||||
|
||||
_addListener(ownerDoc, _eventTypes[3], _onRelease);
|
||||
|
||||
allowClicks && _addListener(target, "click", clickCapture, true, true);
|
||||
onClick && _addListener(target, "click", _onClick);
|
||||
onGestureStart && _addListener(ownerDoc, "gesturestart", _onGestureStart);
|
||||
onGestureEnd && _addListener(ownerDoc, "gestureend", _onGestureEnd);
|
||||
onHover && _addListener(target, _pointerType + "enter", _onHover);
|
||||
onHoverEnd && _addListener(target, _pointerType + "leave", _onHoverEnd);
|
||||
onMove && _addListener(target, _pointerType + "move", _onMove);
|
||||
}
|
||||
|
||||
self.isEnabled = true;
|
||||
self.isDragging = self.isGesturing = self.isPressed = moved = dragged = false;
|
||||
|
||||
self._vx.reset();
|
||||
|
||||
self._vy.reset();
|
||||
|
||||
scrollX = scrollFuncX();
|
||||
scrollY = scrollFuncY();
|
||||
e && e.type && _onPress(e);
|
||||
onEnable && onEnable(self);
|
||||
}
|
||||
|
||||
return self;
|
||||
};
|
||||
|
||||
self.disable = function () {
|
||||
if (self.isEnabled) {
|
||||
_observers.filter(function (o) {
|
||||
return o !== self && _isViewport(o.target);
|
||||
}).length || _removeListener(isViewport ? ownerDoc : target, "scroll", _onScroll);
|
||||
|
||||
if (self.isPressed) {
|
||||
self._vx.reset();
|
||||
|
||||
self._vy.reset();
|
||||
|
||||
_removeListener(isNormalizer ? target : ownerDoc, _eventTypes[1], _onDrag, true);
|
||||
}
|
||||
|
||||
_removeListener(isViewport ? ownerDoc : target, "scroll", onScroll, capture);
|
||||
|
||||
_removeListener(target, "wheel", _onWheel, capture);
|
||||
|
||||
_removeListener(target, _eventTypes[0], _onPress, capture);
|
||||
|
||||
_removeListener(ownerDoc, _eventTypes[2], _onRelease);
|
||||
|
||||
_removeListener(ownerDoc, _eventTypes[3], _onRelease);
|
||||
|
||||
_removeListener(target, "click", clickCapture, true);
|
||||
|
||||
_removeListener(target, "click", _onClick);
|
||||
|
||||
_removeListener(ownerDoc, "gesturestart", _onGestureStart);
|
||||
|
||||
_removeListener(ownerDoc, "gestureend", _onGestureEnd);
|
||||
|
||||
_removeListener(target, _pointerType + "enter", _onHover);
|
||||
|
||||
_removeListener(target, _pointerType + "leave", _onHoverEnd);
|
||||
|
||||
_removeListener(target, _pointerType + "move", _onMove);
|
||||
|
||||
self.isEnabled = self.isPressed = self.isDragging = false;
|
||||
onDisable && onDisable(self);
|
||||
}
|
||||
};
|
||||
|
||||
self.kill = self.revert = function () {
|
||||
self.disable();
|
||||
|
||||
var i = _observers.indexOf(self);
|
||||
|
||||
i >= 0 && _observers.splice(i, 1);
|
||||
_normalizer === self && (_normalizer = 0);
|
||||
};
|
||||
|
||||
_observers.push(self);
|
||||
|
||||
isNormalizer && _isViewport(target) && (_normalizer = self);
|
||||
self.enable(event);
|
||||
};
|
||||
|
||||
_createClass(Observer, [{
|
||||
key: "velocityX",
|
||||
get: function get() {
|
||||
return this._vx.getVelocity();
|
||||
}
|
||||
}, {
|
||||
key: "velocityY",
|
||||
get: function get() {
|
||||
return this._vy.getVelocity();
|
||||
}
|
||||
}]);
|
||||
|
||||
return Observer;
|
||||
}();
|
||||
Observer.version = "3.14.2";
|
||||
|
||||
Observer.create = function (vars) {
|
||||
return new Observer(vars);
|
||||
};
|
||||
|
||||
Observer.register = _initCore;
|
||||
|
||||
Observer.getAll = function () {
|
||||
return _observers.slice();
|
||||
};
|
||||
|
||||
Observer.getById = function (id) {
|
||||
return _observers.filter(function (o) {
|
||||
return o.vars.id === id;
|
||||
})[0];
|
||||
};
|
||||
|
||||
_getGSAP() && gsap.registerPlugin(Observer);
|
||||
|
||||
exports.Observer = Observer;
|
||||
exports._getProxyProp = _getProxyProp;
|
||||
exports._getScrollFunc = _getScrollFunc;
|
||||
exports._getTarget = _getTarget;
|
||||
exports._getVelocityProp = _getVelocityProp;
|
||||
exports._horizontal = _horizontal;
|
||||
exports._isViewport = _isViewport;
|
||||
exports._vertical = _vertical;
|
||||
exports.default = Observer;
|
||||
|
||||
if (typeof(window) === 'undefined' || window !== exports) {Object.defineProperty(exports, '__esModule', { value: true });} else {delete window.default;}
|
||||
|
||||
})));
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
/*!
|
||||
* Observer 3.14.2
|
||||
* https://gsap.com
|
||||
*
|
||||
* @license Copyright 2025, GreenSock. All rights reserved.
|
||||
* Subject to the terms at https://gsap.com/standard-license.
|
||||
* @author: Jack Doyle, jack@greensock.com
|
||||
*/
|
||||
|
||||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).window=e.window||{})}(this,function(a){"use strict";function _defineProperties(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function r(){return Me||"undefined"!=typeof window&&(Me=window.gsap)&&Me.registerPlugin&&Me}var Me,De,Ee,Pe,Oe,Ae,ze,Ye,Xe,t,Te,ke,Ce,o=1,He=[];a._scrollers=[],a._proxies=[];function x(e,t){return~a._proxies.indexOf(e)&&a._proxies[a._proxies.indexOf(e)+1][t]}function y(e){return!!~t.indexOf(e)}function z(e,t,n,r,o){return e.addEventListener(t,n,{passive:!1!==r,capture:!!o})}function A(e,t,n,r){return e.removeEventListener(t,n,!!r)}function D(){return Te&&Te.isPressed||a._scrollers.cache++}function E(n,r){function ra(e){if(e||0===e){o&&(Ee.history.scrollRestoration="manual");var t=Te&&Te.isPressed;e=ra.v=Math.round(e)||(Te&&Te.iOS?1:0),n(e),ra.cacheID=a._scrollers.cache,t&&i("ss",e)}else(r||a._scrollers.cache!==ra.cacheID||i("ref"))&&(ra.cacheID=a._scrollers.cache,ra.v=n());return ra.v+ra.offset}return ra.offset=0,n&&ra}function H(e,t){return(t&&t._ctx&&t._ctx.selector||Me.utils.toArray)(e)[0]||("string"==typeof e&&!1!==Me.config().nullTargetWarn?console.warn("Element not found:",e):null)}function J(t,e){var n=e.s,r=e.sc;y(t)&&(t=Pe.scrollingElement||Oe);var o=a._scrollers.indexOf(t),i=r===Ge.sc?1:2;~o||(o=a._scrollers.push(t)-1),a._scrollers[o+i]||z(t,"scroll",D);var s=a._scrollers[o+i],c=s||(a._scrollers[o+i]=E(x(t,n),!0)||(y(t)?r:E(function(e){return arguments.length?t[n]=e:t[n]})));return c.target=t,s||(c.smooth="smooth"===Me.getProperty(t,"scrollBehavior")),c}function K(e,t,o){function Ta(e,t){var n=Le();t||r<n-c?(s=i,i=e,a=c,c=n):o?i+=e:i=s+(e-s)/(n-a)*(c-a)}var i=e,s=e,c=Le(),a=c,r=t||50,l=Math.max(500,3*r);return{update:Ta,reset:function reset(){s=i=o?0:i,a=c=0},getVelocity:function getVelocity(e){var t=a,n=s,r=Le();return!e&&0!==e||e===i||Ta(e),c===a||l<r-a?0:(i+(o?n:-n))/((o?r:c)-t)*1e3}}}function L(e,t){return t&&!e._gsapAllow&&e.preventDefault(),e.changedTouches?e.changedTouches[0]:e}function M(e){var t=Math.max.apply(Math,e),n=Math.min.apply(Math,e);return Math.abs(t)>=Math.abs(n)?t:n}function N(){(Xe=Me.core.globals().ScrollTrigger)&&Xe.core&&function _integrate(){var e=Xe.core,n=e.bridge||{},t=e._scrollers,r=e._proxies;t.push.apply(t,a._scrollers),r.push.apply(r,a._proxies),a._scrollers=t,a._proxies=r,i=function _bridge(e,t){return n[e](t)}}()}function O(e){return Me=e||r(),!De&&Me&&"undefined"!=typeof document&&document.body&&(Ee=window,Oe=(Pe=document).documentElement,Ae=Pe.body,t=[Ee,Pe,Oe,Ae],Me.utils.clamp,Ce=Me.core.context||function(){},Ye="onpointerenter"in Ae?"pointer":"mouse",ze=c.isTouch=Ee.matchMedia&&Ee.matchMedia("(hover: none), (pointer: coarse)").matches?1:"ontouchstart"in Ee||0<navigator.maxTouchPoints||0<navigator.msMaxTouchPoints?2:0,ke=c.eventTypes=("ontouchstart"in Oe?"touchstart,touchmove,touchcancel,touchend":"onpointerdown"in Oe?"pointerdown,pointermove,pointercancel,pointerup":"mousedown,mousemove,mouseup,mouseup").split(","),setTimeout(function(){return o=0},500),N(),De=1),De}var Le=Date.now,i=function _bridge(e,t){return t},n="scrollLeft",s="scrollTop",Se={s:n,p:"left",p2:"Left",os:"right",os2:"Right",d:"width",d2:"Width",a:"x",sc:E(function(e){return arguments.length?Ee.scrollTo(e,Ge.sc()):Ee.pageXOffset||Pe[n]||Oe[n]||Ae[n]||0})},Ge={s:s,p:"top",p2:"Top",os:"bottom",os2:"Bottom",d:"height",d2:"Height",a:"y",op:Se,sc:E(function(e){return arguments.length?Ee.scrollTo(Se.sc(),e):Ee.pageYOffset||Pe[s]||Oe[s]||Ae[s]||0})};Se.op=Ge,a._scrollers.cache=0;var c=(Observer.prototype.init=function init(e){De||O(Me)||console.warn("Please gsap.registerPlugin(Observer)"),Xe||N();var o=e.tolerance,s=e.dragMinimum,t=e.type,i=e.target,n=e.lineHeight,r=e.debounce,c=e.preventDefault,a=e.onStop,l=e.onStopDelay,u=e.ignore,f=e.wheelSpeed,d=e.event,g=e.onDragStart,p=e.onDragEnd,h=e.onDrag,v=e.onPress,_=e.onRelease,x=e.onRight,m=e.onLeft,b=e.onUp,w=e.onDown,E=e.onChangeX,P=e.onChangeY,Y=e.onChange,X=e.onToggleX,T=e.onToggleY,k=e.onHover,C=e.onHoverEnd,S=e.onMove,G=e.ignoreCheck,F=e.isNormalizer,I=e.onGestureStart,V=e.onGestureEnd,R=e.onWheel,W=e.onEnable,j=e.onDisable,B=e.onClick,q=e.scrollSpeed,U=e.capture,Q=e.allowClicks,Z=e.lockAxis,$=e.onLockAxis;function tc(){return me=Le()}function uc(e,t){return(ce.event=e)&&u&&function _isWithin(e,t){for(var n=t.length;n--;)if(t[n]===e||t[n].contains(e))return!0;return!1}(e.target,u)||t&&he&&"touch"!==e.pointerType||G&&G(e,t)}function wc(){var e=ce.deltaX=M(_e),t=ce.deltaY=M(xe),n=Math.abs(e)>=o,r=Math.abs(t)>=o;Y&&(n||r)&&Y(ce,e,t,_e,xe),n&&(x&&0<ce.deltaX&&x(ce),m&&ce.deltaX<0&&m(ce),E&&E(ce),X&&ce.deltaX<0!=ae<0&&X(ce),ae=ce.deltaX,_e[0]=_e[1]=_e[2]=0),r&&(w&&0<ce.deltaY&&w(ce),b&&ce.deltaY<0&&b(ce),P&&P(ce),T&&ce.deltaY<0!=le<0&&T(ce),le=ce.deltaY,xe[0]=xe[1]=xe[2Line truncated
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Observer.min.js","sources":["../src/Observer.js"],"sourcesContent":["/*!\n * Observer 3.14.2\n * https://gsap.com\n *\n * @license Copyright 2008-2025, GreenSock. All rights reserved.\n * Subject to the terms at https://gsap.com/standard-license\n * @author: Jack Doyle, jack@greensock.com\n*/\n/* eslint-disable */\n\nlet gsap, _coreInitted, _clamp, _win, _doc, _docEl, _body, _isTouch, _pointerType, ScrollTrigger, _root, _normalizer, _eventTypes, _context,\n\t_getGSAP = () => gsap || (typeof(window) !== \"undefined\" && (gsap = window.gsap) && gsap.registerPlugin && gsap),\n\t_startup = 1,\n\t_observers = [],\n\t_scrollers = [],\n\t_proxies = [],\n\t_getTime = Date.now,\n\t_bridge = (name, value) => value,\n\t_integrate = () => {\n\t\tlet core = ScrollTrigger.core,\n\t\t\tdata = core.bridge || {},\n\t\t\tscrollers = core._scrollers,\n\t\t\tproxies = core._proxies;\n\t\tscrollers.push(..._scrollers);\n\t\tproxies.push(..._proxies);\n\t\t_scrollers = scrollers;\n\t\t_proxies = proxies;\n\t\t_bridge = (name, value) => data[name](value);\n\t},\n\t_getProxyProp = (element, property) => ~_proxies.indexOf(element) && _proxies[_proxies.indexOf(element) + 1][property],\n\t_isViewport = el => !!~_root.indexOf(el),\n\t_addListener = (element, type, func, passive, capture) => element.addEventListener(type, func, {passive: passive !== false, capture: !!capture}),\n\t_removeListener = (element, type, func, capture) => element.removeEventListener(type, func, !!capture),\n\t_scrollLeft = \"scrollLeft\",\n\t_scrollTop = \"scrollTop\",\n\t_onScroll = () => (_normalizer && _normalizer.isPressed) || _scrollers.cache++,\n\t_scrollCacheFunc = (f, doNotCache) => {\n\t\tlet cachingFunc = value => { // since reading the scrollTop/scrollLeft/pageOffsetY/pageOffsetX can trigger a layout, this function allows us to cache the value so it only gets read fresh after a \"scroll\" event fires (or while we're refreshing because that can lengthen the page and alter the scroll position). when \"soft\" is true, that means don't actually set the scroll, but cache the new value instead (useful in ScrollSmoother)\n\t\t\tif (value || value === 0) {\n\t\t\t\t_startup && (_win.history.scrollRestoration = \"manual\"); // otherwise the new position will get overwritten by the browser onload.\n\t\t\t\tlet isNormalizing = _normalizer && _normalizer.isPressed;\n\t\t\t\tvalue = cachingFunc.v = Math.round(value) || (_normalizer && _normalizer.iOS ? 1 : 0); //TODO: iOS Bug: if you allow it to go to 0, Safari can start to report super strange (wildly inaccurate) touch positions!\n\t\t\t\tf(value);\n\t\t\t\tcachingFunc.cacheID = _scrollers.cache;\n\t\t\t\tisNormalizing && _bridge(\"ss\", value); // set scroll (notify ScrollTrigger so it can dispatch a \"scrollStart\" event if necessary\n\t\t\t} else if (doNotCache || _scrollers.cache !== cachingFunc.cacheID || _bridge(\"ref\")) {\n\t\t\t\tcachingFunc.cacheID = _scrollers.cache;\n\t\t\t\tcachingFunc.v = f();\n\t\t\t}\n\t\t\treturn cachingFunc.v + cachingFunc.offset;\n\t\t};\n\t\tcachingFunc.offset = 0;\n\t\treturn f && cachingFunc;\n\t},\n\t_horizontal = {s: _scrollLeft, p: \"left\", p2: \"Left\", os: \"right\", os2: \"Right\", d: \"width\", d2: \"Width\", a: \"x\", sc: _scrollCacheFunc(function(value) { return arguments.length ? _win.scrollTo(value, _vertical.sc()) : _win.pageXOffset || _doc[_scrollLeft] || _docEl[_scrollLeft] || _body[_scrollLeft] || 0})},\n\t_vertical = {s: _scrollTop, p: \"top\", p2: \"Top\", os: \"bottom\", os2: \"Bottom\", d: \"height\", d2: \"Height\", a: \"y\", op: _horizontal, sc: _scrollCacheFunc(function(value) { return arguments.length ? _win.scrollTo(_horizontal.sc(), value) : _win.pageYOffset || _doc[_scrollTop] || _docEl[_scrollTop] || _body[_scrollTop] || 0})},\n\t_getTarget = (t, self) => ((self && self._ctx && self._ctx.selector) || gsap.utils.toArray)(t)[0] || (typeof(t) === \"string\" && gsap.config().nullTargetWarn !== false ? console.warn(\"Element not found:\", t) : null),\n\n\t_isWithin = (element, list) => { // check if the element is in the list or is a descendant of an element in the list.\n\t\tlet i = list.length;\n\t\twhile (i--) {\n\t\t\tif (list[i] === element || list[i].contains(element)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t},\n\t_getScrollFunc = (element, {s, sc}) => { // we store the scroller functions in an alternating sequenced Array like [element, verticalScrollFunc, horizontalScrollFunc, ...] so that we can minimize memory, maximize performance, and we also record the last position as a \".rec\" property in order to revert to that after refreshing to ensure things don't shift around.\n\t\t_isViewport(element) && (element = _doc.scrollingElement || _docEl);\n\t\tlet i = _scrollers.indexOf(element),\n\t\t\toffset = sc === _vertical.sc ? 1 : 2;\n\t\t!~i && (i = _scrollers.push(element) - 1);\n\t\t_scrollers[i + offset] || _addListener(element, \"scroll\", _onScroll); // clear the cache when a scroll occurs\n\t\tlLine truncated
|
||||
+167
@@ -0,0 +1,167 @@
|
||||
(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';
|
||||
|
||||
/*!
|
||||
* Physics2DPlugin 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 gsap,
|
||||
_coreInitted,
|
||||
_getUnit,
|
||||
_getStyleSaver,
|
||||
_reverting,
|
||||
_DEG2RAD = Math.PI / 180,
|
||||
_getGSAP = function _getGSAP() {
|
||||
return gsap || typeof window !== "undefined" && (gsap = window.gsap) && gsap.registerPlugin && gsap;
|
||||
},
|
||||
_round = function _round(value) {
|
||||
return Math.round(value * 10000) / 10000;
|
||||
},
|
||||
_initCore = function _initCore(core) {
|
||||
gsap = core || _getGSAP();
|
||||
|
||||
if (!_coreInitted) {
|
||||
_getUnit = gsap.utils.getUnit;
|
||||
_getStyleSaver = gsap.core.getStyleSaver;
|
||||
|
||||
_reverting = gsap.core.reverting || function () {};
|
||||
|
||||
_coreInitted = 1;
|
||||
}
|
||||
};
|
||||
|
||||
var PhysicsProp = function PhysicsProp(target, p, velocity, acceleration, stepsPerTimeUnit) {
|
||||
var cache = target._gsap,
|
||||
curVal = cache.get(target, p);
|
||||
this.p = p;
|
||||
this.set = cache.set(target, p);
|
||||
this.s = this.val = parseFloat(curVal);
|
||||
this.u = _getUnit(curVal) || 0;
|
||||
this.vel = velocity || 0;
|
||||
this.v = this.vel / stepsPerTimeUnit;
|
||||
|
||||
if (acceleration || acceleration === 0) {
|
||||
this.acc = acceleration;
|
||||
this.a = this.acc / (stepsPerTimeUnit * stepsPerTimeUnit);
|
||||
} else {
|
||||
this.acc = this.a = 0;
|
||||
}
|
||||
};
|
||||
|
||||
var Physics2DPlugin = {
|
||||
version: "3.14.2",
|
||||
name: "physics2D",
|
||||
register: _initCore,
|
||||
init: function init(target, value, tween) {
|
||||
_coreInitted || _initCore();
|
||||
var data = this,
|
||||
angle = +value.angle || 0,
|
||||
velocity = +value.velocity || 0,
|
||||
acceleration = +value.acceleration || 0,
|
||||
xProp = value.xProp || "x",
|
||||
yProp = value.yProp || "y",
|
||||
aAngle = value.accelerationAngle || value.accelerationAngle === 0 ? +value.accelerationAngle : angle;
|
||||
data.styles = _getStyleSaver && _getStyleSaver(target, value.xProp && value.xProp !== "x" ? value.xProp + "," + value.yProp : "transform");
|
||||
data.target = target;
|
||||
data.tween = tween;
|
||||
data.step = 0;
|
||||
data.sps = 30;
|
||||
|
||||
if (value.gravity) {
|
||||
acceleration = +value.gravity;
|
||||
aAngle = 90;
|
||||
}
|
||||
|
||||
angle *= _DEG2RAD;
|
||||
aAngle *= _DEG2RAD;
|
||||
data.fr = 1 - (+value.friction || 0);
|
||||
|
||||
data._props.push(xProp, yProp);
|
||||
|
||||
data.xp = new PhysicsProp(target, xProp, Math.cos(angle) * velocity, Math.cos(aAngle) * acceleration, data.sps);
|
||||
data.yp = new PhysicsProp(target, yProp, Math.sin(angle) * velocity, Math.sin(aAngle) * acceleration, data.sps);
|
||||
data.skipX = data.skipY = 0;
|
||||
},
|
||||
render: function render(ratio, data) {
|
||||
var xp = data.xp,
|
||||
yp = data.yp,
|
||||
tween = data.tween,
|
||||
target = data.target,
|
||||
step = data.step,
|
||||
sps = data.sps,
|
||||
fr = data.fr,
|
||||
skipX = data.skipX,
|
||||
skipY = data.skipY,
|
||||
time = tween._from ? tween._dur - tween._time : tween._time,
|
||||
x,
|
||||
y,
|
||||
tt,
|
||||
steps,
|
||||
remainder,
|
||||
i;
|
||||
|
||||
if (tween._time || !_reverting()) {
|
||||
if (fr === 1) {
|
||||
tt = time * time * 0.5;
|
||||
x = xp.s + xp.vel * time + xp.acc * tt;
|
||||
y = yp.s + yp.vel * time + yp.acc * tt;
|
||||
} else {
|
||||
time *= sps;
|
||||
steps = i = (time | 0) - step;
|
||||
|
||||
if (i < 0) {
|
||||
xp.v = xp.vel / sps;
|
||||
yp.v = yp.vel / sps;
|
||||
xp.val = xp.s;
|
||||
yp.val = yp.s;
|
||||
data.step = 0;
|
||||
steps = i = time | 0;
|
||||
}
|
||||
|
||||
remainder = time % 1 * fr;
|
||||
|
||||
while (i--) {
|
||||
xp.v += xp.a;
|
||||
yp.v += yp.a;
|
||||
xp.v *= fr;
|
||||
yp.v *= fr;
|
||||
xp.val += xp.v;
|
||||
yp.val += yp.v;
|
||||
}
|
||||
|
||||
x = xp.val + xp.v * remainder;
|
||||
y = yp.val + yp.v * remainder;
|
||||
data.step += steps;
|
||||
}
|
||||
|
||||
skipX || xp.set(target, xp.p, _round(x) + xp.u);
|
||||
skipY || yp.set(target, yp.p, _round(y) + yp.u);
|
||||
} else {
|
||||
data.styles.revert();
|
||||
}
|
||||
},
|
||||
kill: function kill(property) {
|
||||
if (this.xp.p === property) {
|
||||
this.skipX = 1;
|
||||
}
|
||||
|
||||
if (this.yp.p === property) {
|
||||
this.skipY = 1;
|
||||
}
|
||||
}
|
||||
};
|
||||
_getGSAP() && gsap.registerPlugin(Physics2DPlugin);
|
||||
|
||||
exports.Physics2DPlugin = Physics2DPlugin;
|
||||
exports.default = Physics2DPlugin;
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
})));
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
/*!
|
||||
* Physics2DPlugin 3.14.2
|
||||
* https://gsap.com
|
||||
*
|
||||
* @license Copyright 2025, GreenSock. All rights reserved.
|
||||
* Subject to the terms at https://gsap.com/standard-license.
|
||||
* @author: Jack Doyle, jack@greensock.com
|
||||
*/
|
||||
|
||||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).window=e.window||{})}(this,function(e){"use strict";function j(){return t||"undefined"!=typeof window&&(t=window.gsap)&&t.registerPlugin&&t}function k(e){return Math.round(1e4*e)/1e4}function l(e){t=e||j(),v||(o=t.utils.getUnit,f=t.core.getStyleSaver,w=t.core.reverting||function(){},v=1)}function m(e,t,i,s,n){var r=e._gsap,a=r.get(e,t);this.p=t,this.set=r.set(e,t),this.s=this.val=parseFloat(a),this.u=o(a)||0,this.vel=i||0,this.v=this.vel/n,s||0===s?(this.acc=s,this.a=this.acc/(n*n)):this.acc=this.a=0}var t,v,o,f,w,u=Math.PI/180,i={version:"3.14.2",name:"physics2D",register:l,init:function init(e,t,i){v||l();var s=this,n=+t.angle||0,r=+t.velocity||0,a=+t.acceleration||0,o=t.xProp||"x",p=t.yProp||"y",c=t.accelerationAngle||0===t.accelerationAngle?+t.accelerationAngle:n;s.styles=f&&f(e,t.xProp&&"x"!==t.xProp?t.xProp+","+t.yProp:"transform"),s.target=e,s.tween=i,s.step=0,s.sps=30,t.gravity&&(a=+t.gravity,c=90),n*=u,c*=u,s.fr=1-(+t.friction||0),s._props.push(o,p),s.xp=new m(e,o,Math.cos(n)*r,Math.cos(c)*a,s.sps),s.yp=new m(e,p,Math.sin(n)*r,Math.sin(c)*a,s.sps),s.skipX=s.skipY=0},render:function render(e,t){var i,s,n,r,a,o,p=t.xp,l=t.yp,c=t.tween,v=t.target,f=t.step,u=t.sps,h=t.fr,d=t.skipX,g=t.skipY,y=c._from?c._dur-c._time:c._time;if(c._time||!w()){if(1===h)n=y*y*.5,i=p.s+p.vel*y+p.acc*n,s=l.s+l.vel*y+l.acc*n;else{for(r=o=(0|(y*=u))-f,o<0&&(p.v=p.vel/u,l.v=l.vel/u,p.val=p.s,l.val=l.s,r=o=(t.step=0)|y),a=y%1*h;o--;)p.v+=p.a,l.v+=l.a,p.v*=h,l.v*=h,p.val+=p.v,l.val+=l.v;i=p.val+p.v*a,s=l.val+l.v*a,t.step+=r}d||p.set(v,p.p,k(i)+p.u),g||l.set(v,l.p,k(s)+l.u)}else t.styles.revert()},kill:function kill(e){this.xp.p===e&&(this.skipX=1),this.yp.p===e&&(this.skipY=1)}};j()&&t.registerPlugin(i),e.Physics2DPlugin=i,e.default=i;if (typeof(window)==="undefined"||window!==e){Object.defineProperty(e,"__esModule",{value:!0})} else {delete e.default}});
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Physics2DPlugin.min.js","sources":["../src/Physics2DPlugin.js"],"sourcesContent":["/*!\n * Physics2DPlugin 3.14.2\n * https://gsap.com\n *\n * @license Copyright 2008-2025, GreenSock. All rights reserved.\n * Subject to the terms at https://gsap.com/standard-license\n * @author: Jack Doyle, jack@greensock.com\n*/\n/* eslint-disable */\n\nlet gsap, _coreInitted, _getUnit, _getStyleSaver, _reverting,\n\t_DEG2RAD = Math.PI / 180,\n\t_getGSAP = () => gsap || (typeof(window) !== \"undefined\" && (gsap = window.gsap) && gsap.registerPlugin && gsap),\n\t_round = value => Math.round(value * 10000) / 10000,\n\t_bonusValidated = 1, //<name>Physics2DPlugin</name>\n\t_initCore = core => {\n\t\tgsap = core || _getGSAP();\n\t\tif (!_coreInitted) {\n\t\t\t_getUnit = gsap.utils.getUnit;\n\t\t\t_getStyleSaver = gsap.core.getStyleSaver;\n\t\t\t_reverting = gsap.core.reverting || function() {};\n\t\t\t_coreInitted = 1;\n\t\t}\n\t};\n\nclass PhysicsProp {\n\n\tconstructor(target, p, velocity, acceleration, stepsPerTimeUnit) {\n\t\tlet cache = target._gsap,\n\t\t\tcurVal = cache.get(target, p);\n\t\tthis.p = p;\n\t\tthis.set = cache.set(target, p); //setter\n\t\tthis.s = this.val = parseFloat(curVal);\n\t\tthis.u = _getUnit(curVal) || 0;\n\t\tthis.vel = velocity || 0;\n\t\tthis.v = this.vel / stepsPerTimeUnit;\n\t\tif (acceleration || acceleration === 0) {\n\t\t\tthis.acc = acceleration;\n\t\t\tthis.a = this.acc / (stepsPerTimeUnit * stepsPerTimeUnit);\n\t\t} else {\n\t\t\tthis.acc = this.a = 0;\n\t\t}\n\t}\n\n}\n\n\nexport const Physics2DPlugin = {\n\tversion:\"3.14.2\",\n\tname:\"physics2D\",\n\tregister: _initCore,\n\tinit(target, value, tween) {\n\t\t_coreInitted || _initCore();\n\t\tlet data = this,\n\t\t\tangle = +value.angle || 0,\n\t\t\tvelocity = +value.velocity || 0,\n\t\t\tacceleration = +value.acceleration || 0,\n\t\t\txProp = value.xProp || \"x\",\n\t\t\tyProp = value.yProp || \"y\",\n\t\t\taAngle = (value.accelerationAngle || value.accelerationAngle === 0) ? +value.accelerationAngle : angle;\n\t\tdata.styles = _getStyleSaver && _getStyleSaver(target, value.xProp && value.xProp !== \"x\" ? value.xProp + \",\" + value.yProp : \"transform\");\n\t\tdata.target = target;\n\t\tdata.tween = tween;\n\t\tdata.step = 0;\n\t\tdata.sps = 30; //steps per second\n\t\tif (value.gravity) {\n\t\t\tacceleration = +value.gravity;\n\t\t\taAngle = 90;\n\t\t}\n\t\tangle *= _DEG2RAD;\n\t\taAngle *= _DEG2RAD;\n\t\tdata.fr = 1 - (+value.friction || 0);\n\t\tdata._props.push(xProp, yProp);\n\n\t\tdata.xp = new PhysicsProp(target, xProp, Math.cos(angle) * velocity, Math.cos(aAngle) * acceleration, data.sps);\n\t\tdata.yp = new PhysicsProp(target, yProp, Math.sin(angle) * velocity, Math.sin(aAngle) * acceleration, data.sps);\n\t\tdata.skipX = data.skipY = 0;\n\t},\n\trender(ratio, data) {\n\t\tlet { xp, yp, tween, target, step, sps, fr, skipX, skipY } = data,\n\t\t\ttime = tween._from ? tween._dur - tween._time : tween._time,\n\t\t\tx, y, tt, steps, remainder, i;\n\t\tif (tween._time || !_reverting()) {\n\t\t\tif (fr === 1) {\n\t\t\t\ttt = time * time * 0.5;\n\t\t\t\tx = xp.s + xp.vel * time + xp.acc * tt;\n\t\t\t\ty = yp.s + yp.vel * time + yp.acc * tt;\n\t\t\t} else {\n\t\t\t\ttime *= sps;\n\t\t\t\tsteps = i = (time | 0) - step;\n\t\t\t\t/*\n\t\t\t\tNote: rounding errors build up if we walk the calculations backward which we used to do like this to maximize performance:\n\t\t\t\t\ti = -i;\n\t\t\t\t\twhile (i--) {\n\t\t\t\t\t\txp.val -= xp.v;\n\t\t\t\t\t\typ.val -= yp.v;\n\t\t\t\t\t\txp.v /= fr;\n\t\t\t\t\t\typ.v /= fr;\n\t\t\t\t\t\txp.v -= xp.a;\n\t\t\t\t\t\typ.v -= yp.a;\n\t\t\t\t\t}\n\t\t\t\tbut now for the sake of accuracy (to ensure rewinding always goes back to EXACTLY the same spot), we force the calculations to go forward every time. So if the tween is going backward, we just start from the beginning and iterate. This is only necessary with friction.\n\t\t\t\t */\n\t\t\t\tif (i < 0) {\n\t\t\t\t\txp.v = xp.vel / sps;\n\t\t\t\t\typ.v = yp.vel / sps;\n\t\t\t\t\txp.val = xp.s;\n\t\t\t\t\typ.val = yp.s;\n\t\t\t\t\tdata.step = 0;\n\t\t\t\t\tsteps = i = time | 0;\n\t\t\t\t}\n\t\t\t\tremainder = (time % 1) * fr;\n\t\t\t\twhile (i--) {\n\t\t\t\t\txp.v += xp.a;\n\t\t\t\t\typ.v += yp.a;\n\t\t\t\t\txp.v *= fr;\n\t\t\t\t\typ.v *= fr;\n\t\t\t\t\txp.val += xp.v;\n\t\t\t\t\typ.val += yp.v;\n\t\t\t\t}\n\t\t\t\tx = xp.val + xp.v * remainder;\n\t\t\t\ty = yp.val + yp.v * remainder;\n\t\t\t\tdata.step += steps;\n\t\t\t}\n\t\t\tskipX || xp.set(target, xp.p, _round(x) + xp.u);\n\t\t\tskipY || yp.set(target, yp.p, _round(y) + yp.u);\n\t\t} else {\n\t\t\tdata.styles.revert();\n\t\t}\n\t},\n\tkill(property) {\n\t\tif (this.xp.p === property) {\n\t\t\tthis.skipX = 1;\n\t\t}\n\t\tif (this.yp.p === property) {\n\t\t\tthis.skipY = 1;\n\t\t}\n\t}\n};\n\n\n_getGSAP() && gsap.registerPlugin(Physics2DPlugin);\n\nexport { Physics2DPlugin as default };"],"names":["_getGSAP","gsap","window","registerPlugin","_round","value","Math","round","_initCLine truncated
|
||||
+166
@@ -0,0 +1,166 @@
|
||||
(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';
|
||||
|
||||
/*!
|
||||
* PhysicsPropsPlugin 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 gsap,
|
||||
_coreInitted,
|
||||
_getUnit,
|
||||
_getStyleSaver,
|
||||
_reverting,
|
||||
_getGSAP = function _getGSAP() {
|
||||
return gsap || typeof window !== "undefined" && (gsap = window.gsap) && gsap.registerPlugin && gsap;
|
||||
},
|
||||
_round = function _round(value) {
|
||||
return Math.round(value * 10000) / 10000;
|
||||
},
|
||||
_initCore = function _initCore(core) {
|
||||
gsap = core || _getGSAP();
|
||||
|
||||
if (!_coreInitted) {
|
||||
_getUnit = gsap.utils.getUnit;
|
||||
_getStyleSaver = gsap.core.getStyleSaver;
|
||||
|
||||
_reverting = gsap.core.reverting || function () {};
|
||||
|
||||
_coreInitted = 1;
|
||||
}
|
||||
};
|
||||
|
||||
var PhysicsProp = function PhysicsProp(target, p, velocity, acceleration, friction, stepsPerTimeUnit) {
|
||||
var cache = target._gsap,
|
||||
curVal = cache.get(target, p);
|
||||
this.p = p;
|
||||
this.set = cache.set(target, p);
|
||||
this.s = this.val = parseFloat(curVal);
|
||||
this.u = _getUnit(curVal) || 0;
|
||||
this.vel = velocity || 0;
|
||||
this.v = this.vel / stepsPerTimeUnit;
|
||||
|
||||
if (acceleration || acceleration === 0) {
|
||||
this.acc = acceleration;
|
||||
this.a = this.acc / (stepsPerTimeUnit * stepsPerTimeUnit);
|
||||
} else {
|
||||
this.acc = this.a = 0;
|
||||
}
|
||||
|
||||
this.fr = 1 - (friction || 0);
|
||||
};
|
||||
|
||||
var PhysicsPropsPlugin = {
|
||||
version: "3.14.2",
|
||||
name: "physicsProps",
|
||||
register: _initCore,
|
||||
init: function init(target, value, tween) {
|
||||
_coreInitted || _initCore();
|
||||
var data = this,
|
||||
p;
|
||||
data.styles = _getStyleSaver && _getStyleSaver(target);
|
||||
data.target = target;
|
||||
data.tween = tween;
|
||||
data.step = 0;
|
||||
data.sps = 30;
|
||||
data.vProps = [];
|
||||
|
||||
for (p in value) {
|
||||
var _value$p = value[p],
|
||||
velocity = _value$p.velocity,
|
||||
acceleration = _value$p.acceleration,
|
||||
friction = _value$p.friction;
|
||||
|
||||
if (velocity || acceleration) {
|
||||
data.vProps.push(new PhysicsProp(target, p, velocity, acceleration, friction, data.sps));
|
||||
|
||||
data._props.push(p);
|
||||
|
||||
_getStyleSaver && data.styles.save(p);
|
||||
friction && (data.hasFr = 1);
|
||||
}
|
||||
}
|
||||
},
|
||||
render: function render(ratio, data) {
|
||||
var vProps = data.vProps,
|
||||
tween = data.tween,
|
||||
target = data.target,
|
||||
step = data.step,
|
||||
hasFr = data.hasFr,
|
||||
sps = data.sps,
|
||||
i = vProps.length,
|
||||
time = tween._from ? tween._dur - tween._time : tween._time,
|
||||
curProp,
|
||||
steps,
|
||||
remainder,
|
||||
j,
|
||||
tt;
|
||||
|
||||
if (tween._time || !_reverting()) {
|
||||
if (hasFr) {
|
||||
time *= sps;
|
||||
steps = (time | 0) - step;
|
||||
|
||||
if (steps < 0) {
|
||||
while (i--) {
|
||||
curProp = vProps[i];
|
||||
curProp.v = curProp.vel / sps;
|
||||
curProp.val = curProp.s;
|
||||
}
|
||||
|
||||
i = vProps.length;
|
||||
data.step = step = 0;
|
||||
steps = time | 0;
|
||||
}
|
||||
|
||||
remainder = time % 1;
|
||||
|
||||
while (i--) {
|
||||
curProp = vProps[i];
|
||||
j = steps;
|
||||
|
||||
while (j--) {
|
||||
curProp.v += curProp.a;
|
||||
curProp.v *= curProp.fr;
|
||||
curProp.val += curProp.v;
|
||||
}
|
||||
|
||||
curProp.set(target, curProp.p, _round(curProp.val + curProp.v * remainder * curProp.fr) + curProp.u);
|
||||
}
|
||||
|
||||
data.step += steps;
|
||||
} else {
|
||||
tt = time * time * 0.5;
|
||||
|
||||
while (i--) {
|
||||
curProp = vProps[i];
|
||||
curProp.set(target, curProp.p, _round(curProp.s + curProp.vel * time + curProp.acc * tt) + curProp.u);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
data.styles.revert();
|
||||
}
|
||||
},
|
||||
kill: function kill(property) {
|
||||
var vProps = this.vProps,
|
||||
i = vProps.length;
|
||||
|
||||
while (i--) {
|
||||
vProps[i].p === property && vProps.splice(i, 1);
|
||||
}
|
||||
}
|
||||
};
|
||||
_getGSAP() && gsap.registerPlugin(PhysicsPropsPlugin);
|
||||
|
||||
exports.PhysicsPropsPlugin = PhysicsPropsPlugin;
|
||||
exports.default = PhysicsPropsPlugin;
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
})));
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
/*!
|
||||
* PhysicsPropsPlugin 3.14.2
|
||||
* https://gsap.com
|
||||
*
|
||||
* @license Copyright 2025, GreenSock. All rights reserved.
|
||||
* Subject to the terms at https://gsap.com/standard-license.
|
||||
* @author: Jack Doyle, jack@greensock.com
|
||||
*/
|
||||
|
||||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).window=e.window||{})}(this,function(e){"use strict";function i(){return t||"undefined"!=typeof window&&(t=window.gsap)&&t.registerPlugin&&t}function j(e){return Math.round(1e4*e)/1e4}function k(e){t=e||i(),p||(a=t.utils.getUnit,c=t.core.getStyleSaver,d=t.core.reverting||function(){},p=1)}function l(e,t,s,i,r,n){var o=e._gsap,f=o.get(e,t);this.p=t,this.set=o.set(e,t),this.s=this.val=parseFloat(f),this.u=a(f)||0,this.vel=s||0,this.v=this.vel/n,i||0===i?(this.acc=i,this.a=this.acc/(n*n)):this.acc=this.a=0,this.fr=1-(r||0)}var t,p,a,c,d,s={version:"3.14.2",name:"physicsProps",register:k,init:function init(e,t,s){p||k();var i,r=this;for(i in r.styles=c&&c(e),r.target=e,r.tween=s,r.step=0,r.sps=30,r.vProps=[],t){var n=t[i],o=n.velocity,f=n.acceleration,a=n.friction;(o||f)&&(r.vProps.push(new l(e,i,o,f,a,r.sps)),r._props.push(i),c&&r.styles.save(i),a&&(r.hasFr=1))}},render:function render(e,t){var s,i,r,n,o,f=t.vProps,l=t.tween,a=t.target,p=t.step,c=t.hasFr,u=t.sps,v=f.length,h=l._from?l._dur-l._time:l._time;if(l._time||!d())if(c){if((i=(0|(h*=u))-p)<0){for(;v--;)(s=f[v]).v=s.vel/u,s.val=s.s;v=f.length,t.step=p=0,i=0|h}for(r=h%1;v--;){for(s=f[v],n=i;n--;)s.v+=s.a,s.v*=s.fr,s.val+=s.v;s.set(a,s.p,j(s.val+s.v*r*s.fr)+s.u)}t.step+=i}else for(o=h*h*.5;v--;)(s=f[v]).set(a,s.p,j(s.s+s.vel*h+s.acc*o)+s.u);else t.styles.revert()},kill:function kill(e){for(var t=this.vProps,s=t.length;s--;)t[s].p===e&&t.splice(s,1)}};i()&&t.registerPlugin(s),e.PhysicsPropsPlugin=s,e.default=s;if (typeof(window)==="undefined"||window!==e){Object.defineProperty(e,"__esModule",{value:!0})} else {delete e.default}});
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"PhysicsPropsPlugin.min.js","sources":["../src/PhysicsPropsPlugin.js"],"sourcesContent":["/*!\n * PhysicsPropsPlugin 3.14.2\n * https://gsap.com\n *\n * @license Copyright 2008-2025, GreenSock. All rights reserved.\n * Subject to the terms at https://gsap.com/standard-license\n * @author: Jack Doyle, jack@greensock.com\n*/\n/* eslint-disable */\n\nlet gsap, _coreInitted, _getUnit, _getStyleSaver, _reverting,\n\t_getGSAP = () => gsap || (typeof(window) !== \"undefined\" && (gsap = window.gsap) && gsap.registerPlugin && gsap),\n\t_round = value => Math.round(value * 10000) / 10000,\n\t_bonusValidated = 1, //<name>PhysicsPropsPlugin</name>\n\t_initCore = core => {\n\t\tgsap = core || _getGSAP();\n\t\tif (!_coreInitted) {\n\t\t\t_getUnit = gsap.utils.getUnit;\n\t\t\t_getStyleSaver = gsap.core.getStyleSaver;\n\t\t\t_reverting = gsap.core.reverting || function() {};\n\t\t\t_coreInitted = 1;\n\t\t}\n\t};\n\nclass PhysicsProp {\n\n\tconstructor(target, p, velocity, acceleration, friction, stepsPerTimeUnit) {\n\t\tlet cache = target._gsap,\n\t\t\tcurVal = cache.get(target, p);\n\t\tthis.p = p;\n\t\tthis.set = cache.set(target, p); //setter\n\t\tthis.s = this.val = parseFloat(curVal);\n\t\tthis.u = _getUnit(curVal) || 0;\n\t\tthis.vel = velocity || 0;\n\t\tthis.v = this.vel / stepsPerTimeUnit;\n\t\tif (acceleration || acceleration === 0) {\n\t\t\tthis.acc = acceleration;\n\t\t\tthis.a = this.acc / (stepsPerTimeUnit * stepsPerTimeUnit);\n\t\t} else {\n\t\t\tthis.acc = this.a = 0;\n\t\t}\n\t\tthis.fr = 1 - (friction || 0) ;\n\t}\n\n}\n\n\nexport const PhysicsPropsPlugin = {\n\tversion:\"3.14.2\",\n\tname:\"physicsProps\",\n\tregister: _initCore,\n\tinit(target, value, tween) {\n\t\t_coreInitted || _initCore();\n\t\tlet data = this,\n\t\t\tp;\n\t\tdata.styles = _getStyleSaver && _getStyleSaver(target);\n\t\tdata.target = target;\n\t\tdata.tween = tween;\n\t\tdata.step = 0;\n\t\tdata.sps = 30; //steps per second\n\t\tdata.vProps = [];\n\t\tfor (p in value) {\n\t\t\tlet { velocity, acceleration, friction } = value[p];\n\t\t\tif (velocity || acceleration) {\n\t\t\t\tdata.vProps.push(new PhysicsProp(target, p, velocity, acceleration, friction, data.sps));\n\t\t\t\tdata._props.push(p);\n\t\t\t\t_getStyleSaver && data.styles.save(p);\n\t\t\t\tfriction && (data.hasFr = 1);\n\t\t\t}\n\t\t}\n\t},\n\trender(ratio, data) {\n\t\tlet { vProps, tween, target, step, hasFr, sps } = data,\n\t\t\ti = vProps.length,\n\t\t\ttime = tween._from ? tween._dur - tween._time : tween._time,\n\t\t\tcurProp, steps, remainder, j, tt;\n\t\tif (tween._time || !_reverting()) {\n\t\t\tif (hasFr) {\n\t\t\t\ttime *= sps;\n\t\t\t\tsteps = (time | 0) - step;\n\t\t\t\t/*\n\t\t\t\tNote: rounding errors build up if we walk the calculations backward which we used to do like this to maximize performance:\n\t\t\t\twhile (i--) {\n\t\t\t\t\tcurProp = vProps[i];\n\t\t\t\t\tj = -steps;\n\t\t\t\t\twhile (j--) {\n\t\t\t\t\t\tcurProp.val -= curProp.v;\n\t\t\t\t\t\tcurProp.v /= curProp.fr;\n\t\t\t\t\t\tcurProp.v -= curProp.a;\n\t\t\t\t\t}\n\t\t\t\t\tcurProp.set(target, curProp.p, _round(curProp.val + (curProp.v * remainder * curProp.fr)) + curProp.u);\n\t\t\t\t}\n\t\t\t\tbut now for the sake of accuracy (to ensure rewinding always goes back to EXACTLY the same spot), we force the calculations to go forward every time. So if the tween is going backward, we just start from the beginning and iterate. This is only necessary with friction.\n\t\t\t\t */\n\t\t\t\tif (steps < 0) {\n\t\t\t\t\twhile (i--) {\n\t\t\t\t\t\tcurProp = vProps[i];\n\t\t\t\t\t\tcurProp.v = curProp.vel / sps;\n\t\t\t\t\t\tcurProp.val = curProp.s;\n\t\t\t\t\t}\n\t\t\t\t\ti = vProps.length;\n\t\t\t\t\tdata.step = step = 0;\n\t\t\t\t\tsteps = time | 0;\n\t\t\t\t}\n\t\t\t\tremainder = time % 1;\n\t\t\t\twhile (i--) {\n\t\t\t\t\tcurProp = vProps[i];\n\t\t\t\t\tj = steps;\n\t\t\t\t\twhile (j--) {\n\t\t\t\t\t\tcurProp.v += curProp.a;\n\t\t\t\t\t\tcurProp.v *= curProp.fr;\n\t\t\t\t\t\tcurProp.val += curProp.v;\n\t\t\t\t\t}\n\t\t\t\t\tcurProp.set(target, curProp.p, _round(curProp.val + (curProp.v * remainder * curProp.fr)) + curProp.u);\n\t\t\t\t}\n\t\t\t\tdata.step += steps;\n\n\t\t\t} else {\n\t\t\t\ttt = time * time * 0.5;\n\t\t\t\twhile (i--) {\n\t\t\t\t\tcurProp = vProps[i];\n\t\t\t\t\tcurProp.set(target, curProp.p, _round(curProp.s + curProp.vel * time + curProp.acc * tt) + curProp.u);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tdata.styles.revert();\n\t\t}\n\t},\n\tkill(property) {\n\t\tlet vProps = this.vProps,\n\t\t\ti = vProps.length;\n\t\twhile (i--) {\n\t\t\tvProps[i].p === property && vProps.splice(i, 1);\n\t\t}\n\t}\n};\n\n\n_getGSAP() && gsap.registerPlugin(PhysicsPropsPlugin);\n\nexport { PhysicsPropsPlugin as default };"],"names":["_getGSAP","gsap","window","registerPlugin","_round","value","Math","round","_initCore","core","_coreInitted","_getUnit","utils","getUnit","_getStyleSaver","getStyleSaver","_reverting","reverting","PhysicsProp","target","p","velocity","acceleration","friLine truncated
|
||||
+474
@@ -0,0 +1,474 @@
|
||||
(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';
|
||||
|
||||
/*!
|
||||
* PixiPlugin 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 gsap,
|
||||
_splitColor,
|
||||
_coreInitted,
|
||||
_PIXI,
|
||||
PropTween,
|
||||
_getSetter,
|
||||
_isV4,
|
||||
_isV8Plus,
|
||||
_windowExists = function _windowExists() {
|
||||
return typeof window !== "undefined";
|
||||
},
|
||||
_getGSAP = function _getGSAP() {
|
||||
return gsap || _windowExists() && (gsap = window.gsap) && gsap.registerPlugin && gsap;
|
||||
},
|
||||
_isFunction = function _isFunction(value) {
|
||||
return typeof value === "function";
|
||||
},
|
||||
_warn = function _warn(message) {
|
||||
return console.warn(message);
|
||||
},
|
||||
_idMatrix = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0],
|
||||
_lumR = 0.212671,
|
||||
_lumG = 0.715160,
|
||||
_lumB = 0.072169,
|
||||
_filterClass = function _filterClass(name) {
|
||||
return _isFunction(_PIXI[name]) ? _PIXI[name] : _PIXI.filters[name];
|
||||
},
|
||||
_applyMatrix = function _applyMatrix(m, m2) {
|
||||
var temp = [],
|
||||
i = 0,
|
||||
z = 0,
|
||||
y,
|
||||
x;
|
||||
|
||||
for (y = 0; y < 4; y++) {
|
||||
for (x = 0; x < 5; x++) {
|
||||
z = x === 4 ? m[i + 4] : 0;
|
||||
temp[i + x] = m[i] * m2[x] + m[i + 1] * m2[x + 5] + m[i + 2] * m2[x + 10] + m[i + 3] * m2[x + 15] + z;
|
||||
}
|
||||
|
||||
i += 5;
|
||||
}
|
||||
|
||||
return temp;
|
||||
},
|
||||
_setSaturation = function _setSaturation(m, n) {
|
||||
var inv = 1 - n,
|
||||
r = inv * _lumR,
|
||||
g = inv * _lumG,
|
||||
b = inv * _lumB;
|
||||
return _applyMatrix([r + n, g, b, 0, 0, r, g + n, b, 0, 0, r, g, b + n, 0, 0, 0, 0, 0, 1, 0], m);
|
||||
},
|
||||
_colorize = function _colorize(m, color, amount) {
|
||||
var c = _splitColor(color),
|
||||
r = c[0] / 255,
|
||||
g = c[1] / 255,
|
||||
b = c[2] / 255,
|
||||
inv = 1 - amount;
|
||||
|
||||
return _applyMatrix([inv + amount * r * _lumR, amount * r * _lumG, amount * r * _lumB, 0, 0, amount * g * _lumR, inv + amount * g * _lumG, amount * g * _lumB, 0, 0, amount * b * _lumR, amount * b * _lumG, inv + amount * b * _lumB, 0, 0, 0, 0, 0, 1, 0], m);
|
||||
},
|
||||
_setHue = function _setHue(m, n) {
|
||||
n *= Math.PI / 180;
|
||||
var c = Math.cos(n),
|
||||
s = Math.sin(n);
|
||||
return _applyMatrix([_lumR + c * (1 - _lumR) + s * -_lumR, _lumG + c * -_lumG + s * -_lumG, _lumB + c * -_lumB + s * (1 - _lumB), 0, 0, _lumR + c * -_lumR + s * 0.143, _lumG + c * (1 - _lumG) + s * 0.14, _lumB + c * -_lumB + s * -0.283, 0, 0, _lumR + c * -_lumR + s * -(1 - _lumR), _lumG + c * -_lumG + s * _lumG, _lumB + c * (1 - _lumB) + s * _lumB, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1], m);
|
||||
},
|
||||
_setContrast = function _setContrast(m, n) {
|
||||
return _applyMatrix([n, 0, 0, 0, 0.5 * (1 - n), 0, n, 0, 0, 0.5 * (1 - n), 0, 0, n, 0, 0.5 * (1 - n), 0, 0, 0, 1, 0], m);
|
||||
},
|
||||
_getFilter = function _getFilter(target, type) {
|
||||
var filterClass = _filterClass(type),
|
||||
filters = target.filters || [],
|
||||
i = filters.length,
|
||||
filter;
|
||||
|
||||
filterClass || _warn(type + " not found. PixiPlugin.registerPIXI(PIXI)");
|
||||
|
||||
while (--i > -1) {
|
||||
if (filters[i] instanceof filterClass) {
|
||||
return filters[i];
|
||||
}
|
||||
}
|
||||
|
||||
filter = new filterClass();
|
||||
|
||||
if (type === "BlurFilter") {
|
||||
if (_isV8Plus) {
|
||||
filter.strength = 0;
|
||||
} else {
|
||||
filter.blur = 0;
|
||||
}
|
||||
}
|
||||
|
||||
target.filters = [].concat(filters, [filter]);
|
||||
return filter;
|
||||
},
|
||||
_addColorMatrixFilterCacheTween = function _addColorMatrixFilterCacheTween(p, plugin, cache, vars) {
|
||||
plugin.add(cache, p, cache[p], vars[p]);
|
||||
|
||||
plugin._props.push(p);
|
||||
},
|
||||
_applyBrightnessToMatrix = function _applyBrightnessToMatrix(brightness, matrix) {
|
||||
var filterClass = _filterClass("ColorMatrixFilter"),
|
||||
temp = new filterClass();
|
||||
|
||||
temp.matrix = matrix;
|
||||
temp.brightness(brightness, true);
|
||||
return temp.matrix;
|
||||
},
|
||||
_copy = function _copy(obj) {
|
||||
var copy = {},
|
||||
p;
|
||||
|
||||
for (p in obj) {
|
||||
copy[p] = obj[p];
|
||||
}
|
||||
|
||||
return copy;
|
||||
},
|
||||
_CMFdefaults = {
|
||||
contrast: 1,
|
||||
saturation: 1,
|
||||
colorizeAmount: 0,
|
||||
colorize: "rgb(255,255,255)",
|
||||
hue: 0,
|
||||
brightness: 1
|
||||
},
|
||||
_parseColorMatrixFilter = function _parseColorMatrixFilter(target, v, pg) {
|
||||
var filter = _getFilter(target, "ColorMatrixFilter"),
|
||||
cache = target._gsColorMatrixFilter = target._gsColorMatrixFilter || _copy(_CMFdefaults),
|
||||
combine = v.combineCMF && !("colorMatrixFilter" in v && !v.colorMatrixFilter),
|
||||
i,
|
||||
matrix,
|
||||
startMatrix;
|
||||
|
||||
startMatrix = filter.matrix;
|
||||
|
||||
if (v.resolution) {
|
||||
filter.resolution = v.resolution;
|
||||
}
|
||||
|
||||
if (v.matrix && v.matrix.length === startMatrix.length) {
|
||||
matrix = v.matrix;
|
||||
|
||||
if (cache.contrast !== 1) {
|
||||
_addColorMatrixFilterCacheTween("contrast", pg, cache, _CMFdefaults);
|
||||
}
|
||||
|
||||
if (cache.hue) {
|
||||
_addColorMatrixFilterCacheTween("hue", pg, cache, _CMFdefaults);
|
||||
}
|
||||
|
||||
if (cache.brightness !== 1) {
|
||||
_addColorMatrixFilterCacheTween("brightness", pg, cache, _CMFdefaults);
|
||||
}
|
||||
|
||||
if (cache.colorizeAmount) {
|
||||
_addColorMatrixFilterCacheTween("colorize", pg, cache, _CMFdefaults);
|
||||
|
||||
_addColorMatrixFilterCacheTween("colorizeAmount", pg, cache, _CMFdefaults);
|
||||
}
|
||||
|
||||
if (cache.saturation !== 1) {
|
||||
_addColorMatrixFilterCacheTween("saturation", pg, cache, _CMFdefaults);
|
||||
}
|
||||
} else {
|
||||
matrix = _idMatrix.slice();
|
||||
|
||||
if (v.contrast != null) {
|
||||
matrix = _setContrast(matrix, +v.contrast);
|
||||
|
||||
_addColorMatrixFilterCacheTween("contrast", pg, cache, v);
|
||||
} else if (cache.contrast !== 1) {
|
||||
if (combine) {
|
||||
matrix = _setContrast(matrix, cache.contrast);
|
||||
} else {
|
||||
_addColorMatrixFilterCacheTween("contrast", pg, cache, _CMFdefaults);
|
||||
}
|
||||
}
|
||||
|
||||
if (v.hue != null) {
|
||||
matrix = _setHue(matrix, +v.hue);
|
||||
|
||||
_addColorMatrixFilterCacheTween("hue", pg, cache, v);
|
||||
} else if (cache.hue) {
|
||||
if (combine) {
|
||||
matrix = _setHue(matrix, cache.hue);
|
||||
} else {
|
||||
_addColorMatrixFilterCacheTween("hue", pg, cache, _CMFdefaults);
|
||||
}
|
||||
}
|
||||
|
||||
if (v.brightness != null) {
|
||||
matrix = _applyBrightnessToMatrix(+v.brightness, matrix);
|
||||
|
||||
_addColorMatrixFilterCacheTween("brightness", pg, cache, v);
|
||||
} else if (cache.brightness !== 1) {
|
||||
if (combine) {
|
||||
matrix = _applyBrightnessToMatrix(cache.brightness, matrix);
|
||||
} else {
|
||||
_addColorMatrixFilterCacheTween("brightness", pg, cache, _CMFdefaults);
|
||||
}
|
||||
}
|
||||
|
||||
if (v.colorize != null) {
|
||||
v.colorizeAmount = "colorizeAmount" in v ? +v.colorizeAmount : 1;
|
||||
matrix = _colorize(matrix, v.colorize, v.colorizeAmount);
|
||||
|
||||
_addColorMatrixFilterCacheTween("colorize", pg, cache, v);
|
||||
|
||||
_addColorMatrixFilterCacheTween("colorizeAmount", pg, cache, v);
|
||||
} else if (cache.colorizeAmount) {
|
||||
if (combine) {
|
||||
matrix = _colorize(matrix, cache.colorize, cache.colorizeAmount);
|
||||
} else {
|
||||
_addColorMatrixFilterCacheTween("colorize", pg, cache, _CMFdefaults);
|
||||
|
||||
_addColorMatrixFilterCacheTween("colorizeAmount", pg, cache, _CMFdefaults);
|
||||
}
|
||||
}
|
||||
|
||||
if (v.saturation != null) {
|
||||
matrix = _setSaturation(matrix, +v.saturation);
|
||||
|
||||
_addColorMatrixFilterCacheTween("saturation", pg, cache, v);
|
||||
} else if (cache.saturation !== 1) {
|
||||
if (combine) {
|
||||
matrix = _setSaturation(matrix, cache.saturation);
|
||||
} else {
|
||||
_addColorMatrixFilterCacheTween("saturation", pg, cache, _CMFdefaults);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
i = matrix.length;
|
||||
|
||||
while (--i > -1) {
|
||||
if (matrix[i] !== startMatrix[i]) {
|
||||
pg.add(startMatrix, i, startMatrix[i], matrix[i], "colorMatrixFilter");
|
||||
}
|
||||
}
|
||||
|
||||
pg._props.push("colorMatrixFilter");
|
||||
},
|
||||
_renderColor = function _renderColor(ratio, _ref) {
|
||||
var t = _ref.t,
|
||||
p = _ref.p,
|
||||
color = _ref.color,
|
||||
set = _ref.set;
|
||||
set(t, p, color[0] << 16 | color[1] << 8 | color[2]);
|
||||
},
|
||||
_renderDirtyCache = function _renderDirtyCache(ratio, _ref2) {
|
||||
var g = _ref2.g;
|
||||
|
||||
if (_isV8Plus) {
|
||||
g.fill();
|
||||
g.stroke();
|
||||
} else if (g) {
|
||||
g.dirty++;
|
||||
g.clearDirty++;
|
||||
}
|
||||
},
|
||||
_renderAutoAlpha = function _renderAutoAlpha(ratio, data) {
|
||||
data.t.visible = !!data.t.alpha;
|
||||
},
|
||||
_addColorTween = function _addColorTween(target, p, value, plugin) {
|
||||
var currentValue = target[p],
|
||||
startColor = _splitColor(_isFunction(currentValue) ? target[p.indexOf("set") || !_isFunction(target["get" + p.substr(3)]) ? p : "get" + p.substr(3)]() : currentValue),
|
||||
endColor = _splitColor(value);
|
||||
|
||||
plugin._pt = new PropTween(plugin._pt, target, p, 0, 0, _renderColor, {
|
||||
t: target,
|
||||
p: p,
|
||||
color: startColor,
|
||||
set: _getSetter(target, p)
|
||||
});
|
||||
plugin.add(startColor, 0, startColor[0], endColor[0]);
|
||||
plugin.add(startColor, 1, startColor[1], endColor[1]);
|
||||
plugin.add(startColor, 2, startColor[2], endColor[2]);
|
||||
},
|
||||
_colorProps = {
|
||||
tint: 1,
|
||||
lineColor: 1,
|
||||
fillColor: 1,
|
||||
strokeColor: 1
|
||||
},
|
||||
_xyContexts = "position,scale,skew,pivot,anchor,tilePosition,tileScale".split(","),
|
||||
_contexts = {
|
||||
x: "position",
|
||||
y: "position",
|
||||
tileX: "tilePosition",
|
||||
tileY: "tilePosition"
|
||||
},
|
||||
_colorMatrixFilterProps = {
|
||||
colorMatrixFilter: 1,
|
||||
saturation: 1,
|
||||
contrast: 1,
|
||||
hue: 1,
|
||||
colorize: 1,
|
||||
colorizeAmount: 1,
|
||||
brightness: 1,
|
||||
combineCMF: 1
|
||||
},
|
||||
_DEG2RAD = Math.PI / 180,
|
||||
_isString = function _isString(value) {
|
||||
return typeof value === "string";
|
||||
},
|
||||
_degreesToRadians = function _degreesToRadians(value) {
|
||||
return _isString(value) && value.charAt(1) === "=" ? value.substr(0, 2) + parseFloat(value.substr(2)) * _DEG2RAD : value * _DEG2RAD;
|
||||
},
|
||||
_renderPropWithEnd = function _renderPropWithEnd(ratio, data) {
|
||||
return data.set(data.t, data.p, ratio === 1 ? data.e : Math.round((data.s + data.c * ratio) * 100000) / 100000, data);
|
||||
},
|
||||
_addRotationalPropTween = function _addRotationalPropTween(plugin, target, property, startNum, endValue, radians) {
|
||||
var cap = 360 * (radians ? _DEG2RAD : 1),
|
||||
isString = _isString(endValue),
|
||||
relative = isString && endValue.charAt(1) === "=" ? +(endValue.charAt(0) + "1") : 0,
|
||||
endNum = parseFloat(relative ? endValue.substr(2) : endValue) * (radians ? _DEG2RAD : 1),
|
||||
change = relative ? endNum * relative : endNum - startNum,
|
||||
finalValue = startNum + change,
|
||||
direction,
|
||||
pt;
|
||||
|
||||
if (isString) {
|
||||
direction = endValue.split("_")[1];
|
||||
|
||||
if (direction === "short") {
|
||||
change %= cap;
|
||||
|
||||
if (change !== change % (cap / 2)) {
|
||||
change += change < 0 ? cap : -cap;
|
||||
}
|
||||
}
|
||||
|
||||
if (direction === "cw" && change < 0) {
|
||||
change = (change + cap * 1e10) % cap - ~~(change / cap) * cap;
|
||||
} else if (direction === "ccw" && change > 0) {
|
||||
change = (change - cap * 1e10) % cap - ~~(change / cap) * cap;
|
||||
}
|
||||
}
|
||||
|
||||
plugin._pt = pt = new PropTween(plugin._pt, target, property, startNum, change, _renderPropWithEnd);
|
||||
pt.e = finalValue;
|
||||
return pt;
|
||||
},
|
||||
_initCore = function _initCore() {
|
||||
if (!_coreInitted) {
|
||||
gsap = _getGSAP();
|
||||
_PIXI = _coreInitted = _PIXI || _windowExists() && window.PIXI;
|
||||
var version = _PIXI && _PIXI.VERSION && parseFloat(_PIXI.VERSION.split(".")[0]) || 0;
|
||||
_isV4 = version === 4;
|
||||
_isV8Plus = version >= 8;
|
||||
|
||||
_splitColor = function _splitColor(color) {
|
||||
return gsap.utils.splitColor((color + "").substr(0, 2) === "0x" ? "#" + color.substr(2) : color);
|
||||
};
|
||||
}
|
||||
},
|
||||
i,
|
||||
p;
|
||||
|
||||
for (i = 0; i < _xyContexts.length; i++) {
|
||||
p = _xyContexts[i];
|
||||
_contexts[p + "X"] = p;
|
||||
_contexts[p + "Y"] = p;
|
||||
}
|
||||
|
||||
var PixiPlugin = {
|
||||
version: "3.14.2",
|
||||
name: "pixi",
|
||||
register: function register(core, Plugin, propTween) {
|
||||
gsap = core;
|
||||
PropTween = propTween;
|
||||
_getSetter = Plugin.getSetter;
|
||||
|
||||
_initCore();
|
||||
},
|
||||
headless: true,
|
||||
registerPIXI: function registerPIXI(pixi) {
|
||||
_PIXI = pixi;
|
||||
},
|
||||
init: function init(target, values, tween, index, targets) {
|
||||
_PIXI || _initCore();
|
||||
|
||||
if (!_PIXI) {
|
||||
_warn("PIXI was not found. PixiPlugin.registerPIXI(PIXI);");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
var context, axis, value, colorMatrix, filter, p, padding, i, data, subProp;
|
||||
|
||||
for (p in values) {
|
||||
context = _contexts[p];
|
||||
value = values[p];
|
||||
|
||||
if (context) {
|
||||
axis = ~p.charAt(p.length - 1).toLowerCase().indexOf("x") ? "x" : "y";
|
||||
this.add(target[context], axis, target[context][axis], context === "skew" ? _degreesToRadians(value) : value, 0, 0, 0, 0, 0, 1);
|
||||
} else if (p === "scale" || p === "anchor" || p === "pivot" || p === "tileScale") {
|
||||
this.add(target[p], "x", target[p].x, value);
|
||||
this.add(target[p], "y", target[p].y, value);
|
||||
} else if (p === "rotation" || p === "angle") {
|
||||
_addRotationalPropTween(this, target, p, target[p], value, p === "rotation");
|
||||
} else if (_colorMatrixFilterProps[p]) {
|
||||
if (!colorMatrix) {
|
||||
_parseColorMatrixFilter(target, values.colorMatrixFilter || values, this);
|
||||
|
||||
colorMatrix = true;
|
||||
}
|
||||
} else if (p === "blur" || p === "blurX" || p === "blurY" || p === "blurPadding") {
|
||||
filter = _getFilter(target, "BlurFilter");
|
||||
this.add(filter, p, filter[p], value);
|
||||
|
||||
if (values.blurPadding !== 0) {
|
||||
padding = values.blurPadding || Math.max(filter[p], value) * 2;
|
||||
i = target.filters.length;
|
||||
|
||||
while (--i > -1) {
|
||||
target.filters[i].padding = Math.max(target.filters[i].padding, padding);
|
||||
}
|
||||
}
|
||||
} else if (_colorProps[p]) {
|
||||
if ((p === "lineColor" || p === "fillColor" || p === "strokeColor") && target instanceof _PIXI.Graphics) {
|
||||
data = "fillStyle" in target ? [target] : (target.geometry || target).graphicsData;
|
||||
subProp = p.substr(0, p.length - 5);
|
||||
_isV8Plus && subProp === "line" && (subProp = "stroke");
|
||||
this._pt = new PropTween(this._pt, target, p, 0, 0, _renderDirtyCache, {
|
||||
g: target.geometry || target
|
||||
});
|
||||
i = data.length;
|
||||
|
||||
while (--i > -1) {
|
||||
_addColorTween(_isV4 ? data[i] : data[i][subProp + "Style"], _isV4 ? p : "color", value, this);
|
||||
}
|
||||
} else {
|
||||
_addColorTween(target, p, value, this);
|
||||
}
|
||||
} else if (p === "autoAlpha") {
|
||||
this._pt = new PropTween(this._pt, target, "visible", 0, 0, _renderAutoAlpha);
|
||||
this.add(target, "alpha", target.alpha, value);
|
||||
|
||||
this._props.push("alpha", "visible");
|
||||
} else if (p !== "resolution") {
|
||||
this.add(target, p, "get", value);
|
||||
}
|
||||
|
||||
this._props.push(p);
|
||||
}
|
||||
}
|
||||
};
|
||||
_getGSAP() && gsap.registerPlugin(PixiPlugin);
|
||||
|
||||
exports.PixiPlugin = PixiPlugin;
|
||||
exports.default = PixiPlugin;
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
})));
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
/*!
|
||||
* PixiPlugin 3.14.2
|
||||
* https://gsap.com
|
||||
*
|
||||
* @license Copyright 2025, GreenSock. All rights reserved.
|
||||
* Subject to the terms at https://gsap.com/standard-license.
|
||||
* @author: Jack Doyle, jack@greensock.com
|
||||
*/
|
||||
|
||||
!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((t=t||self).window=t.window||{})}(this,function(r){"use strict";function l(){return"undefined"!=typeof window}function m(){return e||l()&&(e=window.gsap)&&e.registerPlugin&&e}function n(t){return"function"==typeof t}function o(t){return console.warn(t)}function t(t){return n(p[t])?p[t]:p.filters[t]}function u(t,r){var i,o,e=[],n=0,s=0;for(i=0;i<4;i++){for(o=0;o<5;o++)s=4===o?t[n+4]:0,e[n+o]=t[n]*r[o]+t[n+1]*r[o+5]+t[n+2]*r[o+10]+t[n+3]*r[o+15]+s;n+=5}return e}function v(t,r){var i=1-r,o=i*M,e=i*_,n=i*C;return u([o+r,e,n,0,0,o,e+r,n,0,0,o,e,n+r,0,0,0,0,0,1,0],t)}function w(t,r,i){var o=a(r),e=o[0]/255,n=o[1]/255,s=o[2]/255,l=1-i;return u([l+i*e*M,i*e*_,i*e*C,0,0,i*n*M,l+i*n*_,i*n*C,0,0,i*s*M,i*s*_,l+i*s*C,0,0,0,0,0,1,0],t)}function x(t,r){r*=Math.PI/180;var i=Math.cos(r),o=Math.sin(r);return u([M+i*(1-M)+o*-M,_+i*-_+o*-_,C+i*-C+o*(1-C),0,0,M+i*-M+.143*o,_+i*(1-_)+.14*o,C+i*-C+-.283*o,0,0,M+i*-M+o*-(1-M),_+i*-_+o*_,C+i*(1-C)+o*C,0,0,0,0,0,1,0,0,0,0,0,1],t)}function y(t,r){return u([r,0,0,0,.5*(1-r),0,r,0,0,.5*(1-r),0,0,r,0,.5*(1-r),0,0,0,1,0],t)}function z(r,i){var e,n=t(i),s=r.filters||[],l=s.length;for(n||o(i+" not found. PixiPlugin.registerPIXI(PIXI)");-1<--l;)if(s[l]instanceof n)return s[l];return e=new n,"BlurFilter"===i&&(b?e.strength=0:e.blur=0),r.filters=[].concat(s,[e]),e}function A(t,r,i,o){r.add(i,t,i[t],o[t]),r._props.push(t)}function B(r,i){var o=new(t("ColorMatrixFilter"));return o.matrix=i,o.brightness(r,!0),o.matrix}function E(t,r,i){var o,e,n,s=z(t,"ColorMatrixFilter"),l=t._gsColorMatrixFilter=t._gsColorMatrixFilter||function _copy(t){var r,i={};for(r in t)i[r]=t[r];return i}(X),u=r.combineCMF&&!("colorMatrixFilter"in r&&!r.colorMatrixFilter);n=s.matrix,r.resolution&&(s.resolution=r.resolution),r.matrix&&r.matrix.length===n.length?(e=r.matrix,1!==l.contrast&&A("contrast",i,l,X),l.hue&&A("hue",i,l,X),1!==l.brightness&&A("brightness",i,l,X),l.colorizeAmount&&(A("colorize",i,l,X),A("colorizeAmount",i,l,X)),1!==l.saturation&&A("saturation",i,l,X)):(e=h.slice(),null!=r.contrast?(e=y(e,+r.contrast),A("contrast",i,l,r)):1!==l.contrast&&(u?e=y(e,l.contrast):A("contrast",i,l,X)),null!=r.hue?(e=x(e,+r.hue),A("hue",i,l,r)):l.hue&&(u?e=x(e,l.hue):A("hue",i,l,X)),null!=r.brightness?(e=B(+r.brightness,e),A("brightness",i,l,r)):1!==l.brightness&&(u?e=B(l.brightness,e):A("brightness",i,l,X)),null!=r.colorize?(r.colorizeAmount="colorizeAmount"in r?+r.colorizeAmount:1,e=w(e,r.colorize,r.colorizeAmount),A("colorize",i,l,r),A("colorizeAmount",i,l,r)):l.colorizeAmount&&(u?e=w(e,l.colorize,l.colorizeAmount):(A("colorize",i,l,X),A("colorizeAmount",i,l,X))),null!=r.saturation?(e=v(e,+r.saturation),A("saturation",i,l,r)):1!==l.saturation&&(u?e=v(e,l.saturation):A("saturation",i,l,X))),o=e.length;for(;-1<--o;)e[o]!==n[o]&&i.add(n,o,n[o],e[o],"colorMatrixFilter");i._props.push("colorMatrixFilter")}function F(t,r){var i=r.t,o=r.p,e=r.color;(0,r.set)(i,o,e[0]<<16|e[1]<<8|e[2])}function G(t,r){var i=r.g;b?(i.fill(),i.stroke()):i&&(i.dirty++,i.clearDirty++)}function H(t,r){r.t.visible=!!r.t.alpha}function I(t,r,i,o){var e=t[r],s=a(n(e)?t[r.indexOf("set")||!n(t["get"+r.substr(3)])?r:"get"+r.substr(3)]():e),l=a(i);o._pt=new d(o._pt,t,r,0,0,F,{t:t,p:r,color:s,set:c(t,r)}),o.add(s,0,s[0],l[0]),o.add(s,1,s[1],l[1]),o.add(s,2,s[2],l[2])}function O(t){return"string"==typeof t}function P(t){return O(t)&&"="===t.charAt(1)?t.substr(0,2)+parseFloat(t.substr(2))*N:t*N}function Q(t,r){return r.set(r.t,r.p,1===t?r.e:Math.round(1e5*(r.s+r.c*t))/1e5,r)}function R(t,r,i,o,e,n){var s,l,u=360*(n?N:1),a=O(e),c=a&&"="===e.charAt(1)?+(e.charAt(0)+"1"):0,f=parseFloat(c?e.substr(2):e)*(n?N:1),h=c?f*c:f-o,p=o+h;return a&&("short"===(s=e.split("_")[1])&&(h%=u)!==h%(u/2)&&(h+=h<0?u:-u),"cw"===s&&h<0?h=(h+1e10*u)%u-~~(h/u)*u:"ccw"===s&&0<h&&(h=(h-1e10*u)%u-~~(h/u)*u)),t._pt=l=new d(t._pt,r,i,o,h,Q),l.e=p,l}function S(){if(!i){e=m();var t=(p=i=p||l()&&window.PIXI)&&p.VERSION&&parseFloat(p.VERSION.split(".")[0])||0;g=4===t,b=8<=t,a=function _splitColor(t){return e.utils.splitColor("0x"===(t+"").substr(0,2)?"#"+t.substr(2):t)}}}var e,a,i,p,d,c,g,b,s,f,h=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],M=.212671,_=.71516,C=.072169,X={contrast:1,saturation:1,colorizeAmount:0,colorize:"rgb(255,255,255)",hue:0,brightness:1},k={tint:1,lineColor:1,fillColor:1,strokeColor:1},Y="position,scale,skew,pivot,anchor,tilePosition,tileScale".split(","),j={x:"position",y:"position",tileX:"tilePosition",tileY:"tilePosition"},D={colorMatrixFilter:1,saturation:1,contrast:1,hue:1,colorize:1,colorizeAmount:1,brightness:1,combineCMF:1},N=Math.PI/180;for(s=0;s<Y.length;s++)f=Y[s],j[f+"X"]=f,j[f+"Y"]=f;var V={version:"3.14.2",name:"pixi",register:function register(t,r,i){e=t,d=i,c=r.getSetter,S()},headless:!0,registerPIXI:function registerPIXI(t){p=t},init:function init(t,r){if(p||S(),!p)return o("PIXI was not found. PixiPlugin.registerPIXI(PIXLine truncated
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"PixiPlugin.min.js","sources":["../src/PixiPlugin.js"],"sourcesContent":["/*!\n * PixiPlugin 3.14.2\n * https://gsap.com\n *\n * @license Copyright 2008-2025, GreenSock. All rights reserved.\n * Subject to the terms at https://gsap.com/standard-license\n * @author: Jack Doyle, jack@greensock.com\n*/\n/* eslint-disable */\n\nlet gsap, _splitColor, _coreInitted, _PIXI, PropTween, _getSetter, _isV4, _isV8Plus,\n\t_windowExists = () => typeof(window) !== \"undefined\",\n\t_getGSAP = () => gsap || (_windowExists() && (gsap = window.gsap) && gsap.registerPlugin && gsap),\n\t_isFunction = value => typeof(value) === \"function\",\n\t_warn = message => console.warn(message),\n\t_idMatrix = [1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],\n\t_lumR = 0.212671,\n\t_lumG = 0.715160,\n\t_lumB = 0.072169,\n\t_filterClass = name => _isFunction(_PIXI[name]) ? _PIXI[name] : _PIXI.filters[name], // in PIXI 7.1, filters moved from PIXI.filters to just PIXI\n\t_applyMatrix = (m, m2) => {\n\t\tlet temp = [],\n\t\t\ti = 0,\n\t\t\tz = 0,\n\t\t\ty, x;\n\t\tfor (y = 0; y < 4; y++) {\n\t\t\tfor (x = 0; x < 5; x++) {\n\t\t\t\tz = (x === 4) ? m[i + 4] : 0;\n\t\t\t\ttemp[i + x] = m[i] * m2[x] + m[i+1] * m2[x + 5] +\tm[i+2] * m2[x + 10] + m[i+3] * m2[x + 15] +\tz;\n\t\t\t}\n\t\t\ti += 5;\n\t\t}\n\t\treturn temp;\n\t},\n\t_setSaturation = (m, n) => {\n\t\tlet inv = 1 - n,\n\t\t\tr = inv * _lumR,\n\t\t\tg = inv * _lumG,\n\t\t\tb = inv * _lumB;\n\t\treturn _applyMatrix([r + n, g, b, 0, 0, r, g + n, b, 0, 0, r, g, b + n, 0, 0, 0, 0, 0, 1, 0], m);\n\t},\n\t_colorize = (m, color, amount) => {\n\t\tlet c = _splitColor(color),\n\t\t\tr = c[0] / 255,\n\t\t\tg = c[1] / 255,\n\t\t\tb = c[2] / 255,\n\t\t\tinv = 1 - amount;\n\t\treturn _applyMatrix([inv + amount * r * _lumR, amount * r * _lumG, amount * r * _lumB, 0, 0, amount * g * _lumR, inv + amount * g * _lumG, amount * g * _lumB, 0, 0, amount * b * _lumR, amount * b * _lumG, inv + amount * b * _lumB, 0, 0, 0, 0, 0, 1, 0], m);\n\t},\n\t_setHue = (m, n) => {\n\t\tn *= Math.PI / 180;\n\t\tlet c = Math.cos(n),\n\t\t\ts = Math.sin(n);\n\t\treturn _applyMatrix([(_lumR + (c * (1 - _lumR))) + (s * (-_lumR)), (_lumG + (c * (-_lumG))) + (s * (-_lumG)), (_lumB + (c * (-_lumB))) + (s * (1 - _lumB)), 0, 0, (_lumR + (c * (-_lumR))) + (s * 0.143), (_lumG + (c * (1 - _lumG))) + (s * 0.14), (_lumB + (c * (-_lumB))) + (s * -0.283), 0, 0, (_lumR + (c * (-_lumR))) + (s * (-(1 - _lumR))), (_lumG + (c * (-_lumG))) + (s * _lumG), (_lumB + (c * (1 - _lumB))) + (s * _lumB), 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1], m);\n\t},\n\t_setContrast = (m, n) => _applyMatrix([n,0,0,0,0.5 * (1 - n), 0,n,0,0,0.5 * (1 - n), 0,0,n,0,0.5 * (1 - n), 0,0,0,1,0], m),\n\t_getFilter = (target, type) => {\n\t\tlet filterClass = _filterClass(type),\n\t\t\tfilters = target.filters || [],\n\t\t\ti = filters.length,\n\t\t\tfilter;\n\t\tfilterClass || _warn(type + \" not found. PixiPlugin.registerPIXI(PIXI)\");\n\t\twhile (--i > -1) {\n\t\t\tif (filters[i] instanceof filterClass) {\n\t\t\t\treturn filters[i];\n\t\t\t}\n\t\t}\n\t\tfilter = new filterClass();\n\t\tif (type === \"BlurFilter\") {\n\t\t\tif (_isV8Plus) {\n\t\t\t\tfilter.strength = 0;\n\t\t\t} else {\n\t\t\t\tfilter.blur = 0;\n\t\t\t}\n\t\t}\n\t\ttarget.filters = [...filters, filter];\n\t\treturn filter;\n\t},\n\t_addColorMatrixFilterCacheTween = (p, plugin, cache, vars) => { //we cache the ColorMatrixFilter components in a _gsColorMatrixFilter object attached to the target object so that it's easy to grab the current value at any time.\n\t\tplugin.add(cache, p, cache[p], vars[p]);\n\t\tplugin._props.push(p);\n\t},\n\t_applyBrightnessToMatrix = (brightness, matrix) => {\n\t\tlet filterClass = _filterClass(\"ColorMatrixFilter\"),\n\t\t\ttemp = new filterClass();\n\t\ttemp.matrix = matrix;\n\t\ttemp.brightness(brightness, true);\n\t\treturn temp.matrix;\n\t},\n\t_copy = obj => {\n\t\tlet copy = {},\n\t\t\tp;\n\t\tfor (p in obj) {\n\t\t\tcopy[p] = obj[p];\n\t\t}\n\t\treturn copy;\n\t},\n\t_CMFdefaults = {contrast:1, saturation:1, colorizeAmount:0, colorize:\"rgb(255,255,255)\", hue:0, brightness:1},\n\t_parseColorMatrixFilter = (target, v, pg) => {\n\t\tlet filter = _getFilter(target, \"ColorMatrixFilter\"),\n\t\t\tcache = target._gsColorMatrixFilter = target._gsColorMatrixFilter || _copy(_CMFdefaults),\n\t\t\tcombine = v.combineCMF && !(\"colorMatrixFilter\" in v && !v.colorMatrixFilter),\n\t\t\ti, matrix, startMatrix;\n\t\tstartMatrix = filter.matrix;\n\t\tif (v.resolution) {\n\t\t\tfilter.resolution = v.resolution;\n\t\t}\n\t\tif (v.matrix && v.matrix.length === startMatrix.length) {\n\t\t\tmatrix = v.matrix;\n\t\t\tif (cache.contrast !== 1) {\n\t\t\t\t_addColorMatrixFilterCacheTween(\"contrast\", pg, cache, _CMFdefaults);\n\t\t\t}\n\t\t\tif (cache.hue) {\n\t\t\t\t_addColorMatrixFilterCacheTween(\"hue\", pg, cache, _CMFdefaults);\n\t\t\t}\n\t\t\tif (cache.brightness !== 1) {\n\t\t\t\t_addColorMatrixFilterCacheTween(\"brightness\", pg, cache, _CMFdefaults);\n\t\t\t}\n\t\t\tLine truncated
|
||||
+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\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-\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 });
|
||||
|
||||
})));
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
/*!
|
||||
* ScrambleTextPlugin 3.14.2
|
||||
* https://gsap.com
|
||||
*
|
||||
* @license Copyright 2025, GreenSock. All rights reserved.
|
||||
* Subject to the terms at https://gsap.com/standard-license.
|
||||
* @author: Jack Doyle, jack@greensock.com
|
||||
*/
|
||||
|
||||
!function(D,u){"object"==typeof exports&&"undefined"!=typeof module?u(exports):"function"==typeof define&&define.amd?define(["exports"],u):u((D=D||self).window=D.window||{})}(this,function(D){"use strict";var s=/(?:^\s+|\s+$)/g,a=/([\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\uDLine truncated
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ScrambleTextPlugin.min.js","sources":["../src/utils/strings.js","../src/ScrambleTextPlugin.js"],"sourcesContent":["/*!\n * strings: 3.14.2\n * https://gsap.com\n *\n * Copyright 2008-2025, GreenSock. All rights reserved.\n * Subject to the terms at https://gsap.com/standard-license\n * @author: Jack Doyle, jack@greensock.com\n*/\n/* eslint-disable */\n\nlet _trimExp = /(?:^\\s+|\\s+$)/g;\n\nexport 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[Line truncated
|
||||
+973
@@ -0,0 +1,973 @@
|
||||
(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';
|
||||
|
||||
function _defineProperties(target, props) {
|
||||
for (var i = 0; i < props.length; i++) {
|
||||
var descriptor = props[i];
|
||||
descriptor.enumerable = descriptor.enumerable || false;
|
||||
descriptor.configurable = true;
|
||||
if ("value" in descriptor) descriptor.writable = true;
|
||||
Object.defineProperty(target, descriptor.key, descriptor);
|
||||
}
|
||||
}
|
||||
|
||||
function _createClass(Constructor, protoProps, staticProps) {
|
||||
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
||||
if (staticProps) _defineProperties(Constructor, staticProps);
|
||||
return Constructor;
|
||||
}
|
||||
|
||||
/*!
|
||||
* ScrollSmoother 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 gsap,
|
||||
_coreInitted,
|
||||
_win,
|
||||
_doc,
|
||||
_docEl,
|
||||
_body,
|
||||
_toArray,
|
||||
_clamp,
|
||||
ScrollTrigger,
|
||||
_mainInstance,
|
||||
_expo,
|
||||
_getVelocityProp,
|
||||
_inputObserver,
|
||||
_context,
|
||||
_onResizeDelayedCall,
|
||||
_windowExists = function _windowExists() {
|
||||
return typeof window !== "undefined";
|
||||
},
|
||||
_getGSAP = function _getGSAP() {
|
||||
return gsap || _windowExists() && (gsap = window.gsap) && gsap.registerPlugin && gsap;
|
||||
},
|
||||
_round = function _round(value) {
|
||||
return Math.round(value * 100000) / 100000 || 0;
|
||||
},
|
||||
_maxScroll = function _maxScroll(scroller) {
|
||||
return ScrollTrigger.maxScroll(scroller || _win);
|
||||
},
|
||||
_autoDistance = function _autoDistance(el, progress) {
|
||||
var parent = el.parentNode || _docEl,
|
||||
b1 = el.getBoundingClientRect(),
|
||||
b2 = parent.getBoundingClientRect(),
|
||||
gapTop = b2.top - b1.top,
|
||||
gapBottom = b2.bottom - b1.bottom,
|
||||
change = (Math.abs(gapTop) > Math.abs(gapBottom) ? gapTop : gapBottom) / (1 - progress),
|
||||
offset = -change * progress,
|
||||
ratio,
|
||||
extraChange;
|
||||
|
||||
if (change > 0) {
|
||||
ratio = b2.height / (_win.innerHeight + b2.height);
|
||||
extraChange = ratio === 0.5 ? b2.height * 2 : Math.min(b2.height, Math.abs(-change * ratio / (2 * ratio - 1))) * 2 * (progress || 1);
|
||||
offset += progress ? -extraChange * progress : -extraChange / 2;
|
||||
change += extraChange;
|
||||
}
|
||||
|
||||
return {
|
||||
change: change,
|
||||
offset: offset
|
||||
};
|
||||
},
|
||||
_wrap = function _wrap(el) {
|
||||
var wrapper = _doc.querySelector(".ScrollSmoother-wrapper");
|
||||
|
||||
if (!wrapper) {
|
||||
wrapper = _doc.createElement("div");
|
||||
wrapper.classList.add("ScrollSmoother-wrapper");
|
||||
el.parentNode.insertBefore(wrapper, el);
|
||||
wrapper.appendChild(el);
|
||||
}
|
||||
|
||||
return wrapper;
|
||||
};
|
||||
|
||||
var ScrollSmoother = function () {
|
||||
function ScrollSmoother(vars) {
|
||||
var _this = this;
|
||||
|
||||
_coreInitted || ScrollSmoother.register(gsap) || console.warn("Please gsap.registerPlugin(ScrollSmoother)");
|
||||
vars = this.vars = vars || {};
|
||||
_mainInstance && _mainInstance.kill();
|
||||
_mainInstance = this;
|
||||
|
||||
_context(this);
|
||||
|
||||
var _vars = vars,
|
||||
smoothTouch = _vars.smoothTouch,
|
||||
_onUpdate = _vars.onUpdate,
|
||||
onStop = _vars.onStop,
|
||||
smooth = _vars.smooth,
|
||||
onFocusIn = _vars.onFocusIn,
|
||||
normalizeScroll = _vars.normalizeScroll,
|
||||
wholePixels = _vars.wholePixels,
|
||||
content,
|
||||
wrapper,
|
||||
height,
|
||||
mainST,
|
||||
effects,
|
||||
sections,
|
||||
intervalID,
|
||||
wrapperCSS,
|
||||
contentCSS,
|
||||
paused,
|
||||
pausedNormalizer,
|
||||
recordedRefreshScroll,
|
||||
recordedRefreshScrub,
|
||||
allowUpdates,
|
||||
self = this,
|
||||
effectsPrefix = vars.effectsPrefix || "",
|
||||
scrollFunc = ScrollTrigger.getScrollFunc(_win),
|
||||
smoothDuration = ScrollTrigger.isTouch === 1 ? smoothTouch === true ? 0.8 : parseFloat(smoothTouch) || 0 : smooth === 0 || smooth === false ? 0 : parseFloat(smooth) || 0.8,
|
||||
speed = smoothDuration && +vars.speed || 1,
|
||||
currentY = 0,
|
||||
delta = 0,
|
||||
startupPhase = 1,
|
||||
tracker = _getVelocityProp(0),
|
||||
updateVelocity = function updateVelocity() {
|
||||
return tracker.update(-currentY);
|
||||
},
|
||||
scroll = {
|
||||
y: 0
|
||||
},
|
||||
removeScroll = function removeScroll() {
|
||||
return content.style.overflow = "visible";
|
||||
},
|
||||
isProxyScrolling,
|
||||
killScrub = function killScrub(trigger) {
|
||||
trigger.update();
|
||||
var scrub = trigger.getTween();
|
||||
|
||||
if (scrub) {
|
||||
scrub.pause();
|
||||
scrub._time = scrub._dur;
|
||||
scrub._tTime = scrub._tDur;
|
||||
}
|
||||
|
||||
isProxyScrolling = false;
|
||||
trigger.animation.progress(trigger.progress, true);
|
||||
},
|
||||
render = function render(y, force) {
|
||||
if (y !== currentY && !paused || force) {
|
||||
wholePixels && (y = Math.round(y));
|
||||
|
||||
if (smoothDuration) {
|
||||
content.style.transform = "matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, " + y + ", 0, 1)";
|
||||
content._gsap.y = y + "px";
|
||||
}
|
||||
|
||||
delta = y - currentY;
|
||||
currentY = y;
|
||||
ScrollTrigger.isUpdating || ScrollSmoother.isRefreshing || ScrollTrigger.update();
|
||||
}
|
||||
},
|
||||
scrollTop = function scrollTop(value) {
|
||||
if (arguments.length) {
|
||||
value < 0 && (value = 0);
|
||||
scroll.y = -value;
|
||||
isProxyScrolling = true;
|
||||
paused ? currentY = -value : render(-value);
|
||||
ScrollTrigger.isRefreshing ? mainST.update() : scrollFunc(value / speed);
|
||||
return this;
|
||||
}
|
||||
|
||||
return -currentY;
|
||||
},
|
||||
resizeObserver = typeof ResizeObserver !== "undefined" && vars.autoResize !== false && new ResizeObserver(function () {
|
||||
if (!ScrollTrigger.isRefreshing) {
|
||||
var max = _maxScroll(wrapper) * speed;
|
||||
max < -currentY && scrollTop(max);
|
||||
|
||||
_onResizeDelayedCall.restart(true);
|
||||
}
|
||||
}),
|
||||
lastFocusElement,
|
||||
_onFocusIn = function _onFocusIn(e) {
|
||||
wrapper.scrollTop = 0;
|
||||
|
||||
if (e.target.contains && e.target.contains(wrapper) || onFocusIn && onFocusIn(_this, e) === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
ScrollTrigger.isInViewport(e.target) || e.target === lastFocusElement || _this.scrollTo(e.target, false, "center center");
|
||||
lastFocusElement = e.target;
|
||||
},
|
||||
_transformPosition = function _transformPosition(position, st) {
|
||||
if (position < st.start) {
|
||||
return position;
|
||||
}
|
||||
|
||||
var ratio = isNaN(st.ratio) ? 1 : st.ratio,
|
||||
change = st.end - st.start,
|
||||
distance = position - st.start,
|
||||
offset = st.offset || 0,
|
||||
pins = st.pins || [],
|
||||
pinOffset = pins.offset || 0,
|
||||
progressOffset = st._startClamp && st.start <= 0 || st.pins && st.pins.offset ? 0 : st._endClamp && st.end === _maxScroll() ? 1 : 0.5;
|
||||
pins.forEach(function (p) {
|
||||
change -= p.distance;
|
||||
|
||||
if (p.nativeStart <= position) {
|
||||
distance -= p.distance;
|
||||
}
|
||||
});
|
||||
|
||||
if (pinOffset) {
|
||||
distance *= (change - pinOffset / ratio) / change;
|
||||
}
|
||||
|
||||
return position + (distance - offset * progressOffset) / ratio - distance;
|
||||
},
|
||||
adjustEffectRelatedTriggers = function adjustEffectRelatedTriggers(st, triggers, partial) {
|
||||
partial || (st.pins.length = st.pins.offset = 0);
|
||||
var pins = st.pins,
|
||||
markers = st.markers,
|
||||
dif,
|
||||
isClamped,
|
||||
start,
|
||||
end,
|
||||
nativeStart,
|
||||
nativeEnd,
|
||||
i,
|
||||
trig;
|
||||
|
||||
for (i = 0; i < triggers.length; i++) {
|
||||
trig = triggers[i];
|
||||
|
||||
if (st.trigger && trig.trigger && st !== trig && (trig.trigger === st.trigger || trig.pinnedContainer === st.trigger || st.trigger.contains(trig.trigger))) {
|
||||
nativeStart = trig._startNative || trig._startClamp || trig.start;
|
||||
nativeEnd = trig._endNative || trig._endClamp || trig.end;
|
||||
start = _transformPosition(nativeStart, st);
|
||||
end = trig.pin && nativeEnd > 0 ? start + (nativeEnd - nativeStart) : _transformPosition(nativeEnd, st);
|
||||
trig.setPositions(start, end, true, (trig._startClamp ? Math.max(0, start) : start) - nativeStart);
|
||||
trig.markerStart && markers.push(gsap.quickSetter([trig.markerStart, trig.markerEnd], "y", "px"));
|
||||
|
||||
if (trig.pin && trig.end > 0 && !partial) {
|
||||
dif = trig.end - trig.start;
|
||||
isClamped = st._startClamp && trig.start < 0;
|
||||
|
||||
if (isClamped) {
|
||||
if (st.start > 0) {
|
||||
st.setPositions(0, st.end + (st._startNative - st.start), true);
|
||||
adjustEffectRelatedTriggers(st, triggers);
|
||||
return;
|
||||
}
|
||||
|
||||
dif += trig.start;
|
||||
pins.offset = -trig.start;
|
||||
}
|
||||
|
||||
pins.push({
|
||||
start: trig.start,
|
||||
nativeStart: nativeStart,
|
||||
end: trig.end,
|
||||
distance: dif,
|
||||
trig: trig
|
||||
});
|
||||
st.setPositions(st.start, st.end + (isClamped ? -trig.start : dif), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
adjustParallaxPosition = function adjustParallaxPosition(triggers, createdAfterEffectWasApplied) {
|
||||
effects.forEach(function (st) {
|
||||
return adjustEffectRelatedTriggers(st, triggers, createdAfterEffectWasApplied);
|
||||
});
|
||||
},
|
||||
onRefresh = function onRefresh() {
|
||||
_docEl = _doc.documentElement;
|
||||
_body = _doc.body;
|
||||
removeScroll();
|
||||
requestAnimationFrame(removeScroll);
|
||||
|
||||
if (effects) {
|
||||
ScrollTrigger.getAll().forEach(function (st) {
|
||||
st._startNative = st.start;
|
||||
st._endNative = st.end;
|
||||
});
|
||||
effects.forEach(function (st) {
|
||||
var start = st._startClamp || st.start,
|
||||
end = st.autoSpeed ? Math.min(_maxScroll(), st.end) : start + Math.abs((st.end - start) / st.ratio),
|
||||
offset = end - st.end;
|
||||
start -= offset / 2;
|
||||
end -= offset / 2;
|
||||
|
||||
if (start > end) {
|
||||
var s = start;
|
||||
start = end;
|
||||
end = s;
|
||||
}
|
||||
|
||||
if (st._startClamp && start < 0) {
|
||||
end = st.ratio < 0 ? _maxScroll() : st.end / st.ratio;
|
||||
offset = end - st.end;
|
||||
start = 0;
|
||||
} else if (st.ratio < 0 || st._endClamp && end >= _maxScroll()) {
|
||||
end = _maxScroll();
|
||||
start = st.ratio < 0 ? 0 : st.ratio > 1 ? 0 : end - (end - st.start) / st.ratio;
|
||||
offset = (end - start) * st.ratio - (st.end - st.start);
|
||||
}
|
||||
|
||||
st.offset = offset || 0.0001;
|
||||
st.pins.length = st.pins.offset = 0;
|
||||
st.setPositions(start, end, true);
|
||||
});
|
||||
adjustParallaxPosition(ScrollTrigger.sort());
|
||||
}
|
||||
|
||||
tracker.reset();
|
||||
},
|
||||
addOnRefresh = function addOnRefresh() {
|
||||
return ScrollTrigger.addEventListener("refresh", onRefresh);
|
||||
},
|
||||
restoreEffects = function restoreEffects() {
|
||||
return effects && effects.forEach(function (st) {
|
||||
return st.vars.onRefresh(st);
|
||||
});
|
||||
},
|
||||
revertEffects = function revertEffects() {
|
||||
effects && effects.forEach(function (st) {
|
||||
return st.vars.onRefreshInit(st);
|
||||
});
|
||||
return restoreEffects;
|
||||
},
|
||||
effectValueGetter = function effectValueGetter(name, value, index, el) {
|
||||
return function () {
|
||||
var v = typeof value === "function" ? value(index, el) : value;
|
||||
v || v === 0 || (v = el.getAttribute("data-" + effectsPrefix + name) || (name === "speed" ? 1 : 0));
|
||||
el.setAttribute("data-" + effectsPrefix + name, v);
|
||||
var clamp = (v + "").substr(0, 6) === "clamp(";
|
||||
return {
|
||||
clamp: clamp,
|
||||
value: clamp ? v.substr(6, v.length - 7) : v
|
||||
};
|
||||
};
|
||||
},
|
||||
createEffect = function createEffect(el, speed, lag, index, effectsPadding) {
|
||||
effectsPadding = (typeof effectsPadding === "function" ? effectsPadding(index, el) : effectsPadding) || 0;
|
||||
|
||||
var getSpeed = effectValueGetter("speed", speed, index, el),
|
||||
getLag = effectValueGetter("lag", lag, index, el),
|
||||
startY = gsap.getProperty(el, "y"),
|
||||
cache = el._gsap,
|
||||
ratio,
|
||||
st,
|
||||
autoSpeed,
|
||||
scrub,
|
||||
progressOffset,
|
||||
yOffset,
|
||||
pins = [],
|
||||
initDynamicValues = function initDynamicValues() {
|
||||
speed = getSpeed();
|
||||
lag = parseFloat(getLag().value);
|
||||
ratio = parseFloat(speed.value) || 1;
|
||||
autoSpeed = speed.value === "auto";
|
||||
progressOffset = autoSpeed || st && st._startClamp && st.start <= 0 || pins.offset ? 0 : st && st._endClamp && st.end === _maxScroll() ? 1 : 0.5;
|
||||
scrub && scrub.kill();
|
||||
scrub = lag && gsap.to(el, {
|
||||
ease: _expo,
|
||||
overwrite: false,
|
||||
y: "+=0",
|
||||
duration: lag
|
||||
});
|
||||
|
||||
if (st) {
|
||||
st.ratio = ratio;
|
||||
st.autoSpeed = autoSpeed;
|
||||
}
|
||||
},
|
||||
revert = function revert() {
|
||||
cache.y = startY + "px";
|
||||
cache.renderTransform(1);
|
||||
initDynamicValues();
|
||||
},
|
||||
markers = [],
|
||||
change = 0,
|
||||
updateChange = function updateChange(self) {
|
||||
if (autoSpeed) {
|
||||
revert();
|
||||
|
||||
var auto = _autoDistance(el, _clamp(0, 1, -self.start / (self.end - self.start)));
|
||||
|
||||
change = auto.change;
|
||||
yOffset = auto.offset;
|
||||
} else {
|
||||
yOffset = pins.offset || 0;
|
||||
change = (self.end - self.start - yOffset) * (1 - ratio);
|
||||
}
|
||||
|
||||
pins.forEach(function (p) {
|
||||
return change -= p.distance * (1 - ratio);
|
||||
});
|
||||
self.offset = change || 0.001;
|
||||
self.vars.onUpdate(self);
|
||||
scrub && scrub.progress(1);
|
||||
};
|
||||
|
||||
initDynamicValues();
|
||||
|
||||
if (ratio !== 1 || autoSpeed || scrub) {
|
||||
st = ScrollTrigger.create({
|
||||
trigger: autoSpeed ? el.parentNode : el,
|
||||
start: function start() {
|
||||
return speed.clamp ? "clamp(top bottom+=" + effectsPadding + ")" : "top bottom+=" + effectsPadding;
|
||||
},
|
||||
end: function end() {
|
||||
return speed.value < 0 ? "max" : speed.clamp ? "clamp(bottom top-=" + effectsPadding + ")" : "bottom top-=" + effectsPadding;
|
||||
},
|
||||
scroller: wrapper,
|
||||
scrub: true,
|
||||
refreshPriority: -999,
|
||||
onRefreshInit: revert,
|
||||
onRefresh: updateChange,
|
||||
onKill: function onKill(self) {
|
||||
var i = effects.indexOf(self);
|
||||
i >= 0 && effects.splice(i, 1);
|
||||
revert();
|
||||
},
|
||||
onUpdate: function onUpdate(self) {
|
||||
var y = startY + change * (self.progress - progressOffset),
|
||||
i = pins.length,
|
||||
extraY = 0,
|
||||
pin,
|
||||
scrollY,
|
||||
end;
|
||||
|
||||
if (self.offset) {
|
||||
if (i) {
|
||||
scrollY = -currentY;
|
||||
end = self.end;
|
||||
|
||||
while (i--) {
|
||||
pin = pins[i];
|
||||
|
||||
if (pin.trig.isActive || scrollY >= pin.start && scrollY <= pin.end) {
|
||||
if (scrub) {
|
||||
pin.trig.progress += pin.trig.direction < 0 ? 0.001 : -0.001;
|
||||
pin.trig.update(0, 0, 1);
|
||||
scrub.resetTo("y", parseFloat(cache.y), -delta, true);
|
||||
startupPhase && scrub.progress(1);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
scrollY > pin.end && (extraY += pin.distance);
|
||||
end -= pin.distance;
|
||||
}
|
||||
|
||||
y = startY + extraY + change * ((gsap.utils.clamp(self.start, self.end, scrollY) - self.start - extraY) / (end - self.start) - progressOffset);
|
||||
}
|
||||
|
||||
markers.length && !autoSpeed && markers.forEach(function (setter) {
|
||||
return setter(y - extraY);
|
||||
});
|
||||
y = _round(y + yOffset);
|
||||
|
||||
if (scrub) {
|
||||
scrub.resetTo("y", y, -delta, true);
|
||||
startupPhase && scrub.progress(1);
|
||||
} else {
|
||||
cache.y = y + "px";
|
||||
cache.renderTransform(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
updateChange(st);
|
||||
gsap.core.getCache(st.trigger).stRevert = revertEffects;
|
||||
st.startY = startY;
|
||||
st.pins = pins;
|
||||
st.markers = markers;
|
||||
st.ratio = ratio;
|
||||
st.autoSpeed = autoSpeed;
|
||||
el.style.willChange = "transform";
|
||||
}
|
||||
|
||||
return st;
|
||||
};
|
||||
|
||||
addOnRefresh();
|
||||
ScrollTrigger.addEventListener("killAll", addOnRefresh);
|
||||
gsap.delayedCall(0.5, function () {
|
||||
return startupPhase = 0;
|
||||
});
|
||||
this.scrollTop = scrollTop;
|
||||
|
||||
this.scrollTo = function (target, smooth, position) {
|
||||
var p = gsap.utils.clamp(0, _maxScroll(), isNaN(target) ? _this.offset(target, position, !!smooth && !paused) : +target);
|
||||
!smooth ? scrollTop(p) : paused ? gsap.to(_this, {
|
||||
duration: smoothDuration,
|
||||
scrollTop: p,
|
||||
overwrite: "auto",
|
||||
ease: _expo
|
||||
}) : scrollFunc(p);
|
||||
};
|
||||
|
||||
this.offset = function (target, position, ignoreSpeed) {
|
||||
target = _toArray(target)[0];
|
||||
var cssText = target.style.cssText,
|
||||
st = ScrollTrigger.create({
|
||||
trigger: target,
|
||||
start: position || "top top"
|
||||
}),
|
||||
y;
|
||||
|
||||
if (effects) {
|
||||
startupPhase ? ScrollTrigger.refresh() : adjustParallaxPosition([st], true);
|
||||
}
|
||||
|
||||
y = st.start / (ignoreSpeed ? speed : 1);
|
||||
st.kill(false);
|
||||
target.style.cssText = cssText;
|
||||
gsap.core.getCache(target).uncache = 1;
|
||||
return y;
|
||||
};
|
||||
|
||||
function refreshHeight() {
|
||||
height = content.clientHeight;
|
||||
content.style.overflow = "visible";
|
||||
_body.style.height = _win.innerHeight + (height - _win.innerHeight) / speed + "px";
|
||||
return height - _win.innerHeight;
|
||||
}
|
||||
|
||||
this.content = function (element) {
|
||||
if (arguments.length) {
|
||||
var newContent = _toArray(element || "#smooth-content")[0] || console.warn("ScrollSmoother needs a valid content element.") || _body.children[0];
|
||||
|
||||
if (newContent !== content) {
|
||||
content = newContent;
|
||||
contentCSS = content.getAttribute("style") || "";
|
||||
resizeObserver && resizeObserver.observe(content);
|
||||
gsap.set(content, {
|
||||
overflow: "visible",
|
||||
width: "100%",
|
||||
boxSizing: "border-box",
|
||||
y: "+=0"
|
||||
});
|
||||
smoothDuration || gsap.set(content, {
|
||||
clearProps: "transform"
|
||||
});
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
return content;
|
||||
};
|
||||
|
||||
this.wrapper = function (element) {
|
||||
if (arguments.length) {
|
||||
wrapper = _toArray(element || "#smooth-wrapper")[0] || _wrap(content);
|
||||
wrapperCSS = wrapper.getAttribute("style") || "";
|
||||
refreshHeight();
|
||||
gsap.set(wrapper, smoothDuration ? {
|
||||
overflow: "hidden",
|
||||
position: "fixed",
|
||||
height: "100%",
|
||||
width: "100%",
|
||||
top: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 0
|
||||
} : {
|
||||
overflow: "visible",
|
||||
position: "relative",
|
||||
width: "100%",
|
||||
height: "auto",
|
||||
top: "auto",
|
||||
bottom: "auto",
|
||||
left: "auto",
|
||||
right: "auto"
|
||||
});
|
||||
return this;
|
||||
}
|
||||
|
||||
return wrapper;
|
||||
};
|
||||
|
||||
this.effects = function (targets, config) {
|
||||
var _effects;
|
||||
|
||||
effects || (effects = []);
|
||||
|
||||
if (!targets) {
|
||||
return effects.slice(0);
|
||||
}
|
||||
|
||||
targets = _toArray(targets);
|
||||
targets.forEach(function (target) {
|
||||
var i = effects.length;
|
||||
|
||||
while (i--) {
|
||||
effects[i].trigger === target && effects[i].kill();
|
||||
}
|
||||
});
|
||||
config = config || {};
|
||||
var _config = config,
|
||||
speed = _config.speed,
|
||||
lag = _config.lag,
|
||||
effectsPadding = _config.effectsPadding,
|
||||
effectsToAdd = [],
|
||||
i,
|
||||
st;
|
||||
|
||||
for (i = 0; i < targets.length; i++) {
|
||||
st = createEffect(targets[i], speed, lag, i, effectsPadding);
|
||||
st && effectsToAdd.push(st);
|
||||
}
|
||||
|
||||
(_effects = effects).push.apply(_effects, effectsToAdd);
|
||||
|
||||
config.refresh !== false && ScrollTrigger.refresh();
|
||||
return effectsToAdd;
|
||||
};
|
||||
|
||||
this.sections = function (targets, config) {
|
||||
var _sections;
|
||||
|
||||
sections || (sections = []);
|
||||
|
||||
if (!targets) {
|
||||
return sections.slice(0);
|
||||
}
|
||||
|
||||
var newSections = _toArray(targets).map(function (el) {
|
||||
return ScrollTrigger.create({
|
||||
trigger: el,
|
||||
start: "top 120%",
|
||||
end: "bottom -20%",
|
||||
onToggle: function onToggle(self) {
|
||||
el.style.opacity = self.isActive ? "1" : "0";
|
||||
el.style.pointerEvents = self.isActive ? "all" : "none";
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
config && config.add ? (_sections = sections).push.apply(_sections, newSections) : sections = newSections.slice(0);
|
||||
return newSections;
|
||||
};
|
||||
|
||||
this.content(vars.content);
|
||||
this.wrapper(vars.wrapper);
|
||||
|
||||
this.render = function (y) {
|
||||
return render(y || y === 0 ? y : currentY);
|
||||
};
|
||||
|
||||
this.getVelocity = function () {
|
||||
return tracker.getVelocity(-currentY);
|
||||
};
|
||||
|
||||
ScrollTrigger.scrollerProxy(wrapper, {
|
||||
scrollTop: scrollTop,
|
||||
scrollHeight: function scrollHeight() {
|
||||
return refreshHeight() && _body.scrollHeight;
|
||||
},
|
||||
fixedMarkers: vars.fixedMarkers !== false && !!smoothDuration,
|
||||
content: content,
|
||||
getBoundingClientRect: function getBoundingClientRect() {
|
||||
return {
|
||||
top: 0,
|
||||
left: 0,
|
||||
width: _win.innerWidth,
|
||||
height: _win.innerHeight
|
||||
};
|
||||
}
|
||||
});
|
||||
ScrollTrigger.defaults({
|
||||
scroller: wrapper
|
||||
});
|
||||
var existingScrollTriggers = ScrollTrigger.getAll().filter(function (st) {
|
||||
return st.scroller === _win || st.scroller === wrapper;
|
||||
});
|
||||
existingScrollTriggers.forEach(function (st) {
|
||||
return st.revert(true, true);
|
||||
});
|
||||
mainST = ScrollTrigger.create({
|
||||
animation: gsap.fromTo(scroll, {
|
||||
y: function y() {
|
||||
allowUpdates = 0;
|
||||
return 0;
|
||||
}
|
||||
}, {
|
||||
y: function y() {
|
||||
allowUpdates = 1;
|
||||
return -refreshHeight();
|
||||
},
|
||||
immediateRender: false,
|
||||
ease: "none",
|
||||
data: "ScrollSmoother",
|
||||
duration: 100,
|
||||
onUpdate: function onUpdate() {
|
||||
if (allowUpdates) {
|
||||
var force = isProxyScrolling;
|
||||
|
||||
if (force) {
|
||||
killScrub(mainST);
|
||||
scroll.y = currentY;
|
||||
}
|
||||
|
||||
render(scroll.y, force);
|
||||
updateVelocity();
|
||||
_onUpdate && !paused && _onUpdate(self);
|
||||
}
|
||||
}
|
||||
}),
|
||||
onRefreshInit: function onRefreshInit(self) {
|
||||
if (ScrollSmoother.isRefreshing) {
|
||||
return;
|
||||
}
|
||||
|
||||
ScrollSmoother.isRefreshing = true;
|
||||
|
||||
if (effects) {
|
||||
var _pins = ScrollTrigger.getAll().filter(function (st) {
|
||||
return !!st.pin;
|
||||
});
|
||||
|
||||
effects.forEach(function (st) {
|
||||
if (!st.vars.pinnedContainer) {
|
||||
_pins.forEach(function (pinST) {
|
||||
if (pinST.pin.contains(st.trigger)) {
|
||||
var v = st.vars;
|
||||
v.pinnedContainer = pinST.pin;
|
||||
st.vars = null;
|
||||
st.init(v, st.animation);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var scrub = self.getTween();
|
||||
recordedRefreshScrub = scrub && scrub._end > scrub._dp._time;
|
||||
recordedRefreshScroll = currentY;
|
||||
scroll.y = 0;
|
||||
|
||||
if (smoothDuration) {
|
||||
ScrollTrigger.isTouch === 1 && (wrapper.style.position = "absolute");
|
||||
wrapper.scrollTop = 0;
|
||||
ScrollTrigger.isTouch === 1 && (wrapper.style.position = "fixed");
|
||||
}
|
||||
},
|
||||
onRefresh: function onRefresh(self) {
|
||||
self.animation.invalidate();
|
||||
scroll.y = 0;
|
||||
self.setPositions(self.start, refreshHeight() / speed);
|
||||
recordedRefreshScrub || killScrub(self);
|
||||
scroll.y = -scrollFunc() * speed;
|
||||
render(scroll.y);
|
||||
|
||||
if (!startupPhase) {
|
||||
recordedRefreshScrub && (isProxyScrolling = false);
|
||||
self.animation.progress(gsap.utils.clamp(0, 1, recordedRefreshScroll / speed / -self.end));
|
||||
}
|
||||
|
||||
if (recordedRefreshScrub) {
|
||||
self.progress -= 0.001;
|
||||
self.update();
|
||||
}
|
||||
|
||||
ScrollSmoother.isRefreshing = false;
|
||||
},
|
||||
id: "ScrollSmoother",
|
||||
scroller: _win,
|
||||
invalidateOnRefresh: true,
|
||||
start: 0,
|
||||
refreshPriority: -9999,
|
||||
end: function end() {
|
||||
return refreshHeight() / speed;
|
||||
},
|
||||
onScrubComplete: function onScrubComplete() {
|
||||
tracker.reset();
|
||||
onStop && onStop(_this);
|
||||
},
|
||||
scrub: smoothDuration || true
|
||||
});
|
||||
|
||||
this.smooth = function (value) {
|
||||
if (arguments.length) {
|
||||
smoothDuration = value || 0;
|
||||
speed = smoothDuration && +vars.speed || 1;
|
||||
mainST.scrubDuration(value);
|
||||
}
|
||||
|
||||
return mainST.getTween() ? mainST.getTween().duration() : 0;
|
||||
};
|
||||
|
||||
mainST.getTween() && (mainST.getTween().vars.ease = vars.ease || _expo);
|
||||
this.scrollTrigger = mainST;
|
||||
vars.effects && this.effects(vars.effects === true ? "[data-" + effectsPrefix + "speed], [data-" + effectsPrefix + "lag]" : vars.effects, {
|
||||
effectsPadding: vars.effectsPadding,
|
||||
refresh: false
|
||||
});
|
||||
vars.sections && this.sections(vars.sections === true ? "[data-section]" : vars.sections);
|
||||
existingScrollTriggers.forEach(function (st) {
|
||||
st.vars.scroller = wrapper;
|
||||
st.revert(false, true);
|
||||
st.init(st.vars, st.animation);
|
||||
});
|
||||
|
||||
this.paused = function (value, allowNestedScroll) {
|
||||
if (arguments.length) {
|
||||
if (!!paused !== value) {
|
||||
if (value) {
|
||||
mainST.getTween() && mainST.getTween().pause();
|
||||
scrollFunc(-currentY / speed);
|
||||
tracker.reset();
|
||||
pausedNormalizer = ScrollTrigger.normalizeScroll();
|
||||
pausedNormalizer && pausedNormalizer.disable();
|
||||
paused = ScrollTrigger.observe({
|
||||
preventDefault: true,
|
||||
type: "wheel,touch,scroll",
|
||||
debounce: false,
|
||||
allowClicks: true,
|
||||
onChangeY: function onChangeY() {
|
||||
return scrollTop(-currentY);
|
||||
}
|
||||
});
|
||||
paused.nested = _inputObserver(_docEl, "wheel,touch,scroll", true, allowNestedScroll !== false);
|
||||
} else {
|
||||
paused.nested.kill();
|
||||
paused.kill();
|
||||
paused = 0;
|
||||
pausedNormalizer && pausedNormalizer.enable();
|
||||
mainST.progress = (-currentY / speed - mainST.start) / (mainST.end - mainST.start);
|
||||
killScrub(mainST);
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
return !!paused;
|
||||
};
|
||||
|
||||
this.kill = this.revert = function () {
|
||||
_this.paused(false);
|
||||
|
||||
killScrub(mainST);
|
||||
mainST.kill();
|
||||
var triggers = (effects || []).concat(sections || []),
|
||||
i = triggers.length;
|
||||
|
||||
while (i--) {
|
||||
triggers[i].kill();
|
||||
}
|
||||
|
||||
ScrollTrigger.scrollerProxy(wrapper);
|
||||
ScrollTrigger.removeEventListener("killAll", addOnRefresh);
|
||||
ScrollTrigger.removeEventListener("refresh", onRefresh);
|
||||
wrapper.style.cssText = wrapperCSS;
|
||||
content.style.cssText = contentCSS;
|
||||
var defaults = ScrollTrigger.defaults({});
|
||||
defaults && defaults.scroller === wrapper && ScrollTrigger.defaults({
|
||||
scroller: _win
|
||||
});
|
||||
_this.normalizer && ScrollTrigger.normalizeScroll(false);
|
||||
clearInterval(intervalID);
|
||||
_mainInstance = null;
|
||||
resizeObserver && resizeObserver.disconnect();
|
||||
|
||||
_body.style.removeProperty("height");
|
||||
|
||||
_win.removeEventListener("focusin", _onFocusIn);
|
||||
};
|
||||
|
||||
this.refresh = function (soft, force) {
|
||||
return mainST.refresh(soft, force);
|
||||
};
|
||||
|
||||
if (normalizeScroll) {
|
||||
this.normalizer = ScrollTrigger.normalizeScroll(normalizeScroll === true ? {
|
||||
debounce: true,
|
||||
content: !smoothDuration && content
|
||||
} : normalizeScroll);
|
||||
}
|
||||
|
||||
ScrollTrigger.config(vars);
|
||||
"scrollBehavior" in _win.getComputedStyle(_body) && gsap.set([_body, _docEl], {
|
||||
scrollBehavior: "auto"
|
||||
});
|
||||
|
||||
_win.addEventListener("focusin", _onFocusIn);
|
||||
|
||||
intervalID = setInterval(updateVelocity, 250);
|
||||
_doc.readyState === "loading" || requestAnimationFrame(function () {
|
||||
return ScrollTrigger.refresh();
|
||||
});
|
||||
}
|
||||
|
||||
ScrollSmoother.register = function register(core) {
|
||||
if (!_coreInitted) {
|
||||
gsap = core || _getGSAP();
|
||||
|
||||
if (_windowExists() && window.document) {
|
||||
_win = window;
|
||||
_doc = document;
|
||||
_docEl = _doc.documentElement;
|
||||
_body = _doc.body;
|
||||
}
|
||||
|
||||
if (gsap) {
|
||||
_toArray = gsap.utils.toArray;
|
||||
_clamp = gsap.utils.clamp;
|
||||
_expo = gsap.parseEase("expo");
|
||||
|
||||
_context = gsap.core.context || function () {};
|
||||
|
||||
ScrollTrigger = gsap.core.globals().ScrollTrigger;
|
||||
gsap.core.globals("ScrollSmoother", ScrollSmoother);
|
||||
|
||||
if (_body && ScrollTrigger) {
|
||||
_onResizeDelayedCall = gsap.delayedCall(0.2, function () {
|
||||
return ScrollTrigger.isRefreshing || _mainInstance && _mainInstance.refresh();
|
||||
}).pause();
|
||||
_getVelocityProp = ScrollTrigger.core._getVelocityProp;
|
||||
_inputObserver = ScrollTrigger.core._inputObserver;
|
||||
ScrollSmoother.refresh = ScrollTrigger.refresh;
|
||||
_coreInitted = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return _coreInitted;
|
||||
};
|
||||
|
||||
_createClass(ScrollSmoother, [{
|
||||
key: "progress",
|
||||
get: function get() {
|
||||
return this.scrollTrigger ? this.scrollTrigger.animation._time / 100 : 0;
|
||||
}
|
||||
}]);
|
||||
|
||||
return ScrollSmoother;
|
||||
}();
|
||||
ScrollSmoother.version = "3.14.2";
|
||||
|
||||
ScrollSmoother.create = function (vars) {
|
||||
return _mainInstance && vars && _mainInstance.content() === _toArray(vars.content)[0] ? _mainInstance : new ScrollSmoother(vars);
|
||||
};
|
||||
|
||||
ScrollSmoother.get = function () {
|
||||
return _mainInstance;
|
||||
};
|
||||
|
||||
_getGSAP() && gsap.registerPlugin(ScrollSmoother);
|
||||
|
||||
exports.ScrollSmoother = ScrollSmoother;
|
||||
exports.default = ScrollSmoother;
|
||||
|
||||
if (typeof(window) === 'undefined' || window !== exports) {Object.defineProperty(exports, '__esModule', { value: true });} else {delete window.default;}
|
||||
|
||||
})));
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
/*!
|
||||
* ScrollSmoother 3.14.2
|
||||
* https://gsap.com
|
||||
*
|
||||
* @license Copyright 2025, GreenSock. All rights reserved.
|
||||
* Subject to the terms at https://gsap.com/standard-license.
|
||||
* @author: Jack Doyle, jack@greensock.com
|
||||
*/
|
||||
|
||||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).window=e.window||{})}(this,function(e){"use strict";function _defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function s(){return"undefined"!=typeof window}function t(){return I||s()&&(I=window.gsap)&&I.registerPlugin&&I}function v(e){return Y.maxScroll(e||U)}var I,D,U,j,G,K,q,V,Y,Q,W,J,X,Z,$,r=(ScrollSmoother.register=function register(e){return D||(I=e||t(),s()&&window.document&&(U=window,j=document,G=j.documentElement,K=j.body),I&&(q=I.utils.toArray,V=I.utils.clamp,W=I.parseEase("expo"),Z=I.core.context||function(){},Y=I.core.globals().ScrollTrigger,I.core.globals("ScrollSmoother",ScrollSmoother),K&&Y&&($=I.delayedCall(.2,function(){return Y.isRefreshing||Q&&Q.refresh()}).pause(),J=Y.core._getVelocityProp,X=Y.core._inputObserver,ScrollSmoother.refresh=Y.refresh,D=1))),D},function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),e}(ScrollSmoother,[{key:"progress",get:function get(){return this.scrollTrigger?this.scrollTrigger.animation._time/100:0}}]),ScrollSmoother);function ScrollSmoother(t){var o=this;D||ScrollSmoother.register(I)||console.warn("Please gsap.registerPlugin(ScrollSmoother)"),t=this.vars=t||{},Q&&Q.kill(),Z(Q=this);function Ba(){return z.update(-N)}function Da(){return n.style.overflow="visible"}function Fa(e){e.update();var t=e.getTween();t&&(t.pause(),t._time=t._dur,t._tTime=t._tDur),g=!1,e.animation.progress(e.progress,!0)}function Ga(e,t){(e!==N&&!f||t)&&(x&&(e=Math.round(e)),H&&(n.style.transform="matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, "+e+", 0, 1)",n._gsap.y=e+"px"),F=e-N,N=e,Y.isUpdating||ScrollSmoother.isRefreshing||Y.update())}function Ha(e){return arguments.length?(e<0&&(e=0),B.y=-e,g=!0,f?N=-e:Ga(-e),Y.isRefreshing?i.update():k(e/A),this):-N}function Ka(e){S.scrollTop=0,e.target.contains&&e.target.contains(S)||C&&!1===C(o,e)||(Y.isInViewport(e.target)||e.target===p||o.scrollTo(e.target,!1,"center center"),p=e.target)}function La(t,e){if(t<e.start)return t;var r=isNaN(e.ratio)?1:e.ratio,n=e.end-e.start,o=t-e.start,i=e.offset||0,s=e.pins||[],a=s.offset||0,l=e._startClamp&&e.start<=0||e.pins&&e.pins.offset?0:e._endClamp&&e.end===v()?1:.5;return s.forEach(function(e){n-=e.distance,e.nativeStart<=t&&(o-=e.distance)}),a&&(o*=(n-a/r)/n),t+(o-i*l)/r-o}function Na(t,r){b.forEach(function(e){return function adjustEffectRelatedTriggers(e,t,r){r||(e.pins.length=e.pins.offset=0);var n,o,i,s,a,l,c,f,u=e.pins,h=e.markers;for(c=0;c<t.length;c++)if(f=t[c],e.trigger&&f.trigger&&e!==f&&(f.trigger===e.trigger||f.pinnedContainer===e.trigger||e.trigger.contains(f.trigger))&&(a=f._startNative||f._startClamp||f.start,l=f._endNative||f._endClamp||f.end,i=La(a,e),s=f.pin&&0<l?i+(l-a):La(l,e),f.setPositions(i,s,!0,(f._startClamp?Math.max(0,i):i)-a),f.markerStart&&h.push(I.quickSetter([f.markerStart,f.markerEnd],"y","px")),f.pin&&0<f.end&&!r)){if(n=f.end-f.start,o=e._startClamp&&f.start<0){if(0<e.start)return e.setPositions(0,e.end+(e._startNative-e.start),!0),void adjustEffectRelatedTriggers(e,t);n+=f.start,u.offset=-f.start}u.push({start:f.start,nativeStart:a,end:f.end,distance:n,trig:f}),e.setPositions(e.start,e.end+(o?-f.start:n),!0)}}(e,t,r)})}function Oa(){G=j.documentElement,K=j.body,Da(),requestAnimationFrame(Da),b&&(Y.getAll().forEach(function(e){e._startNative=e.start,e._endNative=e.end}),b.forEach(function(e){var t=e._startClamp||e.start,r=e.autoSpeed?Math.min(v(),e.end):t+Math.abs((e.end-t)/e.ratio),n=r-e.end;if((r-=n/2)<(t-=n/2)){var o=t;t=r,r=o}e._startClamp&&t<0?(n=(r=e.ratio<0?v():e.end/e.ratio)-e.end,t=0):(e.ratio<0||e._endClamp&&r>=v())&&(n=((r=v())-(t=e.ratio<0||1<e.ratio?0:r-(r-e.start)/e.ratio))*e.ratio-(e.end-e.start)),e.offset=n||1e-4,e.pins.length=e.pins.offset=0,e.setPositions(t,r,!0)}),Na(Y.sort())),z.reset()}function Pa(){return Y.addEventListener("refresh",Oa)}function Qa(){return b&&b.forEach(function(e){return e.vars.onRefresh(e)})}function Ra(){return b&&b.forEach(function(e){return e.vars.onRefreshInit(e)}),Qa}function Sa(r,n,o,i){return function(){var e="function"==typeof n?n(o,i):n;e||0===e||(e=i.getAttribute("data-"+E+r)||("speed"===r?1:0)),i.setAttribute("data-"+E+r,e);var t="clamp("===(e+"").substr(0,6);return{clamp:t,value:t?e.substr(6,e.length-7):e}}}function Ta(r,e,t,n,o){function cc(){e=u(),t=parseFloat(h().value),i=parseFloat(e.value)||1,a="auto"===e.value,c=a||s&&s._startClamp&&s.start<=0||p.offset?0:s&&s._endClamp&&s.end===v()?1:.5,l&&l.kill(),l=t&&I.to(r,{ease:W,overwrite:!1,y:"+=0",duration:t}),s&&(s.ratio=i,s.autoSpeed=a)}function dc(){g.y=d+"px",g.renderTransform(1),cc()}function gc(e){if(a){dc();var t=function _autoDistance(e,t){var r,n,o=e.parentNode||G,i=e.getBoundingClientRect(),s=o.getBoundingClientRect(),a=s.top-i.top,l=s.bottom-i.Line truncated
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ScrollSmoother.min.js","sources":["../src/ScrollSmoother.js"],"sourcesContent":["/*!\n * ScrollSmoother 3.14.2\n * https://gsap.com\n *\n * @license Copyright 2008-2025, GreenSock. All rights reserved.\n * Subject to the terms at https://gsap.com/standard-license\n * @author: Jack Doyle, jack@greensock.com\n*/\n/* eslint-disable */\n\nlet gsap, _coreInitted, _win, _doc, _docEl, _body, _root, _toArray, _clamp, ScrollTrigger, _mainInstance, _expo, _getVelocityProp, _inputObserver, _context, _onResizeDelayedCall,\n\t_windowExists = () => typeof(window) !== \"undefined\",\n\t_getGSAP = () => gsap || (_windowExists() && (gsap = window.gsap) && gsap.registerPlugin && gsap),\n\t_bonusValidated = 1, //<name>ScrollSmoother</name>\n\t_round = value => Math.round(value * 100000) / 100000 || 0,\n\t_maxScroll = scroller => ScrollTrigger.maxScroll(scroller || _win),\n\t_autoDistance = (el, progress) => { // for calculating the distance (and offset) for elements with speed: \"auto\". Progress is for if it's \"above the fold\" (negative start position), so we can crop as little as possible.\n\t\tlet parent = el.parentNode || _docEl,\n\t\t\tb1 = el.getBoundingClientRect(),\n\t\t\tb2 = parent.getBoundingClientRect(),\n\t\t\tgapTop = b2.top - b1.top,\n\t\t\tgapBottom = b2.bottom - b1.bottom,\n\t\t\tchange = (Math.abs(gapTop) > Math.abs(gapBottom) ? gapTop : gapBottom) / (1 - progress),\n\t\t\toffset = -change * progress,\n\t\t\tratio, extraChange;\n\t\tif (change > 0) { // if the image starts at the BOTTOM of the container, adjust things so that it shows as much of the image as possible while still covering.\n\t\t\tratio = b2.height / (_win.innerHeight + b2.height);\n\t\t\textraChange = ratio === 0.5 ? b2.height * 2 : Math.min(b2.height, Math.abs(-change * ratio / (2 * ratio - 1))) * 2 * (progress || 1);\n\t\t\toffset += progress ? -extraChange * progress : -extraChange / 2; // whatever the offset, we must double that in the opposite direction to compensate.\n\t\t\tchange += extraChange;\n\t\t}\n\t\treturn {change, offset};\n\t},\n\t_wrap = el => {\n\t\tlet wrapper = _doc.querySelector(\".ScrollSmoother-wrapper\"); // some frameworks load multiple times, so one already exists, just use that to avoid duplicates\n\t\tif (!wrapper) {\n\t\t\twrapper = _doc.createElement(\"div\");\n\t\t\twrapper.classList.add(\"ScrollSmoother-wrapper\");\n\t\t\tel.parentNode.insertBefore(wrapper, el);\n\t\t\twrapper.appendChild(el);\n\t\t}\n\t\treturn wrapper;\n\t};\n\nexport class ScrollSmoother {\n\n\tconstructor(vars) {\n\t\t_coreInitted || ScrollSmoother.register(gsap) || console.warn(\"Please gsap.registerPlugin(ScrollSmoother)\");\n\t\tvars = this.vars = vars || {};\n\n\t\t_mainInstance && _mainInstance.kill();\n\t\t_mainInstance = this;\n\t\t_context(this);\n\n\t\tlet {smoothTouch, onUpdate, onStop, smooth, onFocusIn, normalizeScroll, wholePixels} = vars,\n\t\t\tcontent, wrapper, height, mainST, effects, sections, intervalID, wrapperCSS, contentCSS, paused, pausedNormalizer, recordedRefreshScroll, recordedRefreshScrub, allowUpdates,\n\t\t\tself = this,\n\t\t\teffectsPrefix = vars.effectsPrefix || \"\",\n\t\t\tscrollFunc = ScrollTrigger.getScrollFunc(_win),\n\t\t\tsmoothDuration = ScrollTrigger.isTouch === 1 ? (smoothTouch === true ? 0.8 : parseFloat(smoothTouch) || 0) : (smooth === 0 || smooth === false) ? 0 : parseFloat(smooth) || 0.8,\n\t\t\tspeed = (smoothDuration && +vars.speed) || 1,\n\t\t\tcurrentY = 0,\n\t\t\tdelta = 0,\n\t\t\tstartupPhase = 1,\n\t\t\ttracker = _getVelocityProp(0),\n\t\t\tupdateVelocity = () => tracker.update(-currentY),\n\t\t\tscroll = {y: 0},\n\t\t\tremoveScroll = () => content.style.overflow = \"visible\",\n\t\t\tisProxyScrolling,\n\t\t\tkillScrub = trigger => {\n\t\t\t\ttrigger.update(); // it's possible that it hasn't been synchronized with the actual scroll position yet, like if it's later in the _triggers Array. If it was already updated, it'll skip the processing anyway.\n\t\t\t\tlet scrub = trigger.getTween();\n\t\t\t\tif (scrub) {\n\t\t\t\t\tscrub.pause();\n\t\t\t\t\tscrub._time = scrub._dur; // force the playhead to completion without rendering just so that when it resumes, it doesn't jump back in the .resetTo().\n\t\t\t\t\tscrub._tTime = scrub._tDur;\n\t\t\t\t}\n\t\t\t\tisProxyScrolling = false;\n\t\t\t\ttrigger.animation.progress(trigger.progress, true);\n\t\t\t},\n\t\t\trender = (y, force) => {\n\t\t\t\tif ((y !== currentY && !paused) || force) {\n\t\t\t\t\twholePixels && (y = Math.round(y));\n\t\t\t\t\tif (smoothDuration) {\n\t\t\t\t\t\tcontent.style.transform = \"matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, \" + y + \", 0, 1)\";\n\t\t\t\t\t\t//content.style.transform = \"translateY(\" + y + \"px)\"; // NOTE: when we used matrix3d() or set will-change: transform, it performed noticeably worse on iOS counter-intuitively!\n\t\t\t\t\t\tcontent._gsap.y = y + \"px\";\n\t\t\t\t\t}\n\t\t\t\t\tdelta = y - currentY;\n\t\t\t\t\tcurrentY = y;\n\t\t\t\t\tScrollTrigger.isUpdating || ScrollSLine truncated
|
||||
+285
@@ -0,0 +1,285 @@
|
||||
(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';
|
||||
|
||||
/*!
|
||||
* ScrollToPlugin 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 gsap,
|
||||
_coreInitted,
|
||||
_window,
|
||||
_docEl,
|
||||
_body,
|
||||
_toArray,
|
||||
_config,
|
||||
ScrollTrigger,
|
||||
_windowExists = function _windowExists() {
|
||||
return typeof window !== "undefined";
|
||||
},
|
||||
_getGSAP = function _getGSAP() {
|
||||
return gsap || _windowExists() && (gsap = window.gsap) && gsap.registerPlugin && gsap;
|
||||
},
|
||||
_isString = function _isString(value) {
|
||||
return typeof value === "string";
|
||||
},
|
||||
_isFunction = function _isFunction(value) {
|
||||
return typeof value === "function";
|
||||
},
|
||||
_max = function _max(element, axis) {
|
||||
var dim = axis === "x" ? "Width" : "Height",
|
||||
scroll = "scroll" + dim,
|
||||
client = "client" + dim;
|
||||
return element === _window || element === _docEl || element === _body ? Math.max(_docEl[scroll], _body[scroll]) - (_window["inner" + dim] || _docEl[client] || _body[client]) : element[scroll] - element["offset" + dim];
|
||||
},
|
||||
_buildGetter = function _buildGetter(e, axis) {
|
||||
var p = "scroll" + (axis === "x" ? "Left" : "Top");
|
||||
|
||||
if (e === _window) {
|
||||
if (e.pageXOffset != null) {
|
||||
p = "page" + axis.toUpperCase() + "Offset";
|
||||
} else {
|
||||
e = _docEl[p] != null ? _docEl : _body;
|
||||
}
|
||||
}
|
||||
|
||||
return function () {
|
||||
return e[p];
|
||||
};
|
||||
},
|
||||
_clean = function _clean(value, index, target, targets) {
|
||||
_isFunction(value) && (value = value(index, target, targets));
|
||||
|
||||
if (typeof value !== "object") {
|
||||
return _isString(value) && value !== "max" && value.charAt(1) !== "=" ? {
|
||||
x: value,
|
||||
y: value
|
||||
} : {
|
||||
y: value
|
||||
};
|
||||
} else if (value.nodeType) {
|
||||
return {
|
||||
y: value,
|
||||
x: value
|
||||
};
|
||||
} else {
|
||||
var result = {},
|
||||
p;
|
||||
|
||||
for (p in value) {
|
||||
result[p] = p !== "onAutoKill" && _isFunction(value[p]) ? value[p](index, target, targets) : value[p];
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
},
|
||||
_getOffset = function _getOffset(element, container) {
|
||||
element = _toArray(element)[0];
|
||||
|
||||
if (!element || !element.getBoundingClientRect) {
|
||||
return console.warn("scrollTo target doesn't exist. Using 0") || {
|
||||
x: 0,
|
||||
y: 0
|
||||
};
|
||||
}
|
||||
|
||||
var rect = element.getBoundingClientRect(),
|
||||
isRoot = !container || container === _window || container === _body,
|
||||
cRect = isRoot ? {
|
||||
top: _docEl.clientTop - (_window.pageYOffset || _docEl.scrollTop || _body.scrollTop || 0),
|
||||
left: _docEl.clientLeft - (_window.pageXOffset || _docEl.scrollLeft || _body.scrollLeft || 0)
|
||||
} : container.getBoundingClientRect(),
|
||||
offsets = {
|
||||
x: rect.left - cRect.left,
|
||||
y: rect.top - cRect.top
|
||||
};
|
||||
|
||||
if (!isRoot && container) {
|
||||
offsets.x += _buildGetter(container, "x")();
|
||||
offsets.y += _buildGetter(container, "y")();
|
||||
}
|
||||
|
||||
return offsets;
|
||||
},
|
||||
_parseVal = function _parseVal(value, target, axis, currentVal, offset) {
|
||||
return !isNaN(value) && typeof value !== "object" ? parseFloat(value) - offset : _isString(value) && value.charAt(1) === "=" ? parseFloat(value.substr(2)) * (value.charAt(0) === "-" ? -1 : 1) + currentVal - offset : value === "max" ? _max(target, axis) - offset : Math.min(_max(target, axis), _getOffset(value, target)[axis] - offset);
|
||||
},
|
||||
_initCore = function _initCore() {
|
||||
gsap = _getGSAP();
|
||||
|
||||
if (_windowExists() && gsap && typeof document !== "undefined" && document.body) {
|
||||
_window = window;
|
||||
_body = document.body;
|
||||
_docEl = document.documentElement;
|
||||
_toArray = gsap.utils.toArray;
|
||||
gsap.config({
|
||||
autoKillThreshold: 7
|
||||
});
|
||||
_config = gsap.config();
|
||||
_coreInitted = 1;
|
||||
}
|
||||
};
|
||||
|
||||
var ScrollToPlugin = {
|
||||
version: "3.14.2",
|
||||
name: "scrollTo",
|
||||
rawVars: 1,
|
||||
register: function register(core) {
|
||||
gsap = core;
|
||||
|
||||
_initCore();
|
||||
},
|
||||
init: function init(target, value, tween, index, targets) {
|
||||
_coreInitted || _initCore();
|
||||
var data = this,
|
||||
snapType = gsap.getProperty(target, "scrollSnapType");
|
||||
data.isWin = target === _window;
|
||||
data.target = target;
|
||||
data.tween = tween;
|
||||
value = _clean(value, index, target, targets);
|
||||
data.vars = value;
|
||||
data.autoKill = !!("autoKill" in value ? value : _config).autoKill;
|
||||
data.getX = _buildGetter(target, "x");
|
||||
data.getY = _buildGetter(target, "y");
|
||||
data.x = data.xPrev = data.getX();
|
||||
data.y = data.yPrev = data.getY();
|
||||
ScrollTrigger || (ScrollTrigger = gsap.core.globals().ScrollTrigger);
|
||||
gsap.getProperty(target, "scrollBehavior") === "smooth" && gsap.set(target, {
|
||||
scrollBehavior: "auto"
|
||||
});
|
||||
|
||||
if (snapType && snapType !== "none") {
|
||||
data.snap = 1;
|
||||
data.snapInline = target.style.scrollSnapType;
|
||||
target.style.scrollSnapType = "none";
|
||||
}
|
||||
|
||||
if (value.x != null) {
|
||||
data.add(data, "x", data.x, _parseVal(value.x, target, "x", data.x, value.offsetX || 0), index, targets);
|
||||
|
||||
data._props.push("scrollTo_x");
|
||||
} else {
|
||||
data.skipX = 1;
|
||||
}
|
||||
|
||||
if (value.y != null) {
|
||||
data.add(data, "y", data.y, _parseVal(value.y, target, "y", data.y, value.offsetY || 0), index, targets);
|
||||
|
||||
data._props.push("scrollTo_y");
|
||||
} else {
|
||||
data.skipY = 1;
|
||||
}
|
||||
},
|
||||
render: function render(ratio, data) {
|
||||
var pt = data._pt,
|
||||
target = data.target,
|
||||
tween = data.tween,
|
||||
autoKill = data.autoKill,
|
||||
xPrev = data.xPrev,
|
||||
yPrev = data.yPrev,
|
||||
isWin = data.isWin,
|
||||
snap = data.snap,
|
||||
snapInline = data.snapInline,
|
||||
x,
|
||||
y,
|
||||
yDif,
|
||||
xDif,
|
||||
threshold;
|
||||
|
||||
while (pt) {
|
||||
pt.r(ratio, pt.d);
|
||||
pt = pt._next;
|
||||
}
|
||||
|
||||
x = isWin || !data.skipX ? data.getX() : xPrev;
|
||||
y = isWin || !data.skipY ? data.getY() : yPrev;
|
||||
yDif = y - yPrev;
|
||||
xDif = x - xPrev;
|
||||
threshold = _config.autoKillThreshold;
|
||||
|
||||
if (data.x < 0) {
|
||||
data.x = 0;
|
||||
}
|
||||
|
||||
if (data.y < 0) {
|
||||
data.y = 0;
|
||||
}
|
||||
|
||||
if (autoKill) {
|
||||
if (!data.skipX && (xDif > threshold || xDif < -threshold) && x < _max(target, "x")) {
|
||||
data.skipX = 1;
|
||||
}
|
||||
|
||||
if (!data.skipY && (yDif > threshold || yDif < -threshold) && y < _max(target, "y")) {
|
||||
data.skipY = 1;
|
||||
}
|
||||
|
||||
if (data.skipX && data.skipY) {
|
||||
tween.kill();
|
||||
data.vars.onAutoKill && data.vars.onAutoKill.apply(tween, data.vars.onAutoKillParams || []);
|
||||
}
|
||||
}
|
||||
|
||||
if (isWin) {
|
||||
_window.scrollTo(!data.skipX ? data.x : x, !data.skipY ? data.y : y);
|
||||
} else {
|
||||
data.skipY || (target.scrollTop = data.y);
|
||||
data.skipX || (target.scrollLeft = data.x);
|
||||
}
|
||||
|
||||
if (snap && (ratio === 1 || ratio === 0)) {
|
||||
y = target.scrollTop;
|
||||
x = target.scrollLeft;
|
||||
snapInline ? target.style.scrollSnapType = snapInline : target.style.removeProperty("scroll-snap-type");
|
||||
target.scrollTop = y + 1;
|
||||
target.scrollLeft = x + 1;
|
||||
target.scrollTop = y;
|
||||
target.scrollLeft = x;
|
||||
}
|
||||
|
||||
data.xPrev = data.x;
|
||||
data.yPrev = data.y;
|
||||
ScrollTrigger && ScrollTrigger.update();
|
||||
},
|
||||
kill: function kill(property) {
|
||||
var both = property === "scrollTo",
|
||||
i = this._props.indexOf(property);
|
||||
|
||||
if (both || property === "scrollTo_x") {
|
||||
this.skipX = 1;
|
||||
}
|
||||
|
||||
if (both || property === "scrollTo_y") {
|
||||
this.skipY = 1;
|
||||
}
|
||||
|
||||
i > -1 && this._props.splice(i, 1);
|
||||
return !this._props.length;
|
||||
}
|
||||
};
|
||||
ScrollToPlugin.max = _max;
|
||||
ScrollToPlugin.getOffset = _getOffset;
|
||||
ScrollToPlugin.buildGetter = _buildGetter;
|
||||
|
||||
ScrollToPlugin.config = function (vars) {
|
||||
_config || _initCore() || (_config = gsap.config());
|
||||
|
||||
for (var p in vars) {
|
||||
_config[p] = vars[p];
|
||||
}
|
||||
};
|
||||
|
||||
_getGSAP() && gsap.registerPlugin(ScrollToPlugin);
|
||||
|
||||
exports.ScrollToPlugin = ScrollToPlugin;
|
||||
exports.default = ScrollToPlugin;
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
})));
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
/*!
|
||||
* ScrollToPlugin 3.14.2
|
||||
* https://gsap.com
|
||||
*
|
||||
* @license Copyright 2025, GreenSock. All rights reserved.
|
||||
* Subject to the terms at https://gsap.com/standard-license.
|
||||
* @author: Jack Doyle, jack@greensock.com
|
||||
*/
|
||||
|
||||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).window=e.window||{})}(this,function(e){"use strict";function l(){return"undefined"!=typeof window}function m(){return f||l()&&(f=window.gsap)&&f.registerPlugin&&f}function n(e){return"string"==typeof e}function o(e){return"function"==typeof e}function p(e,t){var o="x"===t?"Width":"Height",n="scroll"+o,r="client"+o;return e===T||e===i||e===c?Math.max(i[n],c[n])-(T["inner"+o]||i[r]||c[r]):e[n]-e["offset"+o]}function q(e,t){var o="scroll"+("x"===t?"Left":"Top");return e===T&&(null!=e.pageXOffset?o="page"+t.toUpperCase()+"Offset":e=null!=i[o]?i:c),function(){return e[o]}}function s(e,t){if(!(e=y(e)[0])||!e.getBoundingClientRect)return console.warn("scrollTo target doesn't exist. Using 0")||{x:0,y:0};var o=e.getBoundingClientRect(),n=!t||t===T||t===c,r=n?{top:i.clientTop-(T.pageYOffset||i.scrollTop||c.scrollTop||0),left:i.clientLeft-(T.pageXOffset||i.scrollLeft||c.scrollLeft||0)}:t.getBoundingClientRect(),l={x:o.left-r.left,y:o.top-r.top};return!n&&t&&(l.x+=q(t,"x")(),l.y+=q(t,"y")()),l}function t(e,t,o,r,l){return isNaN(e)||"object"==typeof e?n(e)&&"="===e.charAt(1)?parseFloat(e.substr(2))*("-"===e.charAt(0)?-1:1)+r-l:"max"===e?p(t,o)-l:Math.min(p(t,o),s(e,t)[o]-l):parseFloat(e)-l}function u(){f=m(),l()&&f&&"undefined"!=typeof document&&document.body&&(T=window,c=document.body,i=document.documentElement,y=f.utils.toArray,f.config({autoKillThreshold:7}),h=f.config(),a=1)}var f,a,T,i,c,y,h,v,r={version:"3.14.2",name:"scrollTo",rawVars:1,register:function register(e){f=e,u()},init:function init(e,r,l,i,s){a||u();var p=this,c=f.getProperty(e,"scrollSnapType");p.isWin=e===T,p.target=e,p.tween=l,r=function _clean(e,t,r,l){if(o(e)&&(e=e(t,r,l)),"object"!=typeof e)return n(e)&&"max"!==e&&"="!==e.charAt(1)?{x:e,y:e}:{y:e};if(e.nodeType)return{y:e,x:e};var i,s={};for(i in e)s[i]="onAutoKill"!==i&&o(e[i])?e[i](t,r,l):e[i];return s}(r,i,e,s),p.vars=r,p.autoKill=!!("autoKill"in r?r:h).autoKill,p.getX=q(e,"x"),p.getY=q(e,"y"),p.x=p.xPrev=p.getX(),p.y=p.yPrev=p.getY(),v=v||f.core.globals().ScrollTrigger,"smooth"===f.getProperty(e,"scrollBehavior")&&f.set(e,{scrollBehavior:"auto"}),c&&"none"!==c&&(p.snap=1,p.snapInline=e.style.scrollSnapType,e.style.scrollSnapType="none"),null!=r.x?(p.add(p,"x",p.x,t(r.x,e,"x",p.x,r.offsetX||0),i,s),p._props.push("scrollTo_x")):p.skipX=1,null!=r.y?(p.add(p,"y",p.y,t(r.y,e,"y",p.y,r.offsetY||0),i,s),p._props.push("scrollTo_y")):p.skipY=1},render:function render(e,t){for(var o,n,r,l,i,s=t._pt,c=t.target,u=t.tween,f=t.autoKill,a=t.xPrev,y=t.yPrev,d=t.isWin,g=t.snap,x=t.snapInline;s;)s.r(e,s.d),s=s._next;o=d||!t.skipX?t.getX():a,r=(n=d||!t.skipY?t.getY():y)-y,l=o-a,i=h.autoKillThreshold,t.x<0&&(t.x=0),t.y<0&&(t.y=0),f&&(!t.skipX&&(i<l||l<-i)&&o<p(c,"x")&&(t.skipX=1),!t.skipY&&(i<r||r<-i)&&n<p(c,"y")&&(t.skipY=1),t.skipX&&t.skipY&&(u.kill(),t.vars.onAutoKill&&t.vars.onAutoKill.apply(u,t.vars.onAutoKillParams||[]))),d?T.scrollTo(t.skipX?o:t.x,t.skipY?n:t.y):(t.skipY||(c.scrollTop=t.y),t.skipX||(c.scrollLeft=t.x)),!g||1!==e&&0!==e||(n=c.scrollTop,o=c.scrollLeft,x?c.style.scrollSnapType=x:c.style.removeProperty("scroll-snap-type"),c.scrollTop=n+1,c.scrollLeft=o+1,c.scrollTop=n,c.scrollLeft=o),t.xPrev=t.x,t.yPrev=t.y,v&&v.update()},kill:function kill(e){var t="scrollTo"===e,o=this._props.indexOf(e);return!t&&"scrollTo_x"!==e||(this.skipX=1),!t&&"scrollTo_y"!==e||(this.skipY=1),-1<o&&this._props.splice(o,1),!this._props.length}};r.max=p,r.getOffset=s,r.buildGetter=q,r.config=function(e){for(var t in h||u()||(h=f.config()),e)h[t]=e[t]},m()&&f.registerPlugin(r),e.ScrollToPlugin=r,e.default=r;if (typeof(window)==="undefined"||window!==e){Object.defineProperty(e,"__esModule",{value:!0})} else {delete e.default}});
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ScrollToPlugin.min.js","sources":["../src/ScrollToPlugin.js"],"sourcesContent":["/*!\n * ScrollToPlugin 3.14.2\n * https://gsap.com\n *\n * @license Copyright 2008-2025, GreenSock. All rights reserved.\n * Subject to the terms at https://gsap.com/standard-license\n * @author: Jack Doyle, jack@greensock.com\n*/\n/* eslint-disable */\n\nlet gsap, _coreInitted, _window, _docEl, _body, _toArray, _config, ScrollTrigger,\n\t_windowExists = () => typeof(window) !== \"undefined\",\n\t_getGSAP = () => gsap || (_windowExists() && (gsap = window.gsap) && gsap.registerPlugin && gsap),\n\t_isString = value => typeof(value) === \"string\",\n\t_isFunction = value => typeof(value) === \"function\",\n\t_max = (element, axis) => {\n\t\tlet dim = (axis === \"x\") ? \"Width\" : \"Height\",\n\t\t\tscroll = \"scroll\" + dim,\n\t\t\tclient = \"client\" + dim;\n\t\treturn (element === _window || element === _docEl || element === _body) ? Math.max(_docEl[scroll], _body[scroll]) - (_window[\"inner\" + dim] || _docEl[client] || _body[client]) : element[scroll] - element[\"offset\" + dim];\n\t},\n\t_buildGetter = (e, axis) => { //pass in an element and an axis (\"x\" or \"y\") and it'll return a getter function for the scroll position of that element (like scrollTop or scrollLeft, although if the element is the window, it'll use the pageXOffset/pageYOffset or the documentElement's scrollTop/scrollLeft or document.body's. Basically this streamlines things and makes a very fast getter across browsers.\n\t\tlet p = \"scroll\" + ((axis === \"x\") ? \"Left\" : \"Top\");\n\t\tif (e === _window) {\n\t\t\tif (e.pageXOffset != null) {\n\t\t\t\tp = \"page\" + axis.toUpperCase() + \"Offset\";\n\t\t\t} else {\n\t\t\t\te = _docEl[p] != null ? _docEl : _body;\n\t\t\t}\n\t\t}\n\t\treturn () => e[p];\n\t},\n\t_clean = (value, index, target, targets) => {\n\t\t_isFunction(value) && (value = value(index, target, targets));\n\t\tif (typeof(value) !== \"object\") {\n\t\t\treturn _isString(value) && value !== \"max\" && value.charAt(1) !== \"=\" ? {x: value, y: value} : {y: value}; //if we don't receive an object as the parameter, assume the user intends \"y\".\n\t\t} else if (value.nodeType) {\n\t\t\treturn {y: value, x: value};\n\t\t} else {\n\t\t\tlet result = {}, p;\n\t\t\tfor (p in value) {\n\t\t\t\tresult[p] = p !== \"onAutoKill\" && _isFunction(value[p]) ? value[p](index, target, targets) : value[p];\n\t\t\t}\n\t\t\treturn result;\n\t\t}\n\t},\n\t_getOffset = (element, container) => {\n\t\telement = _toArray(element)[0];\n\t\tif (!element || !element.getBoundingClientRect) {\n\t\t\treturn console.warn(\"scrollTo target doesn't exist. Using 0\") || {x:0, y:0};\n\t\t}\n\t\tlet rect = element.getBoundingClientRect(),\n\t\t\tisRoot = (!container || container === _window || container === _body),\n\t\t\tcRect = isRoot ? {top:_docEl.clientTop - (_window.pageYOffset || _docEl.scrollTop || _body.scrollTop || 0), left:_docEl.clientLeft - (_window.pageXOffset || _docEl.scrollLeft || _body.scrollLeft || 0)} : container.getBoundingClientRect(),\n\t\t\toffsets = {x: rect.left - cRect.left, y: rect.top - cRect.top};\n\t\tif (!isRoot && container) { //only add the current scroll position if it's not the window/body.\n\t\t\toffsets.x += _buildGetter(container, \"x\")();\n\t\t\toffsets.y += _buildGetter(container, \"y\")();\n\t\t}\n\t\treturn offsets;\n\t},\n\t_parseVal = (value, target, axis, currentVal, offset) => !isNaN(value) && typeof(value) !== \"object\" ? parseFloat(value) - offset : (_isString(value) && value.charAt(1) === \"=\") ? parseFloat(value.substr(2)) * (value.charAt(0) === \"-\" ? -1 : 1) + currentVal - offset : (value === \"max\") ? _max(target, axis) - offset : Math.min(_max(target, axis), _getOffset(value, target)[axis] - offset),\n\t_initCore = () => {\n\t\tgsap = _getGSAP();\n\t\tif (_windowExists() && gsap && typeof(document) !== \"undefined\" && document.body) {\n\t\t\t_window = window;\n\t\t\t_body = document.body;\n\t\t\t_docEl = document.documentElement;\n\t\t\t_toArray = gsap.utils.toArray;\n\t\t\tgsap.config({autoKillThreshold:7});\n\t\t\t_config = gsap.config();\n\t\t\t_coreInitted = 1;\n\t\t}\n\t};\n\n\nexport const ScrollToPlugin = {\n\tversion: \"3.14.2\",\n\tname: \"scrollTo\",\n\trawVars: 1,\n\tregister(core) {\n\t\tgsap = core;\n\t\t_initCore();\n\t},\n\tinit(target, value, tween, index, targets) {\n\t\t_coreInitted || _initCore();\n\t\tlet data = this,\n\t\t\tsnapType = gsap.getProperty(target, \"scrollSnapType\");\n\t\tdata.isWin = (target === _window);\n\t\tdata.target = target;\n\t\tdata.tween = tween;\n\t\tvalue = _clean(value, index, target, targets);\n\t\tdata.vars = value;\n\t\tdata.autoKill = !!(\"autoKill\" in value ? value : _config).autoKill;\n\t\tdata.getX = _buildGetter(target, \"x\");\n\t\tdata.getY = _buildGetter(target, \"y\");\n\t\tdata.x = data.xPrev = data.getX();\n\t\tdata.y = data.yPrev = data.getY();\n\t\tScrollTrigger || (ScrollTrigger = gsap.core.globals().ScrollTrigger);\n\t\tgsap.gLine truncated
|
||||
+3271
File diff suppressed because it is too large.
Load diff
+11
@@ -0,0 +1,11 @@
|
||||
/*!
|
||||
* ScrollTrigger 3.14.2
|
||||
* https://gsap.com
|
||||
*
|
||||
* @license Copyright 2025, GreenSock. All rights reserved.
|
||||
* Subject to the terms at https://gsap.com/standard-license.
|
||||
* @author: Jack Doyle, jack@greensock.com
|
||||
*/
|
||||
|
||||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).window=e.window||{})}(this,function(e){"use strict";function _defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function r(){return Se||"undefined"!=typeof window&&(Se=window.gsap)&&Se.registerPlugin&&Se}function z(e,t){return~Le.indexOf(e)&&Le[Le.indexOf(e)+1][t]}function A(e){return!!~t.indexOf(e)}function B(e,t,r,n,i){return e.addEventListener(t,r,{passive:!1!==n,capture:!!i})}function C(e,t,r,n){return e.removeEventListener(t,r,!!n)}function F(){return Re&&Re.isPressed||ze.cache++}function G(r,n){function fd(e){if(e||0===e){i&&(Ce.history.scrollRestoration="manual");var t=Re&&Re.isPressed;e=fd.v=Math.round(e)||(Re&&Re.iOS?1:0),r(e),fd.cacheID=ze.cache,t&&o("ss",e)}else(n||ze.cache!==fd.cacheID||o("ref"))&&(fd.cacheID=ze.cache,fd.v=r());return fd.v+fd.offset}return fd.offset=0,r&&fd}function J(e,t){return(t&&t._ctx&&t._ctx.selector||Se.utils.toArray)(e)[0]||("string"==typeof e&&!1!==Se.config().nullTargetWarn?console.warn("Element not found:",e):null)}function L(t,e){var r=e.s,n=e.sc;A(t)&&(t=ke.scrollingElement||Me);var i=ze.indexOf(t),o=n===Xe.sc?1:2;~i||(i=ze.push(t)-1),ze[i+o]||B(t,"scroll",F);var a=ze[i+o],s=a||(ze[i+o]=G(z(t,r),!0)||(A(t)?n:G(function(e){return arguments.length?t[r]=e:t[r]})));return s.target=t,a||(s.smooth="smooth"===Se.getProperty(t,"scrollBehavior")),s}function M(e,t,i){function Hd(e,t){var r=Ye();t||n<r-s?(a=o,o=e,l=s,s=r):i?o+=e:o=a+(e-a)/(r-l)*(s-l)}var o=e,a=e,s=Ye(),l=s,n=t||50,c=Math.max(500,3*n);return{update:Hd,reset:function reset(){a=o=i?0:o,l=s=0},getVelocity:function getVelocity(e){var t=l,r=a,n=Ye();return!e&&0!==e||e===o||Hd(e),s===l||c<n-l?0:(o+(i?r:-r))/((i?n:s)-t)*1e3}}}function N(e,t){return t&&!e._gsapAllow&&e.preventDefault(),e.changedTouches?e.changedTouches[0]:e}function O(e){var t=Math.max.apply(Math,e),r=Math.min.apply(Math,e);return Math.abs(t)>=Math.abs(r)?t:r}function P(){(Ae=Se.core.globals().ScrollTrigger)&&Ae.core&&function _integrate(){var e=Ae.core,r=e.bridge||{},t=e._scrollers,n=e._proxies;t.push.apply(t,ze),n.push.apply(n,Le),ze=t,Le=n,o=function _bridge(e,t){return r[e](t)}}()}function Q(e){return Se=e||r(),!Te&&Se&&"undefined"!=typeof document&&document.body&&(Ce=window,Me=(ke=document).documentElement,Ee=ke.body,t=[Ce,ke,Me,Ee],Se.utils.clamp,Ie=Se.core.context||function(){},Oe="onpointerenter"in Ee?"pointer":"mouse",Pe=k.isTouch=Ce.matchMedia&&Ce.matchMedia("(hover: none), (pointer: coarse)").matches?1:"ontouchstart"in Ce||0<navigator.maxTouchPoints||0<navigator.msMaxTouchPoints?2:0,De=k.eventTypes=("ontouchstart"in Me?"touchstart,touchmove,touchcancel,touchend":"onpointerdown"in Me?"pointerdown,pointermove,pointercancel,pointerup":"mousedown,mousemove,mouseup,mouseup").split(","),setTimeout(function(){return i=0},500),P(),Te=1),Te}var Se,Te,Ce,ke,Me,Ee,Pe,Oe,Ae,t,Re,De,Ie,i=1,Be=[],ze=[],Le=[],Ye=Date.now,o=function _bridge(e,t){return t},n="scrollLeft",a="scrollTop",Ne={s:n,p:"left",p2:"Left",os:"right",os2:"Right",d:"width",d2:"Width",a:"x",sc:G(function(e){return arguments.length?Ce.scrollTo(e,Xe.sc()):Ce.pageXOffset||ke[n]||Me[n]||Ee[n]||0})},Xe={s:a,p:"top",p2:"Top",os:"bottom",os2:"Bottom",d:"height",d2:"Height",a:"y",op:Ne,sc:G(function(e){return arguments.length?Ce.scrollTo(Ne.sc(),e):Ce.pageYOffset||ke[a]||Me[a]||Ee[a]||0})};Ne.op=Xe,ze.cache=0;var k=(Observer.prototype.init=function init(e){Te||Q(Se)||console.warn("Please gsap.registerPlugin(Observer)"),Ae||P();var i=e.tolerance,a=e.dragMinimum,t=e.type,o=e.target,r=e.lineHeight,n=e.debounce,s=e.preventDefault,l=e.onStop,c=e.onStopDelay,u=e.ignore,f=e.wheelSpeed,d=e.event,p=e.onDragStart,g=e.onDragEnd,h=e.onDrag,v=e.onPress,b=e.onRelease,m=e.onRight,y=e.onLeft,x=e.onUp,_=e.onDown,w=e.onChangeX,S=e.onChangeY,T=e.onChange,k=e.onToggleX,E=e.onToggleY,R=e.onHover,D=e.onHoverEnd,I=e.onMove,z=e.ignoreCheck,Y=e.isNormalizer,X=e.onGestureStart,q=e.onGestureEnd,U=e.onWheel,H=e.onEnable,W=e.onDisable,V=e.onClick,G=e.scrollSpeed,K=e.capture,j=e.allowClicks,$=e.lockAxis,Z=e.onLockAxis;function hf(){return xe=Ye()}function jf(e,t){return(se.event=e)&&u&&function _isWithin(e,t){for(var r=t.length;r--;)if(t[r]===e||t[r].contains(e))return!0;return!1}(e.target,u)||t&&he&&"touch"!==e.pointerType||z&&z(e,t)}function lf(){var e=se.deltaX=O(me),t=se.deltaY=O(ye),r=Math.abs(e)>=i,n=Math.abs(t)>=i;T&&(r||n)&&T(se,e,t,me,ye),r&&(m&&0<se.deltaX&&m(se),y&&se.deltaX<0&&y(se),w&&w(se),k&&se.deltaX<0!=le<0&&k(se),le=se.deltaX,me[0]=me[1]=me[2]=0),n&&(_&&0<se.deltaY&&_(se),x&&se.deltaY<0&&x(se),S&&S(se),E&&se.deltaY<0!=ce<0&&E(se),ce=se.deltaY,ye[0]=ye[1]=ye[2]=0),(ne||re)&&(I&&I(se),re&&(p&&1===re&&p(se),h&&h(se),re=0),ne=!1),oe&&!(oe=!1)&&Z&&Z(se),ie&&(U(se),ie=!1),ee=0}function mf(e,t,r){me[r]+=e,ye[r]+=t,se._vx.update(e),se._vy.updateLine truncated
|
||||
|
||||
Loaded 100 of 362 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user