@tsparticles/interaction-external-grab
Advanced tools
Comparing version 3.1.0 to 3.2.0
@@ -1,4 +0,6 @@ | ||
import { Grabber } from "./Grabber.js"; | ||
export async function loadExternalGrabInteraction(engine, refresh = true) { | ||
await engine.addInteractor("externalGrab", (container) => new Grabber(container), refresh); | ||
await engine.addInteractor("externalGrab", async (container) => { | ||
const { Grabber } = await import("./Grabber.js"); | ||
return new Grabber(container); | ||
}, refresh); | ||
} | ||
@@ -5,0 +7,0 @@ export * from "./Options/Classes/Grab.js"; |
@@ -13,2 +13,14 @@ "use strict"; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
@@ -19,5 +31,7 @@ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
exports.loadExternalGrabInteraction = void 0; | ||
const Grabber_js_1 = require("./Grabber.js"); | ||
async function loadExternalGrabInteraction(engine, refresh = true) { | ||
await engine.addInteractor("externalGrab", (container) => new Grabber_js_1.Grabber(container), refresh); | ||
await engine.addInteractor("externalGrab", async (container) => { | ||
const { Grabber } = await Promise.resolve().then(() => __importStar(require("./Grabber.js"))); | ||
return new Grabber(container); | ||
}, refresh); | ||
} | ||
@@ -24,0 +38,0 @@ exports.loadExternalGrabInteraction = loadExternalGrabInteraction; |
@@ -1,4 +0,6 @@ | ||
import { Grabber } from "./Grabber.js"; | ||
export async function loadExternalGrabInteraction(engine, refresh = true) { | ||
await engine.addInteractor("externalGrab", (container) => new Grabber(container), refresh); | ||
await engine.addInteractor("externalGrab", async (container) => { | ||
const { Grabber } = await import("./Grabber.js"); | ||
return new Grabber(container); | ||
}, refresh); | ||
} | ||
@@ -5,0 +7,0 @@ export * from "./Options/Classes/Grab.js"; |
{ | ||
"name": "@tsparticles/interaction-external-grab", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"description": "tsParticles grab external interaction", | ||
@@ -90,3 +90,3 @@ "homepage": "https://particles.js.org", | ||
"dependencies": { | ||
"@tsparticles/engine": "^3.1.0" | ||
"@tsparticles/engine": "^3.2.0" | ||
}, | ||
@@ -93,0 +93,0 @@ "publishConfig": { |
@@ -7,4 +7,12 @@ /*! | ||
* How to use? : Check the GitHub README | ||
* v3.1.0 | ||
* v3.2.0 | ||
*/ | ||
/* | ||
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development"). | ||
* This devtool is neither made for production nor for readable output files. | ||
* It uses "eval()" calls to create a separate source file in the browser devtools. | ||
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/) | ||
* or disable the default devtool with "devtool: false". | ||
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/). | ||
*/ | ||
(function webpackUniversalModuleDefinition(root, factory) { | ||
@@ -19,3 +27,3 @@ if(typeof exports === 'object' && typeof module === 'object') | ||
} | ||
})(this, (__WEBPACK_EXTERNAL_MODULE__533__) => { | ||
})(this, (__WEBPACK_EXTERNAL_MODULE__tsparticles_engine__) => { | ||
return /******/ (() => { // webpackBootstrap | ||
@@ -25,6 +33,39 @@ /******/ "use strict"; | ||
/***/ 533: | ||
/***/ "./dist/browser/Options/Classes/Grab.js": | ||
/*!**********************************************!*\ | ||
!*** ./dist/browser/Options/Classes/Grab.js ***! | ||
\**********************************************/ | ||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { | ||
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Grab: () => (/* binding */ Grab)\n/* harmony export */ });\n/* harmony import */ var _GrabLinks_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./GrabLinks.js */ \"./dist/browser/Options/Classes/GrabLinks.js\");\n\nclass Grab {\n constructor() {\n this.distance = 100;\n this.links = new _GrabLinks_js__WEBPACK_IMPORTED_MODULE_0__.GrabLinks();\n }\n load(data) {\n if (!data) {\n return;\n }\n if (data.distance !== undefined) {\n this.distance = data.distance;\n }\n this.links.load(data.links);\n }\n}\n\n//# sourceURL=webpack://@tsparticles/interaction-external-grab/./dist/browser/Options/Classes/Grab.js?"); | ||
/***/ }), | ||
/***/ "./dist/browser/Options/Classes/GrabLinks.js": | ||
/*!***************************************************!*\ | ||
!*** ./dist/browser/Options/Classes/GrabLinks.js ***! | ||
\***************************************************/ | ||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { | ||
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ GrabLinks: () => (/* binding */ GrabLinks)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n\nclass GrabLinks {\n constructor() {\n this.blink = false;\n this.consent = false;\n this.opacity = 1;\n }\n load(data) {\n if (!data) {\n return;\n }\n if (data.blink !== undefined) {\n this.blink = data.blink;\n }\n if (data.color !== undefined) {\n this.color = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OptionsColor.create(this.color, data.color);\n }\n if (data.consent !== undefined) {\n this.consent = data.consent;\n }\n if (data.opacity !== undefined) {\n this.opacity = data.opacity;\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/interaction-external-grab/./dist/browser/Options/Classes/GrabLinks.js?"); | ||
/***/ }), | ||
/***/ "./dist/browser/index.js": | ||
/*!*******************************!*\ | ||
!*** ./dist/browser/index.js ***! | ||
\*******************************/ | ||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { | ||
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Grab: () => (/* reexport safe */ _Options_Classes_Grab_js__WEBPACK_IMPORTED_MODULE_0__.Grab),\n/* harmony export */ GrabLinks: () => (/* reexport safe */ _Options_Classes_GrabLinks_js__WEBPACK_IMPORTED_MODULE_1__.GrabLinks),\n/* harmony export */ loadExternalGrabInteraction: () => (/* binding */ loadExternalGrabInteraction)\n/* harmony export */ });\n/* harmony import */ var _Options_Classes_Grab_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Options/Classes/Grab.js */ \"./dist/browser/Options/Classes/Grab.js\");\n/* harmony import */ var _Options_Classes_GrabLinks_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Options/Classes/GrabLinks.js */ \"./dist/browser/Options/Classes/GrabLinks.js\");\nasync function loadExternalGrabInteraction(engine, refresh = true) {\n await engine.addInteractor(\"externalGrab\", async container => {\n const {\n Grabber\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_Grabber_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./Grabber.js */ \"./dist/browser/Grabber.js\"));\n return new Grabber(container);\n }, refresh);\n}\n\n\n\n\n\n//# sourceURL=webpack://@tsparticles/interaction-external-grab/./dist/browser/index.js?"); | ||
/***/ }), | ||
/***/ "@tsparticles/engine": | ||
/*!*********************************************************************************************************************************!*\ | ||
!*** external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"} ***! | ||
\*********************************************************************************************************************************/ | ||
/***/ ((module) => { | ||
module.exports = __WEBPACK_EXTERNAL_MODULE__533__; | ||
module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__; | ||
@@ -59,3 +100,18 @@ /***/ }) | ||
/******/ | ||
/******/ // expose the modules object (__webpack_modules__) | ||
/******/ __webpack_require__.m = __webpack_modules__; | ||
/******/ | ||
/************************************************************************/ | ||
/******/ /* webpack/runtime/compat get default export */ | ||
/******/ (() => { | ||
/******/ // getDefaultExport function for compatibility with non-harmony modules | ||
/******/ __webpack_require__.n = (module) => { | ||
/******/ var getter = module && module.__esModule ? | ||
/******/ () => (module['default']) : | ||
/******/ () => (module); | ||
/******/ __webpack_require__.d(getter, { a: getter }); | ||
/******/ return getter; | ||
/******/ }; | ||
/******/ })(); | ||
/******/ | ||
/******/ /* webpack/runtime/define property getters */ | ||
@@ -73,2 +129,36 @@ /******/ (() => { | ||
/******/ | ||
/******/ /* webpack/runtime/ensure chunk */ | ||
/******/ (() => { | ||
/******/ __webpack_require__.f = {}; | ||
/******/ // This file contains only the entry chunk. | ||
/******/ // The chunk loading function for additional chunks | ||
/******/ __webpack_require__.e = (chunkId) => { | ||
/******/ return Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key) => { | ||
/******/ __webpack_require__.f[key](chunkId, promises); | ||
/******/ return promises; | ||
/******/ }, [])); | ||
/******/ }; | ||
/******/ })(); | ||
/******/ | ||
/******/ /* webpack/runtime/get javascript chunk filename */ | ||
/******/ (() => { | ||
/******/ // This function allow to reference async chunks | ||
/******/ __webpack_require__.u = (chunkId) => { | ||
/******/ // return url for filenames based on template | ||
/******/ return "" + chunkId + ".js"; | ||
/******/ }; | ||
/******/ })(); | ||
/******/ | ||
/******/ /* webpack/runtime/global */ | ||
/******/ (() => { | ||
/******/ __webpack_require__.g = (function() { | ||
/******/ if (typeof globalThis === 'object') return globalThis; | ||
/******/ try { | ||
/******/ return this || new Function('return this')(); | ||
/******/ } catch (e) { | ||
/******/ if (typeof window === 'object') return window; | ||
/******/ } | ||
/******/ })(); | ||
/******/ })(); | ||
/******/ | ||
/******/ /* webpack/runtime/hasOwnProperty shorthand */ | ||
@@ -79,2 +169,48 @@ /******/ (() => { | ||
/******/ | ||
/******/ /* webpack/runtime/load script */ | ||
/******/ (() => { | ||
/******/ var inProgress = {}; | ||
/******/ var dataWebpackPrefix = "@tsparticles/interaction-external-grab:"; | ||
/******/ // loadScript function to load a script via script tag | ||
/******/ __webpack_require__.l = (url, done, key, chunkId) => { | ||
/******/ if(inProgress[url]) { inProgress[url].push(done); return; } | ||
/******/ var script, needAttach; | ||
/******/ if(key !== undefined) { | ||
/******/ var scripts = document.getElementsByTagName("script"); | ||
/******/ for(var i = 0; i < scripts.length; i++) { | ||
/******/ var s = scripts[i]; | ||
/******/ if(s.getAttribute("src") == url || s.getAttribute("data-webpack") == dataWebpackPrefix + key) { script = s; break; } | ||
/******/ } | ||
/******/ } | ||
/******/ if(!script) { | ||
/******/ needAttach = true; | ||
/******/ script = document.createElement('script'); | ||
/******/ | ||
/******/ script.charset = 'utf-8'; | ||
/******/ script.timeout = 120; | ||
/******/ if (__webpack_require__.nc) { | ||
/******/ script.setAttribute("nonce", __webpack_require__.nc); | ||
/******/ } | ||
/******/ script.setAttribute("data-webpack", dataWebpackPrefix + key); | ||
/******/ | ||
/******/ script.src = url; | ||
/******/ } | ||
/******/ inProgress[url] = [done]; | ||
/******/ var onScriptComplete = (prev, event) => { | ||
/******/ // avoid mem leaks in IE. | ||
/******/ script.onerror = script.onload = null; | ||
/******/ clearTimeout(timeout); | ||
/******/ var doneFns = inProgress[url]; | ||
/******/ delete inProgress[url]; | ||
/******/ script.parentNode && script.parentNode.removeChild(script); | ||
/******/ doneFns && doneFns.forEach((fn) => (fn(event))); | ||
/******/ if(prev) return prev(event); | ||
/******/ } | ||
/******/ var timeout = setTimeout(onScriptComplete.bind(null, undefined, { type: 'timeout', target: script }), 120000); | ||
/******/ script.onerror = onScriptComplete.bind(null, script.onerror); | ||
/******/ script.onload = onScriptComplete.bind(null, script.onload); | ||
/******/ needAttach && document.head.appendChild(script); | ||
/******/ }; | ||
/******/ })(); | ||
/******/ | ||
/******/ /* webpack/runtime/make namespace object */ | ||
@@ -91,164 +227,124 @@ /******/ (() => { | ||
/******/ | ||
/******/ /* webpack/runtime/publicPath */ | ||
/******/ (() => { | ||
/******/ var scriptUrl; | ||
/******/ if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + ""; | ||
/******/ var document = __webpack_require__.g.document; | ||
/******/ if (!scriptUrl && document) { | ||
/******/ if (document.currentScript) | ||
/******/ scriptUrl = document.currentScript.src; | ||
/******/ if (!scriptUrl) { | ||
/******/ var scripts = document.getElementsByTagName("script"); | ||
/******/ if(scripts.length) { | ||
/******/ var i = scripts.length - 1; | ||
/******/ while (i > -1 && !scriptUrl) scriptUrl = scripts[i--].src; | ||
/******/ } | ||
/******/ } | ||
/******/ } | ||
/******/ // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration | ||
/******/ // or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic. | ||
/******/ if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser"); | ||
/******/ scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/"); | ||
/******/ __webpack_require__.p = scriptUrl; | ||
/******/ })(); | ||
/******/ | ||
/******/ /* webpack/runtime/jsonp chunk loading */ | ||
/******/ (() => { | ||
/******/ // no baseURI | ||
/******/ | ||
/******/ // object to store loaded and loading chunks | ||
/******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched | ||
/******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded | ||
/******/ var installedChunks = { | ||
/******/ "tsparticles.interaction.external.grab": 0 | ||
/******/ }; | ||
/******/ | ||
/******/ __webpack_require__.f.j = (chunkId, promises) => { | ||
/******/ // JSONP chunk loading for javascript | ||
/******/ var installedChunkData = __webpack_require__.o(installedChunks, chunkId) ? installedChunks[chunkId] : undefined; | ||
/******/ if(installedChunkData !== 0) { // 0 means "already installed". | ||
/******/ | ||
/******/ // a Promise means "currently loading". | ||
/******/ if(installedChunkData) { | ||
/******/ promises.push(installedChunkData[2]); | ||
/******/ } else { | ||
/******/ if(true) { // all chunks have JS | ||
/******/ // setup Promise in chunk cache | ||
/******/ var promise = new Promise((resolve, reject) => (installedChunkData = installedChunks[chunkId] = [resolve, reject])); | ||
/******/ promises.push(installedChunkData[2] = promise); | ||
/******/ | ||
/******/ // start chunk loading | ||
/******/ var url = __webpack_require__.p + __webpack_require__.u(chunkId); | ||
/******/ // create error before stack unwound to get useful stacktrace later | ||
/******/ var error = new Error(); | ||
/******/ var loadingEnded = (event) => { | ||
/******/ if(__webpack_require__.o(installedChunks, chunkId)) { | ||
/******/ installedChunkData = installedChunks[chunkId]; | ||
/******/ if(installedChunkData !== 0) installedChunks[chunkId] = undefined; | ||
/******/ if(installedChunkData) { | ||
/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type); | ||
/******/ var realSrc = event && event.target && event.target.src; | ||
/******/ error.message = 'Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')'; | ||
/******/ error.name = 'ChunkLoadError'; | ||
/******/ error.type = errorType; | ||
/******/ error.request = realSrc; | ||
/******/ installedChunkData[1](error); | ||
/******/ } | ||
/******/ } | ||
/******/ }; | ||
/******/ __webpack_require__.l(url, loadingEnded, "chunk-" + chunkId, chunkId); | ||
/******/ } | ||
/******/ } | ||
/******/ } | ||
/******/ }; | ||
/******/ | ||
/******/ // no prefetching | ||
/******/ | ||
/******/ // no preloaded | ||
/******/ | ||
/******/ // no HMR | ||
/******/ | ||
/******/ // no HMR manifest | ||
/******/ | ||
/******/ // no on chunks loaded | ||
/******/ | ||
/******/ // install a JSONP callback for chunk loading | ||
/******/ var webpackJsonpCallback = (parentChunkLoadingFunction, data) => { | ||
/******/ var chunkIds = data[0]; | ||
/******/ var moreModules = data[1]; | ||
/******/ var runtime = data[2]; | ||
/******/ // add "moreModules" to the modules object, | ||
/******/ // then flag all "chunkIds" as loaded and fire callback | ||
/******/ var moduleId, chunkId, i = 0; | ||
/******/ if(chunkIds.some((id) => (installedChunks[id] !== 0))) { | ||
/******/ for(moduleId in moreModules) { | ||
/******/ if(__webpack_require__.o(moreModules, moduleId)) { | ||
/******/ __webpack_require__.m[moduleId] = moreModules[moduleId]; | ||
/******/ } | ||
/******/ } | ||
/******/ if(runtime) var result = runtime(__webpack_require__); | ||
/******/ } | ||
/******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data); | ||
/******/ for(;i < chunkIds.length; i++) { | ||
/******/ chunkId = chunkIds[i]; | ||
/******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) { | ||
/******/ installedChunks[chunkId][0](); | ||
/******/ } | ||
/******/ installedChunks[chunkId] = 0; | ||
/******/ } | ||
/******/ | ||
/******/ } | ||
/******/ | ||
/******/ var chunkLoadingGlobal = this["webpackChunk_tsparticles_interaction_external_grab"] = this["webpackChunk_tsparticles_interaction_external_grab"] || []; | ||
/******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0)); | ||
/******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal)); | ||
/******/ })(); | ||
/******/ | ||
/************************************************************************/ | ||
var __webpack_exports__ = {}; | ||
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. | ||
(() => { | ||
// ESM COMPAT FLAG | ||
__webpack_require__.r(__webpack_exports__); | ||
// EXPORTS | ||
__webpack_require__.d(__webpack_exports__, { | ||
Grab: () => (/* reexport */ Grab), | ||
GrabLinks: () => (/* reexport */ GrabLinks), | ||
loadExternalGrabInteraction: () => (/* binding */ loadExternalGrabInteraction) | ||
}); | ||
// EXTERNAL MODULE: external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"} | ||
var engine_root_window_ = __webpack_require__(533); | ||
;// CONCATENATED MODULE: ./dist/browser/Options/Classes/GrabLinks.js | ||
class GrabLinks { | ||
constructor() { | ||
this.blink = false; | ||
this.consent = false; | ||
this.opacity = 1; | ||
} | ||
load(data) { | ||
if (!data) { | ||
return; | ||
} | ||
if (data.blink !== undefined) { | ||
this.blink = data.blink; | ||
} | ||
if (data.color !== undefined) { | ||
this.color = engine_root_window_.OptionsColor.create(this.color, data.color); | ||
} | ||
if (data.consent !== undefined) { | ||
this.consent = data.consent; | ||
} | ||
if (data.opacity !== undefined) { | ||
this.opacity = data.opacity; | ||
} | ||
} | ||
} | ||
;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Grab.js | ||
class Grab { | ||
constructor() { | ||
this.distance = 100; | ||
this.links = new GrabLinks(); | ||
} | ||
load(data) { | ||
if (!data) { | ||
return; | ||
} | ||
if (data.distance !== undefined) { | ||
this.distance = data.distance; | ||
} | ||
this.links.load(data.links); | ||
} | ||
} | ||
;// CONCATENATED MODULE: ./dist/browser/Utils.js | ||
const defaultWidth = 0; | ||
function drawGrabLine(context, width, begin, end, colorLine, opacity) { | ||
(0,engine_root_window_.drawLine)(context, begin, end); | ||
context.strokeStyle = (0,engine_root_window_.getStyleFromRgb)(colorLine, opacity); | ||
context.lineWidth = width; | ||
context.stroke(); | ||
} | ||
function drawGrab(container, particle, lineColor, opacity, mousePos) { | ||
container.canvas.draw(ctx => { | ||
const beginPos = particle.getPosition(); | ||
drawGrabLine(ctx, particle.retina.linksWidth ?? defaultWidth, beginPos, mousePos, lineColor, opacity); | ||
}); | ||
} | ||
;// CONCATENATED MODULE: ./dist/browser/Grabber.js | ||
const grabMode = "grab", | ||
minDistance = 0, | ||
minOpacity = 0; | ||
class Grabber extends engine_root_window_.ExternalInteractorBase { | ||
constructor(container) { | ||
super(container); | ||
} | ||
clear() {} | ||
init() { | ||
const container = this.container, | ||
grab = container.actualOptions.interactivity.modes.grab; | ||
if (!grab) { | ||
return; | ||
} | ||
container.retina.grabModeDistance = grab.distance * container.retina.pixelRatio; | ||
} | ||
async interact() { | ||
const container = this.container, | ||
options = container.actualOptions, | ||
interactivity = options.interactivity; | ||
if (!interactivity.modes.grab || !interactivity.events.onHover.enable || container.interactivity.status !== engine_root_window_.mouseMoveEvent) { | ||
return; | ||
} | ||
const mousePos = container.interactivity.mouse.position; | ||
if (!mousePos) { | ||
return; | ||
} | ||
const distance = container.retina.grabModeDistance; | ||
if (!distance || distance < minDistance) { | ||
return; | ||
} | ||
const query = container.particles.quadTree.queryCircle(mousePos, distance, p => this.isEnabled(p)); | ||
for (const particle of query) { | ||
const pos = particle.getPosition(), | ||
pointDistance = (0,engine_root_window_.getDistance)(pos, mousePos); | ||
if (pointDistance > distance) { | ||
continue; | ||
} | ||
const grabLineOptions = interactivity.modes.grab.links, | ||
lineOpacity = grabLineOptions.opacity, | ||
opacityLine = lineOpacity - pointDistance * lineOpacity / distance; | ||
if (opacityLine <= minOpacity) { | ||
continue; | ||
} | ||
const optColor = grabLineOptions.color ?? particle.options.links?.color; | ||
if (!container.particles.grabLineColor && optColor) { | ||
const linksOptions = interactivity.modes.grab.links; | ||
container.particles.grabLineColor = (0,engine_root_window_.getLinkRandomColor)(optColor, linksOptions.blink, linksOptions.consent); | ||
} | ||
const colorLine = (0,engine_root_window_.getLinkColor)(particle, undefined, container.particles.grabLineColor); | ||
if (!colorLine) { | ||
continue; | ||
} | ||
drawGrab(container, particle, colorLine, opacityLine, mousePos); | ||
} | ||
await Promise.resolve(); | ||
} | ||
isEnabled(particle) { | ||
const container = this.container, | ||
mouse = container.interactivity.mouse, | ||
events = (particle?.interactivity ?? container.actualOptions.interactivity).events; | ||
return events.onHover.enable && !!mouse.position && (0,engine_root_window_.isInArray)(grabMode, events.onHover.mode); | ||
} | ||
loadModeOptions(options, ...sources) { | ||
if (!options.grab) { | ||
options.grab = new Grab(); | ||
} | ||
for (const source of sources) { | ||
options.grab.load(source?.grab); | ||
} | ||
} | ||
reset() {} | ||
} | ||
;// CONCATENATED MODULE: ./dist/browser/index.js | ||
async function loadExternalGrabInteraction(engine, refresh = true) { | ||
await engine.addInteractor("externalGrab", container => new Grabber(container), refresh); | ||
} | ||
})(); | ||
/******/ | ||
/******/ // startup | ||
/******/ // Load entry module and return exports | ||
/******/ // This entry module can't be inlined because the eval devtool is used. | ||
/******/ var __webpack_exports__ = __webpack_require__("./dist/browser/index.js"); | ||
/******/ | ||
/******/ return __webpack_exports__; | ||
@@ -255,0 +351,0 @@ /******/ })() |
/*! For license information please see tsparticles.interaction.external.grab.min.js.LICENSE.txt */ | ||
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],e);else{var o="object"==typeof exports?e(require("@tsparticles/engine")):e(t.window);for(var i in o)("object"==typeof exports?exports:t)[i]=o[i]}}(this,(t=>(()=>{"use strict";var e={533:e=>{e.exports=t}},o={};function i(t){var n=o[t];if(void 0!==n)return n.exports;var r=o[t]={exports:{}};return e[t](r,r.exports,i),r.exports}i.d=(t,e)=>{for(var o in e)i.o(e,o)&&!i.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};return(()=>{i.r(n),i.d(n,{Grab:()=>o,GrabLinks:()=>e,loadExternalGrabInteraction:()=>a});var t=i(533);class e{constructor(){this.blink=!1,this.consent=!1,this.opacity=1}load(e){e&&(void 0!==e.blink&&(this.blink=e.blink),void 0!==e.color&&(this.color=t.OptionsColor.create(this.color,e.color)),void 0!==e.consent&&(this.consent=e.consent),void 0!==e.opacity&&(this.opacity=e.opacity))}}class o{constructor(){this.distance=100,this.links=new e}load(t){t&&(void 0!==t.distance&&(this.distance=t.distance),this.links.load(t.links))}}function r(e,o,i,n,r){e.canvas.draw((e=>{const s=o.getPosition();!function(e,o,i,n,r,s){(0,t.drawLine)(e,i,n),e.strokeStyle=(0,t.getStyleFromRgb)(r,s),e.lineWidth=o,e.stroke()}(e,o.retina.linksWidth??0,s,r,i,n)}))}class s extends t.ExternalInteractorBase{constructor(t){super(t)}clear(){}init(){const t=this.container,e=t.actualOptions.interactivity.modes.grab;e&&(t.retina.grabModeDistance=e.distance*t.retina.pixelRatio)}async interact(){const e=this.container,o=e.actualOptions.interactivity;if(!o.modes.grab||!o.events.onHover.enable||e.interactivity.status!==t.mouseMoveEvent)return;const i=e.interactivity.mouse.position;if(!i)return;const n=e.retina.grabModeDistance;if(!n||n<0)return;const s=e.particles.quadTree.queryCircle(i,n,(t=>this.isEnabled(t)));for(const a of s){const s=a.getPosition(),c=(0,t.getDistance)(s,i);if(c>n)continue;const l=o.modes.grab.links,d=l.opacity,p=d-c*d/n;if(p<=0)continue;const b=l.color??a.options.links?.color;if(!e.particles.grabLineColor&&b){const i=o.modes.grab.links;e.particles.grabLineColor=(0,t.getLinkRandomColor)(b,i.blink,i.consent)}const u=(0,t.getLinkColor)(a,void 0,e.particles.grabLineColor);u&&r(e,a,u,p,i)}await Promise.resolve()}isEnabled(e){const o=this.container,i=o.interactivity.mouse,n=(e?.interactivity??o.actualOptions.interactivity).events;return n.onHover.enable&&!!i.position&&(0,t.isInArray)("grab",n.onHover.mode)}loadModeOptions(t,...e){t.grab||(t.grab=new o);for(const o of e)t.grab.load(o?.grab)}reset(){}}async function a(t,e=!0){await t.addInteractor("externalGrab",(t=>new s(t)),e)}})(),n})())); | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],t);else{var r="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var o in r)("object"==typeof exports?exports:e)[o]=r[o]}}(this,(e=>(()=>{var t,r,o={30:(e,t,r)=>{r.d(t,{z:()=>n});var o=r(715);class n{constructor(){this.distance=100,this.links=new o.p}load(e){e&&(void 0!==e.distance&&(this.distance=e.distance),this.links.load(e.links))}}},715:(e,t,r)=>{r.d(t,{p:()=>n});var o=r(533);class n{constructor(){this.blink=!1,this.consent=!1,this.opacity=1}load(e){e&&(void 0!==e.blink&&(this.blink=e.blink),void 0!==e.color&&(this.color=o.OptionsColor.create(this.color,e.color)),void 0!==e.consent&&(this.consent=e.consent),void 0!==e.opacity&&(this.opacity=e.opacity))}}},533:t=>{t.exports=e}},n={};function i(e){var t=n[e];if(void 0!==t)return t.exports;var r=n[e]={exports:{}};return o[e](r,r.exports,i),r.exports}i.m=o,i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.f={},i.e=e=>Promise.all(Object.keys(i.f).reduce(((t,r)=>(i.f[r](e,t),t)),[])),i.u=e=>e+".min.js",i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),t={},r="@tsparticles/interaction-external-grab:",i.l=(e,o,n,a)=>{if(t[e])t[e].push(o);else{var s,c;if(void 0!==n)for(var l=document.getElementsByTagName("script"),d=0;d<l.length;d++){var p=l[d];if(p.getAttribute("src")==e||p.getAttribute("data-webpack")==r+n){s=p;break}}s||(c=!0,(s=document.createElement("script")).charset="utf-8",s.timeout=120,i.nc&&s.setAttribute("nonce",i.nc),s.setAttribute("data-webpack",r+n),s.src=e),t[e]=[o];var u=(r,o)=>{s.onerror=s.onload=null,clearTimeout(f);var n=t[e];if(delete t[e],s.parentNode&&s.parentNode.removeChild(s),n&&n.forEach((e=>e(o))),r)return r(o)},f=setTimeout(u.bind(null,void 0,{type:"timeout",target:s}),12e4);s.onerror=u.bind(null,s.onerror),s.onload=u.bind(null,s.onload),c&&document.head.appendChild(s)}},i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;i.g.importScripts&&(e=i.g.location+"");var t=i.g.document;if(!e&&t&&(t.currentScript&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");if(r.length)for(var o=r.length-1;o>-1&&!e;)e=r[o--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),i.p=e})(),(()=>{var e={169:0};i.f.j=(t,r)=>{var o=i.o(e,t)?e[t]:void 0;if(0!==o)if(o)r.push(o[2]);else{var n=new Promise(((r,n)=>o=e[t]=[r,n]));r.push(o[2]=n);var a=i.p+i.u(t),s=new Error;i.l(a,(r=>{if(i.o(e,t)&&(0!==(o=e[t])&&(e[t]=void 0),o)){var n=r&&("load"===r.type?"missing":r.type),a=r&&r.target&&r.target.src;s.message="Loading chunk "+t+" failed.\n("+n+": "+a+")",s.name="ChunkLoadError",s.type=n,s.request=a,o[1](s)}}),"chunk-"+t,t)}};var t=(t,r)=>{var o,n,a=r[0],s=r[1],c=r[2],l=0;if(a.some((t=>0!==e[t]))){for(o in s)i.o(s,o)&&(i.m[o]=s[o]);if(c)c(i)}for(t&&t(r);l<a.length;l++)n=a[l],i.o(e,n)&&e[n]&&e[n][0](),e[n]=0},r=this.webpackChunk_tsparticles_interaction_external_grab=this.webpackChunk_tsparticles_interaction_external_grab||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})();var a={};return(()=>{i.r(a),i.d(a,{Grab:()=>e.z,GrabLinks:()=>t.p,loadExternalGrabInteraction:()=>r});var e=i(30),t=i(715);async function r(e,t=!0){await e.addInteractor("externalGrab",(async e=>{const{Grabber:t}=await i.e(690).then(i.bind(i,690));return new t(e)}),t)}})(),a})())); |
@@ -1,1 +0,1 @@ | ||
/*! tsParticles Grab External Interaction v3.1.0 by Matteo Bruni */ | ||
/*! tsParticles Grab External Interaction v3.2.0 by Matteo Bruni */ |
@@ -12,2 +12,14 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
@@ -22,11 +34,14 @@ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
else if (typeof define === "function" && define.amd) { | ||
define(["require", "exports", "./Grabber.js", "./Options/Classes/Grab.js", "./Options/Classes/GrabLinks.js", "./Options/Interfaces/IGrab.js", "./Options/Interfaces/IGrabLinks.js"], factory); | ||
define(["require", "exports", "./Options/Classes/Grab.js", "./Options/Classes/GrabLinks.js", "./Options/Interfaces/IGrab.js", "./Options/Interfaces/IGrabLinks.js"], factory); | ||
} | ||
})(function (require, exports) { | ||
"use strict"; | ||
var __syncRequire = typeof module === "object" && typeof module.exports === "object"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.loadExternalGrabInteraction = void 0; | ||
const Grabber_js_1 = require("./Grabber.js"); | ||
async function loadExternalGrabInteraction(engine, refresh = true) { | ||
await engine.addInteractor("externalGrab", (container) => new Grabber_js_1.Grabber(container), refresh); | ||
await engine.addInteractor("externalGrab", async (container) => { | ||
const { Grabber } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./Grabber.js"))) : new Promise((resolve_1, reject_1) => { require(["./Grabber.js"], resolve_1, reject_1); }).then(__importStar)); | ||
return new Grabber(container); | ||
}, refresh); | ||
} | ||
@@ -33,0 +48,0 @@ exports.loadExternalGrabInteraction = loadExternalGrabInteraction; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 2 instances in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
344331
58
1230
1
3
5
Updated@tsparticles/engine@^3.2.0