code stringlengths 28 313k | docstring stringlengths 25 85.3k | func_name stringlengths 1 74 | language stringclasses 1
value | repo stringlengths 5 60 | path stringlengths 4 172 | url stringlengths 44 218 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
function triggerNotImplemented(name, args) {
let error = `"${name}" not implemented`;
console.error(error, args);
throw new Error(error);
} | @param {string} name
@param {any[]} args | triggerNotImplemented | javascript | PepsRyuu/nollup | lib/impl/PluginLifecycle.js | https://github.com/PepsRyuu/nollup/blob/master/lib/impl/PluginLifecycle.js | MIT |
function isExternal (config, name) {
if (config && config.external) {
let external = config.external;
if (Array.isArray(external)) {
return external.indexOf(name) > -1;
}
if (typeof external === 'function') {
return external(name, undefined, undefined);
... | @param {RollupConfigContainer} config
@param {string} name
@return {boolean | void} | isExternal | javascript | PepsRyuu/nollup | lib/impl/PluginLifecycle.js | https://github.com/PepsRyuu/nollup/blob/master/lib/impl/PluginLifecycle.js | MIT |
async resolveIdImpl (container, id, parentFilePath, options = {}) {
options.isEntry = options.isEntry || false;
options.custom = options.hasOwnProperty('custom')? options.custom : {};
let __plugins = container.__plugins.filter(p => !this.resolveIdSkips.contains(p.execute, parentFilePath, id));
... | @param {PluginContainer} container
@param {string} id
@param {string} parentFilePath
@return {Promise<RollupResolveIdResult>} | resolveIdImpl | javascript | PepsRyuu/nollup | lib/impl/PluginLifecycle.js | https://github.com/PepsRyuu/nollup/blob/master/lib/impl/PluginLifecycle.js | MIT |
function prepareSourceMapChain (mapChain, original_code, filepath) {
mapChain = mapChain.filter(o => o.map && o.map.mappings).reverse();
if (mapChain.length > 1) {
mapChain.forEach((obj, index) => {
obj.map.version = 3;
obj.map.file = filepath + '_' + index;
// Check... | @param {NollupTransformMapEntry[]} mapChain
@param {string} original_code
@param {string} filepath
@return {NollupTransformMapEntry[]} | prepareSourceMapChain | javascript | PepsRyuu/nollup | lib/impl/PluginUtils.js | https://github.com/PepsRyuu/nollup/blob/master/lib/impl/PluginUtils.js | MIT |
function generateSourceMap (mapChain, mapGenerator, original_code, filepath) {
let map;
if (mapChain.length > 1) {
// @ts-ignore
map = mapGenerator.toJSON();
} else {
map = mapChain.length > 0? mapChain[0].map : undefined;
}
if (map) {
map.file = filepath;
m... | @param {NollupTransformMapEntry[]} mapChain
@param {SourceMapGenerator} mapGenerator
@param {string} original_code
@param {string} filepath
@return {RollupSourceMap} | generateSourceMap | javascript | PepsRyuu/nollup | lib/impl/PluginUtils.js | https://github.com/PepsRyuu/nollup/blob/master/lib/impl/PluginUtils.js | MIT |
function combineSourceMapChain (inputMapChain, original_code, filepath) {
let mapGenerator, mapChain = prepareSourceMapChain(inputMapChain, original_code, filepath);
if (mapChain.length > 1) {
// @ts-ignore
mapGenerator = SourceMap.SourceMapGenerator.fromSourceMap(new SourceMap.SourceMapConsume... | @param {NollupTransformMapEntry[]} inputMapChain
@param {string} original_code
@param {string} filepath
@return {RollupSourceMap} | combineSourceMapChain | javascript | PepsRyuu/nollup | lib/impl/PluginUtils.js | https://github.com/PepsRyuu/nollup/blob/master/lib/impl/PluginUtils.js | MIT |
async function combineSourceMapChainFast (inputMapChain, original_code, filepath) {
let mapGenerator, mapChain = prepareSourceMapChain(inputMapChain, original_code, filepath);
if (mapChain.length > 1) {
mapGenerator = SourceMapFast.SourceMapGenerator.fromSourceMap(await new SourceMapFast.SourceMapConsu... | @param {NollupTransformMapEntry[]} inputMapChain
@param {string} original_code
@param {string} filepath
@return {Promise<RollupSourceMap>} | combineSourceMapChainFast | javascript | PepsRyuu/nollup | lib/impl/PluginUtils.js | https://github.com/PepsRyuu/nollup/blob/master/lib/impl/PluginUtils.js | MIT |
function getModuleInfo (container, id) {
let response = container.__onGetModuleInfo(id);
return {
id: id,
code: response.code || null,
isEntry: response.isEntry || false,
isExternal: response.isExternal || false,
importers: response.importers || [],
importedIds: ... | @param {PluginContainer} container
@param {string} id
@return {RollupModuleInfo} | getModuleInfo | javascript | PepsRyuu/nollup | lib/impl/PluginUtils.js | https://github.com/PepsRyuu/nollup/blob/master/lib/impl/PluginUtils.js | MIT |
function callOutputOptionsHook (plugins, outputOptions) {
if (plugins) {
plugins.forEach(plugin => {
if (plugin.outputOptions) {
outputOptions = plugin.outputOptions.call({
meta: PluginMeta
}, outputOptions) || outputOptions;
}
... | @param {RollupPlugin[]} plugins
@param {RollupOutputOptions} outputOptions | callOutputOptionsHook | javascript | PepsRyuu/nollup | lib/impl/RollupConfigContainer.js | https://github.com/PepsRyuu/nollup/blob/master/lib/impl/RollupConfigContainer.js | MIT |
function normalizeInput (input) {
if (typeof input === 'string') {
return [input];
}
if (Array.isArray(input)) {
return input;
}
return input;
} | @param {RollupInputOption} input
@return {string[]|Object<string, string>} | normalizeInput | javascript | PepsRyuu/nollup | lib/impl/RollupConfigContainer.js | https://github.com/PepsRyuu/nollup/blob/master/lib/impl/RollupConfigContainer.js | MIT |
function findChildNodes (node) {
let children = [];
for (let prop in node) {
if (Array.isArray(node[prop]) && node[prop][0] && node[prop][0].constructor && node[prop][0].constructor.name === 'Node') {
children.push(...node[prop]);
}
if (node[prop] && node[prop].constructor... | @param {ESTree} node
@return {Array<ESTree>} | findChildNodes | javascript | PepsRyuu/nollup | lib/impl/utils.js | https://github.com/PepsRyuu/nollup/blob/master/lib/impl/utils.js | MIT |
function resolvePath (target, current) {
if (path.isAbsolute(target)) {
return path.normalize(target);
} else {
// Plugins like CommonJS have namespaced imports.
let parts = target.split(':');
let namespace = parts.length === 2? parts[0] + ':' : '';
let file = parts.lengt... | @param {string} target
@param {string} current
@return {string} | resolvePath | javascript | PepsRyuu/nollup | lib/impl/utils.js | https://github.com/PepsRyuu/nollup/blob/master/lib/impl/utils.js | MIT |
function formatFileName (format, fileName, pattern) {
let name = path.basename(fileName).replace(path.extname(fileName), '');
if (typeof pattern === 'string') {
return pattern.replace('[name]', name)
.replace('[extname]', path.extname(fileName))
.replace('[ext]', path.extname(fi... | @param {string} format
@param {string} fileName
@param {string|function(RollupPreRenderedFile): string} pattern
@return {string} | formatFileName | javascript | PepsRyuu/nollup | lib/impl/utils.js | https://github.com/PepsRyuu/nollup/blob/master/lib/impl/utils.js | MIT |
async function logs (count = 1, timeout = 5000) {
let start = Date.now();
// Wait until we acquire the requested number of logs
while (logbuffer.length < count) {
await wait(100);
if (Date.now() - start > timeout) {
break;
}
}
// return the logs and clear it af... | Returns a list of logs.
Waits until the number of requested logs have accumulated.
There's a timeout to force it to stop checking.
@param {Number} count
@param {Number} timeout
@returns {Promise<String[]>} | logs | javascript | PepsRyuu/nollup | test/utils/evaluator.js | https://github.com/PepsRyuu/nollup/blob/master/test/utils/evaluator.js | MIT |
async function call (fn, arg) {
// TODO: Find deterministic way of handling this
await wait(100);
global._evaluatorInstance.send({ call: [fn, arg] });
await wait(100);
} | Call the global function in the VM.
@param {String} fn
@param {*} arg | call | javascript | PepsRyuu/nollup | test/utils/evaluator.js | https://github.com/PepsRyuu/nollup/blob/master/test/utils/evaluator.js | MIT |
function invalidate (chunks) {
global._evaluatorInstance.send({ invalidate: true, chunks });
} | Sends updated bundle chunks to VM.
@param {Object[]} chunks | invalidate | javascript | PepsRyuu/nollup | test/utils/evaluator.js | https://github.com/PepsRyuu/nollup/blob/master/test/utils/evaluator.js | MIT |
function init (format, entry, chunks, globals = {}, async = false) {
logbuffer = [];
return new Promise((resolve, reject) => {
let impl = (resolve, reject) => {
global._evaluatorResultListener = msg => {
if (msg.log) {
logbuffer.push(msg.log);
... | Evaluates the VM with the provided code.
@param {String} format
@param {String} entry
@param {Object[]} chunks
@param {Object} globals
@param {Boolean} async
@returns {Object} | init | javascript | PepsRyuu/nollup | test/utils/evaluator.js | https://github.com/PepsRyuu/nollup/blob/master/test/utils/evaluator.js | MIT |
constructor(capacity) {
this.capacity = capacity;
this.regExpMap = new Map();
// Since our capacity tends to be fairly small, `.shift()` will be fairly quick despite being O(n). We just use a
// normal array to keep it simple.
this.regExpQueue = [];
} | This is a reusable regular expression cache class. Given a certain maximum number of regular expressions we're
allowed to store in the cache, it provides a way to avoid recreating regular expression objects over and over.
When it needs to evict something, it evicts the oldest one. | constructor | javascript | i18next/i18next | src/utils.js | https://github.com/i18next/i18next/blob/master/src/utils.js | MIT |
deepFind = (obj, path, keySeparator = '.') => {
if (!obj) return undefined;
if (obj[path]) {
if (!Object.prototype.hasOwnProperty.call(obj, path)) return undefined;
return obj[path];
}
const tokens = path.split(keySeparator);
let current = obj;
for (let i = 0; i < tokens.length; ) {
if (!current... | Given
1. a top level object obj, and
2. a path to a deeply nested string or object within it
Find and return that deeply nested string or object. The caveat is that the keys of objects within the nesting chain
may contain period characters. Therefore, we need to DFS and explore all possible keys at each step until we... | deepFind | javascript | i18next/i18next | src/utils.js | https://github.com/i18next/i18next/blob/master/src/utils.js | MIT |
httpApiReadMockImplementation = (language, namespace, callback) => {
const namespacePath = `${__dirname}/locales/${language}/${namespace}.json`;
// console.info('httpApiReadMockImplementation', namespacePath);
if (fs.existsSync(namespacePath)) {
const data = JSON.parse(fs.readFileSync(namespacePath, 'utf-8'... | @param {string} language
@param {string} namespace
@param {import('i18next').ReadCallback} callback
@returns {void} | httpApiReadMockImplementation | javascript | i18next/i18next | test/compatibility/v1/v1.i18nInstance.js | https://github.com/i18next/i18next/blob/master/test/compatibility/v1/v1.i18nInstance.js | MIT |
getI18nCompatibilityV1InitOptions = () => ({
compatibilityAPI: 'v1',
compatibilityJSON: 'v1',
lng: 'en-US',
load: 'all',
fallbackLng: 'dev',
fallbackNS: [],
fallbackOnNull: true,
fallbackOnEmpty: false,
preload: [],
lowerCaseLng: false,
ns: 'translation',
fallbackToDefaultNS: false,
resGetPath... | using a function to have always a new object | getI18nCompatibilityV1InitOptions | javascript | i18next/i18next | test/compatibility/v1/v1.i18nInstance.js | https://github.com/i18next/i18next/blob/master/test/compatibility/v1/v1.i18nInstance.js | MIT |
function distance(p1, p2) {
return Math.hypot(p1.x - p2.x, p1.y - p2.y);
} | Calculates distance between two points. Each point must have `x` and `y` property
@param {*} p1 point 1
@param {*} p2 point 2
@returns distance between two points | distance | javascript | puffinsoft/jscanify | src/jscanify-node.js | https://github.com/puffinsoft/jscanify/blob/master/src/jscanify-node.js | MIT |
findPaperContour(img) {
const imgGray = new cv.Mat();
cv.Canny(img, imgGray, 50, 200);
const imgBlur = new cv.Mat();
cv.GaussianBlur(
imgGray,
imgBlur,
new cv.Size(3, 3),
0,
0,
cv.BORDER_DEFAULT
);
const imgThresh = new cv.Mat();
cv.threshold(imgBlur, im... | Finds the contour of the paper within the image
@param {*} img image to process (cv.Mat)
@returns the biggest contour inside the image | findPaperContour | javascript | puffinsoft/jscanify | src/jscanify-node.js | https://github.com/puffinsoft/jscanify/blob/master/src/jscanify-node.js | MIT |
highlightPaper(image, options) {
options = options || {};
options.color = options.color || "orange";
options.thickness = options.thickness || 10;
const canvas = createCanvas();
const ctx = canvas.getContext("2d");
const img = cv.imread(image);
const maxContour = this.findPaperContour(img);
... | Highlights the paper detected inside the image.
@param {*} image image to process
@param {*} options options for highlighting. Accepts `color` and `thickness` parameter
@returns `HTMLCanvasElement` with original image and paper highlighted | highlightPaper | javascript | puffinsoft/jscanify | src/jscanify-node.js | https://github.com/puffinsoft/jscanify/blob/master/src/jscanify-node.js | MIT |
extractPaper(image, resultWidth, resultHeight, cornerPoints) {
const canvas = createCanvas();
const img = cv.imread(image);
const maxContour = cornerPoints ? null : this.findPaperContour(img);
if(maxContour == null && cornerPoints === undefined){
return null;
}
const {
topLeftCorne... | Extracts and undistorts the image detected within the frame.
Returns `null` if no paper is detected.
@param {*} image image to process
@param {*} resultWidth desired result paper width
@param {*} resultHeight desired result paper height
@param {*} cornerPoints optional custom corner points, in case automatic corner p... | extractPaper | javascript | puffinsoft/jscanify | src/jscanify-node.js | https://github.com/puffinsoft/jscanify/blob/master/src/jscanify-node.js | MIT |
getCornerPoints(contour) {
let rect = cv.minAreaRect(contour);
const center = rect.center;
let topLeftCorner;
let topLeftCornerDist = 0;
let topRightCorner;
let topRightCornerDist = 0;
let bottomLeftCorner;
let bottomLeftCornerDist = 0;
let bottomRightCorner;
let bottomRightC... | Calculates the corner points of a contour.
@param {*} contour contour from {@link findPaperContour}
@returns object with properties `topLeftCorner`, `topRightCorner`, `bottomLeftCorner`, `bottomRightCorner`, each with `x` and `y` property | getCornerPoints | javascript | puffinsoft/jscanify | src/jscanify-node.js | https://github.com/puffinsoft/jscanify/blob/master/src/jscanify-node.js | MIT |
extractPaper(image, resultWidth, resultHeight, cornerPoints) {
const canvas = document.createElement("canvas");
const img = cv.imread(image);
const maxContour = cornerPoints ? null : this.findPaperContour(img);
if(maxContour == null && cornerPoints === undefined){
return null;
}
... | Extracts and undistorts the image detected within the frame.
Returns `null` if no paper is detected.
@param {*} image image to process
@param {*} resultWidth desired result paper width
@param {*} resultHeight desired result paper height
@param {*} cornerPoints optional custom corner points, in case automatic corner ... | extractPaper | javascript | puffinsoft/jscanify | src/jscanify.js | https://github.com/puffinsoft/jscanify/blob/master/src/jscanify.js | MIT |
function processSegmentation(canvas, segmentation) {
var ctx = canvas.getContext('2d');
console.log(segmentation)
// Get data from our overlay canvas which is attempting to estimate background.
var imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
var data = imageData.data;
// Get data fro... | *****************************************************************
Real-Time-Person-Removal Created by Jason Mayes 2020.
Get latest code on my Github:
https://github.com/jasonmayes/Real-Time-Person-Removal
Got questions? Reach out to me on social:
Twitter: @jason_mayes
LinkedIn: https://www.linkedin.com/in/creativetec... | processSegmentation | javascript | jasonmayes/Real-Time-Person-Removal | script.js | https://github.com/jasonmayes/Real-Time-Person-Removal/blob/master/script.js | Apache-2.0 |
function hasGetUserMedia() {
return !!(navigator.mediaDevices &&
navigator.mediaDevices.getUserMedia);
} | *****************************************************************
// Continuously grab image from webcam stream and classify it.
****************************************************************** | hasGetUserMedia | javascript | jasonmayes/Real-Time-Person-Removal | script.js | https://github.com/jasonmayes/Real-Time-Person-Removal/blob/master/script.js | Apache-2.0 |
Juggernaut = function(options){
this.options = options || {};
this.options.host = this.options.host || window.location.hostname;
this.options.port = this.options.port || 8080;
this.handlers = {};
this.meta = this.options.meta;
this.io = io.connect(this.options.host, this.options);
this.io.on("... | Add the transport to your public io.transports array.
@api private | Juggernaut | javascript | maccman/juggernaut | client.js | https://github.com/maccman/juggernaut/blob/master/client.js | MIT |
banner = (format, addTypes) => {
const date = new Date();
return `/**
* anime.js - ${ format }
* @version v${ pkg.version }
* @author Julian Garnier
* @license MIT
* @copyright (c) ${ date.getFullYear() } Julian Garnier
* @see https://animejs.com
*/${addTypes ? jsDocTypes : ''}
`
} | @param {String} format
@param {Boolean} [addTypes]
@return {String} | banner | javascript | juliangarnier/anime | rollup.config.js | https://github.com/juliangarnier/anime/blob/master/rollup.config.js | MIT |
getTotalWidth = (total, $el) => {
const style= getComputedStyle($el);
const marginsWidth = parseInt(style.marginLeft) + parseInt(style.marginRight);
return total + $el.offsetWidth + marginsWidth;
} | @param {Number} total
@param {HTMLElement} $el
@return {Number} | getTotalWidth | javascript | juliangarnier/anime | examples/draggable-infinite-auto-carousel/index.js | https://github.com/juliangarnier/anime/blob/master/examples/draggable-infinite-auto-carousel/index.js | MIT |
parseNumber = str => isStr(str) ?
parseFloat(/** @type {String} */(str)) :
/** @type {Number} */(str) | @param {Number|String} str
@return {Number} | parseNumber | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
round = (v, decimalLength) => {
if (decimalLength < 0) return v;
if (!decimalLength) return _round(v);
let p = powCache[decimalLength];
if (!p) p = powCache[decimalLength] = 10 ** decimalLength;
return _round(v * p) / p;
} | @param {Number} v
@param {Number} decimalLength
@return {Number} | round | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
forEachChildren = (parent, callback, reverse, prevProp = '_prev', nextProp = '_next') => {
let next = parent._head;
let adjustedNextProp = nextProp;
if (reverse) {
next = parent._tail;
adjustedNextProp = prevProp;
}
while (next) {
const currentNext = next[adjustedNextProp];
callback(next);
... | @param {Object} parent
@param {Function} callback
@param {Boolean} [reverse]
@param {String} [prevProp]
@param {String} [nextProp]
@return {void} | forEachChildren | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
removeChild = (parent, child, prevProp = '_prev', nextProp = '_next') => {
const prev = child[prevProp];
const next = child[nextProp];
prev ? prev[nextProp] = next : parent._head = next;
next ? next[prevProp] = prev : parent._tail = prev;
child[prevProp] = null;
child[nextProp] = null;
} | @param {Object} parent
@param {Object} child
@param {String} [prevProp]
@param {String} [nextProp]
@return {void} | removeChild | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
addChild = (parent, child, sortMethod, prevProp = '_prev', nextProp = '_next') => {
let prev = parent._tail;
while (prev && sortMethod && sortMethod(prev, child)) prev = prev[prevProp];
const next = prev ? prev[nextProp] : parent._head;
prev ? prev[nextProp] = child : parent._head = child;
next ? next[prevPro... | @param {Object} parent
@param {Object} child
@param {Function} [sortMethod]
@param {String} prevProp
@param {String} nextProp
@return {void} | addChild | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
render = (tickable, time, muteCallbacks, internalRender, tickMode) => {
const parent = tickable.parent;
const duration = tickable.duration;
const completed = tickable.completed;
const iterationDuration = tickable.iterationDuration;
const iterationCount = tickable.iterationCount;
const _currentIteration = t... | @param {Tickable} tickable
@param {Number} time
@param {Number} muteCallbacks
@param {Number} internalRender
@param {tickModes} tickMode
@return {Number} | render | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
tick = (tickable, time, muteCallbacks, internalRender, tickMode) => {
const _currentIteration = tickable._currentIteration;
render(tickable, time, muteCallbacks, internalRender, tickMode);
if (tickable._hasChildren) {
const tl = /** @type {Timeline} */(tickable);
const tlIsRunningBackwards = tl.backwards;... | @param {Tickable} tickable
@param {Number} time
@param {Number} muteCallbacks
@param {Number} internalRender
@param {Number} tickMode
@return {void} | tick | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
parseInlineTransforms = (target, propName, animationInlineStyles) => {
const inlineTransforms = target.style.transform;
let inlinedStylesPropertyValue;
if (inlineTransforms) {
const cachedTransforms = target[transformsSymbol];
let t; while (t = transformsExecRgx.exec(inlineTransforms)) {
const inlin... | @param {DOMTarget} target
@param {String} propName
@param {Object} animationInlineStyles
@return {String} | parseInlineTransforms | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
function getNodeList(v) {
const n = isStr(v) ? globals.root.querySelectorAll(v) : v;
if (n instanceof NodeList || n instanceof HTMLCollection) return n;
} | @param {DOMTargetsParam|TargetsParam} v
@return {NodeList|HTMLCollection} | getNodeList | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
function parseTargets(targets) {
if (isNil(targets)) return /** @type {TargetsArray} */([]);
if (isArr(targets)) {
const flattened = targets.flat(Infinity);
/** @type {TargetsArray} */
const parsed = [];
for (let i = 0, l = flattened.length; i < l; i++) {
const item = flattened[i];
if (!... | @overload
@param {DOMTargetsParam} targets
@return {DOMTargetsArray}
@overload
@param {JSTargetsParam} targets
@return {JSTargetsArray}
@overload
@param {TargetsParam} targets
@return {TargetsArray}
@param {DOMTargetsParam|JSTargetsParam|TargetsParam} targets | parseTargets | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
getPath = path => {
const parsedTargets = parseTargets(path);
const $parsedSvg = /** @type {SVGGeometryElement} */(parsedTargets[0]);
if (!$parsedSvg || !isSvg($parsedSvg)) return;
return $parsedSvg;
} | @param {TargetsParam} path
@return {SVGGeometryElement|undefined} | getPath | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
morphTo = (path2, precision = .33) => ($path1) => {
const $path2 = /** @type {SVGGeometryElement} */(getPath(path2));
if (!$path2) return;
const isPath = $path1.tagName === 'path';
const separator = isPath ? ' ' : ',';
const previousPoints = $path1[morphPointsSymbol];
if (previousPoints) $path1.setAttribute... | @param {TargetsParam} path2
@param {Number} [precision]
@return {FunctionValue} | morphTo | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
createDrawableProxy = ($el, start, end) => {
const pathLength = K;
const computedStyles = getComputedStyle($el);
const strokeLineCap = computedStyles.strokeLinecap;
// @ts-ignore
const $scalled = computedStyles.vectorEffect === 'non-scaling-stroke' ? $el : null;
let currentCap = strokeLineCap;
const prox... | Creates a proxy that wraps an SVGGeometryElement and adds drawing functionality.
@param {SVGGeometryElement} $el - The SVG element to transform into a drawable
@param {number} start - Starting position (0-1)
@param {number} end - Ending position (0-1)
@return {DrawableSVGGeometry} - Returns a proxy that preserves the o... | createDrawableProxy | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
createDrawable = (selector, start = 0, end = 0) => {
const els = parseTargets(selector);
return els.map($el => createDrawableProxy(
/** @type {SVGGeometryElement} */($el),
start,
end
));
} | Creates drawable proxies for multiple SVG elements.
@param {TargetsParam} selector - CSS selector, SVG element, or array of elements and selectors
@param {number} [start=0] - Starting position (0-1)
@param {number} [end=0] - Ending position (0-1)
@return {Array<DrawableSVGGeometry>} - Array of proxied elements with dra... | createDrawable | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
getPathPoint = ($path, progress, lookup = 0) => {
return $path.getPointAtLength(progress + lookup >= 1 ? progress + lookup : 0);
} | @param {SVGGeometryElement} $path
@param {Number} progress
@param {Number}lookup
@return {DOMPoint} | getPathPoint | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
getPathProgess = ($path, pathProperty) => {
return $el => {
const totalLength = +($path.getTotalLength());
const inSvg = $el[isSvgSymbol];
const ctm = $path.getCTM();
/** @type {TweenObjectValue} */
return {
from: 0,
to: totalLength,
/** @type {TweenModifier} */
modifier: p... | @param {SVGGeometryElement} $path
@param {String} pathProperty
@return {FunctionValue} | getPathProgess | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
isValidSVGAttribute = (el, propertyName) => {
// Return early and use CSS opacity animation instead (already better default values (opacity: 1 instead of 0)) and rotate should be considered a transform
if (cssReservedProperties.includes(propertyName)) return false;
if (el.getAttribute(propertyName) || propertyNam... | @param {Target} el
@param {String} propertyName
@return {Boolean} | isValidSVGAttribute | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
rgbToRgba = rgbValue => {
const rgba = rgbExecRgx.exec(rgbValue) || rgbaExecRgx.exec(rgbValue);
const a = !isUnd(rgba[4]) ? +rgba[4] : 1;
return [
+rgba[1],
+rgba[2],
+rgba[3],
a
]
} | RGB / RGBA Color value string -> RGBA values array
@param {String} rgbValue
@return {ColorArray} | rgbToRgba | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
hexToRgba = hexValue => {
const hexLength = hexValue.length;
const isShort = hexLength === 4 || hexLength === 5;
return [
+('0x' + hexValue[1] + hexValue[isShort ? 1 : 2]),
+('0x' + hexValue[isShort ? 2 : 3] + hexValue[isShort ? 2 : 4]),
+('0x' + hexValue[isShort ? 3 : 5] + hexValue[isShort ? 3 : 6]),... | HEX3 / HEX3A / HEX6 / HEX6A Color value string -> RGBA values array
@param {String} hexValue
@return {ColorArray} | hexToRgba | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
hue2rgb = (p, q, t) => {
if (t < 0) t += 1;
if (t > 1) t -= 1;
return t < 1 / 6 ? p + (q - p) * 6 * t :
t < 1 / 2 ? q :
t < 2 / 3 ? p + (q - p) * (2 / 3 - t) * 6 :
p;
} | @param {Number} p
@param {Number} q
@param {Number} t
@return {Number} | hue2rgb | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
hslToRgba = hslValue => {
const hsla = hslExecRgx.exec(hslValue) || hslaExecRgx.exec(hslValue);
const h = +hsla[1] / 360;
const s = +hsla[2] / 100;
const l = +hsla[3] / 100;
const a = !isUnd(hsla[4]) ? +hsla[4] : 1;
let r, g, b;
if (s === 0) {
r = g = b = l;
} else {
const q = l < .5 ? l * (1 + ... | HSL / HSLA Color value string -> RGBA values array
@param {String} hslValue
@return {ColorArray} | hslToRgba | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
convertColorStringValuesToRgbaArray = colorString => {
return isRgb(colorString) ? rgbToRgba(colorString) :
isHex(colorString) ? hexToRgba(colorString) :
isHsl(colorString) ? hslToRgba(colorString) :
[0, 0, 0, 1];
} | All in one color converter that converts a color string value into an array of RGBA values
@param {String} colorString
@return {ColorArray} | convertColorStringValuesToRgbaArray | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
setValue = (targetValue, defaultValue) => {
return isUnd(targetValue) ? defaultValue : targetValue;
} | @template T, D
@param {T|undefined} targetValue
@param {D} defaultValue
@return {T|D} | setValue | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
getFunctionValue = (value, target, index, total, store) => {
if (isFnc(value)) {
const func = () => {
const computed = /** @type {Function} */(value)(target, index, total);
// Fallback to 0 if the function returns undefined / NaN / null / false / 0
return !isNaN(+computed) ? +computed : computed... | @param {TweenPropValue} value
@param {Target} target
@param {Number} index
@param {Number} total
@param {Object} [store]
@return {any} | getFunctionValue | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
getTweenType = (target, prop) => {
return !target[isDomSymbol] ? tweenTypes.OBJECT :
// Handle SVG attributes
target[isSvgSymbol] && isValidSVGAttribute(target, prop) ? tweenTypes.ATTRIBUTE :
// Handle CSS Transform properties differently than CSS to allow individual animations
validTransforms.include... | @param {Target} target
@param {String} prop
@return {tweenTypes} | getTweenType | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
getOriginalAnimatableValue = (target, propName, tweenType, animationInlineStyles) => {
const type = !isUnd(tweenType) ? tweenType : getTweenType(target, propName);
return type === tweenTypes.OBJECT ? target[propName] || 0 :
type === tweenTypes.ATTRIBUTE ? /** @type {DOMTarget} */(target).getAttribute(propN... | @param {Target} target
@param {String} propName
@param {tweenTypes} [tweenType]
@param {Object|void} [animationInlineStyles]
@return {String|Number} | getOriginalAnimatableValue | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
getRelativeValue = (x, y, operator) => {
return operator === '-' ? x - y :
operator === '+' ? x + y :
x * y;
} | @param {Number} x
@param {Number} y
@param {String} operator
@return {Number} | getRelativeValue | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
decomposeRawValue = (rawValue, targetObject) => {
/** @type {valueTypes} */
targetObject.t = valueTypes.NUMBER;
targetObject.n = 0;
targetObject.u = null;
targetObject.o = null;
targetObject.d = null;
targetObject.s = null;
if (!rawValue) return targetObject;
const num = +rawValue;
if (!isNaN(num)) ... | @param {String|Number} rawValue
@param {TweenDecomposedValue} targetObject
@return {TweenDecomposedValue} | decomposeRawValue | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
decomposeTweenValue = (tween, targetObject) => {
targetObject.t = tween._valueType;
targetObject.n = tween._toNumber;
targetObject.u = tween._unit;
targetObject.o = null;
targetObject.d = cloneArray(tween._toNumbers);
targetObject.s = cloneArray(tween._strings);
return targetObject;
} | @param {Tween} tween
@param {TweenDecomposedValue} targetObject
@return {TweenDecomposedValue} | decomposeTweenValue | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
getTweenSiblings = (target, property, lookup = '_rep') => {
const lookupMap = lookups[lookup];
let targetLookup = lookupMap.get(target);
if (!targetLookup) {
targetLookup = {};
lookupMap.set(target, targetLookup);
}
return targetLookup[property] ? targetLookup[property] : targetLookup[property] = {
... | @param {Target} target
@param {String} property
@param {String} lookup
@return {TweenPropertySiblings} | getTweenSiblings | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
addTweenSortMethod = (p, c) => {
return p._isOverridden || p._absoluteStartTime > c._absoluteStartTime;
} | @param {Tween} p
@param {Tween} c
@return {Number|Boolean} | addTweenSortMethod | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
composeTween = (tween, siblings) => {
const tweenCompositionType = tween._composition;
// Handle replaced tweens
if (tweenCompositionType === compositionTypes.replace) {
const tweenAbsStartTime = tween._absoluteStartTime;
addChild(siblings, tween, addTweenSortMethod, '_prevRep', '_nextRep');
con... | @param {Tween} tween
@param {TweenPropertySiblings} siblings
@return {Tween} | composeTween | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
constructor(parameters = {}, parent = null, parentPosition = 0) {
super(0);
const {
id,
delay,
duration,
reversed,
alternate,
loop,
loopDelay,
autoplay,
frameRate,
playbackRate,
onComplete,
onLoop,
onPause,
onBegin,
onBe... | @param {TimerParams} [parameters]
@param {Timeline} [parent]
@param {Number} [parentPosition] | constructor | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
seek(time, muteCallbacks = 0, internalRender = 0) {
// Recompose the tween siblings in case the timer has been cancelled
reviveTimer(this);
// If you seek a completed animation, otherwise the next play will starts at 0
this.completed = false;
const isPaused = this.paused;
this.paused = true;
... | @param {Number} time
@param {Boolean|Number} [muteCallbacks]
@param {Boolean|Number} [internalRender]
@return {this} | seek | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
revert() {
tick(this, 0, 1, 0, tickModes.AUTO);
const ap = /** @type {ScrollObserver} */(this._autoplay);
if (ap && ap.linked && ap.linked === this) ap.revert();
return this.cancel();
} | Cancels the timer by seeking it back to 0 and reverting the attached scroller if necessary
@return {this} | revert | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
complete() {
return this.seek(this.duration).cancel();
} | Imediatly completes the timer, cancels it and triggers the onComplete callback
@return {this} | complete | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
then(callback = noop) {
const then = this.then;
const onResolve = () => {
// this.then = null prevents infinite recursion if returned by an async function
// https://github.com/juliangarnierorg/anime-beta/issues/26
this.then = null;
callback(this);
this.then = then;
this._res... | @param {Callback<this>} [callback]
@return {Promise} | then | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
binarySubdivide = (aX, mX1, mX2) => {
let aA = 0, aB = 1, currentX, currentT, i = 0;
do {
currentT = aA + (aB - aA) / 2;
currentX = calcBezier(currentT, mX1, mX2) - aX;
if (currentX > 0) {
aB = currentT;
} else {
aA = currentT;
}
} while (abs(currentX) > .0000001 && ++i < 100);
r... | @param {Number} aX
@param {Number} mX1
@param {Number} mX2
@return {Number} | binarySubdivide | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
cubicBezier = (mX1 = 0.5, mY1 = 0.0, mX2 = 0.5, mY2 = 1.0) => (mX1 === mY1 && mX2 === mY2) ? none :
t => t === 0 || t === 1 ? t :
calcBezier(binarySubdivide(t, mX1, mX2), mY1, mY2) | @param {Number} [mX1]
@param {Number} [mY1]
@param {Number} [mX2]
@param {Number} [mY2]
@return {EasingFunction} | cubicBezier | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
linear = (...args) => {
const argsLength = args.length;
if (!argsLength) return none;
const totalPoints = argsLength - 1;
const firstArg = args[0];
const lastArg = args[totalPoints];
const xPoints = [0];
const yPoints = [parseNumber(firstArg)];
for (let i = 1; i < totalPoints; i++) {
const arg = arg... | Without parameters, the linear function creates a non-eased transition.
Parameters, if used, creates a piecewise linear easing by interpolating linearly between the specified points.
@param {...String|Number} [args] - Points
@return {EasingFunction} | linear | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
irregular = (length = 10, randomness = 1) => {
const values = [0];
const total = length - 1;
for (let i = 1; i < total; i++) {
const previousValue = values[i - 1];
const spacing = i / total;
const segmentEnd = (i + 1) / total;
const randomVariation = spacing + (segmentEnd - spacing) * Math.random(... | Generate random steps
@param {Number} [length] - The number of steps
@param {Number} [randomness] - How strong the randomness is
@return {EasingFunction} | irregular | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
parseEaseString = (string, easesFunctions, easesLookups) => {
if (easesLookups[string]) return easesLookups[string];
if (string.indexOf('(') <= -1) {
const hasParams = easeTypes[string] || string.includes('Back') || string.includes('Elastic');
const parsedFn = /** @type {EasingFunction} */(hasParams ? /** @... | @param {String} string
@param {Record<String, EasesFactory|EasingFunction>} easesFunctions
@param {Object} easesLookups
@return {EasingFunction} | parseEaseString | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
sanitizePropertyName = (propertyName, target, tweenType) => {
if (tweenType === tweenTypes.TRANSFORM) {
const t = shortTransforms.get(propertyName);
return t ? t : propertyName;
} else if (
tweenType === tweenTypes.CSS ||
// Handle special cases where properties like "strokeDashoffset" needs to be s... | @param {String} propertyName
@param {Target} target
@param {tweenTypes} tweenType
@return {String} | sanitizePropertyName | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
convertValueUnit = (el, decomposedValue, unit, force = false) => {
const currentUnit = decomposedValue.u;
const currentNumber = decomposedValue.n;
if (decomposedValue.t === valueTypes.UNIT && currentUnit === unit) { // TODO: Check if checking against the same unit string is necessary
return decomposedValue;
... | @param {DOMTarget} el
@param {TweenDecomposedValue} decomposedValue
@param {String} unit
@param {Boolean} [force]
@return {TweenDecomposedValue} | convertValueUnit | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
generateKeyframes = (keyframes, parameters) => {
/** @type {AnimationParams} */
const properties = {};
if (isArr(keyframes)) {
const propertyNames = [].concat(.../** @type {DurationKeyframes} */(keyframes).map(key => Object.keys(key))).filter(isKey);
for (let i = 0, l = propertyNames.length; i < l; i++) {... | @param {DurationKeyframes | PercentageKeyframes} keyframes
@param {AnimationParams} parameters
@return {AnimationParams} | generateKeyframes | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
constructor(
targets,
parameters,
parent,
parentPosition,
fastSet = false,
index = 0,
length = 0
) {
super(/** @type {TimerParams&AnimationParams} */(parameters), parent, parentPosition);
const parsedTargets = registerTargets(targets);
const targetsLength = parsedTargets.leng... | @param {TargetsParam} targets
@param {AnimationParams} parameters
@param {Timeline} [parent]
@param {Number} [parentPosition]
@param {Boolean} [fastSet=false]
@param {Number} [index=0]
@param {Number} [length=0] | constructor | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
revert() {
super.revert();
return cleanInlineStyles(this);
} | Cancel the animation and revert all the values affected by this animation to their original state
@return {this} | revert | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
easingToLinear = (fn, samples = 100) => {
const points = [];
for (let i = 0; i <= samples; i++) points.push(fn(i / samples));
return `linear(${points.join(', ')})`;
} | Converts an easing function into a valid CSS linear() timing function string
@param {EasingFunction} fn
@param {number} [samples=100]
@returns {string} CSS linear() timing function | easingToLinear | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
registerTransformsProperties = () => {
if (transformsPropertiesRegistered) return;
validTransforms.forEach(t => {
const isSkew = stringStartsWith(t, 'skew');
const isScale = stringStartsWith(t, 'scale');
const isRotate = stringStartsWith(t, 'rotate');
const isTranslate = stringStartsWith(t, 'transla... | @typedef {Record<String, WAAPIKeyframeValue | WAAPIAnimationOptions | Boolean | ScrollObserver | WAAPICallback | EasingParam | WAAPITweenOptions> & WAAPIAnimationOptions} WAAPIAnimationParams | registerTransformsProperties | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
removeWAAPIAnimation = ($el, property, parent) => {
let nextLookup = WAAPIAnimationsLookups._head;
while (nextLookup) {
const next = nextLookup._next;
const matchTarget = nextLookup.$el === $el;
const matchProperty = !property || nextLookup.property === property;
const matchParent = !parent || nextL... | @param {DOMTarget} $el
@param {String} [property]
@param {WAAPIAnimation} [parent] | removeWAAPIAnimation | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
addWAAPIAnimation = (parent, $el, property, keyframes, params) => {
const animation = $el.animate(keyframes, params);
const animTotalDuration = params.delay + (+params.duration * params.iterations);
animation.playbackRate = parent._speed;
if (parent.paused) animation.pause();
if (parent.duration < animTotalDu... | @param {WAAPIAnimation} parent
@param {DOMTarget} $el
@param {String} property
@param {PropertyIndexedKeyframes} keyframes
@param {KeyframeAnimationOptions} params
@retun {Animation} | addWAAPIAnimation | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
normalizeTweenValue = (propName, value, $el, i, targetsLength) => {
let v = getFunctionValue(/** @type {any} */(value), $el, i, targetsLength);
if (!isNum(v)) return v;
if (commonDefaultPXProperties.includes(propName) || stringStartsWith(propName, 'translate')) return `${v}px`;
if (stringStartsWith(propName, 'r... | @param {String} propName
@param {WAAPIKeyframeValue} value
@param {DOMTarget} $el
@param {Number} i
@param {Number} targetsLength
@return {String} | normalizeTweenValue | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
parseIndividualTweenValue = ($el, propName, from, to, i, targetsLength) => {
/** @type {WAAPITweenValue} */
let tweenValue = '0';
const computedTo = !isUnd(to) ? normalizeTweenValue(propName, to, $el, i, targetsLength) : getComputedStyle($el)[propName];
if (!isUnd(from)) {
const computedFrom = normalizeTwee... | @param {DOMTarget} $el
@param {String} propName
@param {WAAPIKeyframeValue} from
@param {WAAPIKeyframeValue} to
@param {Number} i
@param {Number} targetsLength
@return {WAAPITweenValue} | parseIndividualTweenValue | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
constructor(targets, params) {
if (globals.scope) globals.scope.revertibles.push(this);
registerTransformsProperties();
const parsedTargets = registerTargets(targets);
const targetsLength = parsedTargets.length;
if (!targetsLength) {
console.warn(`No target found. Make sure the element you... | @param {DOMTargetsParam} targets
@param {WAAPIAnimationParams} params | constructor | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
forEach(callback) {
const cb = isStr(callback) ? a => a[callback]() : callback;
this.animations.forEach(cb);
return this;
} | @param {forEachCallback|String} callback
@return {this} | forEach | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
seek(time, muteCallbacks = false) {
if (muteCallbacks) this.muteCallbacks = true;
if (time < this.duration) this.completed = false;
this.currentTime = time;
this.muteCallbacks = false;
if (this.paused) this.pause();
return this;
} | @param {Number} time
@param {Boolean} muteCallbacks | seek | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
sync = (callback = noop) => {
return new Timer({ duration: 1 * globals.timeScale, onComplete: callback }, null, 0).resume();
} | @param {Callback<Timer>} [callback]
@return {Timer} | sync | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
function getTargetValue(targetSelector, propName, unit) {
const targets = registerTargets(targetSelector);
if (!targets.length) return;
const [ target ] = targets;
const tweenType = getTweenType(target, propName);
const normalizePropName = sanitizePropertyName(propName, target, tweenType);
let originalValue... | @overload
@param {DOMTargetSelector} targetSelector
@param {String} propName
@return {String}
@overload
@param {JSTargetsParam} targetSelector
@param {String} propName
@return {Number|String}
@overload
@param {DOMTargetsParam} targetSelector
@param {String} propName
@param {String} ... | getTargetValue | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
setTargetValues = (targets, parameters) => {
if (isUnd(parameters)) return;
parameters.duration = minValue;
// Do not overrides currently active tweens by default
parameters.composition = setValue(parameters.composition, compositionTypes.none);
// Skip init() and force rendering by playing the animation
ret... | @param {TargetsParam} targets
@param {AnimationParams} parameters
@return {JSAnimation} | setTargetValues | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
removeTargetsFromAnimation = (targetsArray, animation, propertyName) => {
let tweensMatchesTargets = false;
forEachChildren(animation, (/**@type {Tween} */tween) => {
const tweenTarget = tween.target;
if (targetsArray.includes(tweenTarget)) {
const tweenName = tween.property;
const tweenType = t... | @param {TargetsArray} targetsArray
@param {JSAnimation} animation
@param {String} [propertyName]
@return {Boolean} | removeTargetsFromAnimation | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
remove = (targets, renderable, propertyName) => {
const targetsArray = parseTargets(targets);
const parent = /** @type {Renderable|typeof engine} **/(renderable ? renderable : engine);
const waapiAnimation = renderable && /** @type {WAAPIAnimation} */(renderable).controlAnimation && /** @type {WAAPIAnimation} */(... | @param {TargetsParam} targets
@param {Renderable|WAAPIAnimation} [renderable]
@param {String} [propertyName]
@return {TargetsArray} | remove | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
shuffle = items => {
let m = items.length, t, i;
while (m) { i = random(0, --m); t = items[m]; items[m] = items[i]; items[i] = t; }
return items;
} | Adapted from https://bost.ocks.org/mike/shuffle/
@param {Array} items
@return {Array} | shuffle | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
lerp = (start, end, amount, renderable) => {
let dt = K / globals.defaults.frameRate;
if (renderable !== false) {
const ticker = /** @type Renderable */
(renderable) ||
(engine._hasChildren && engine);
if (ticker && ticker.deltaTime) {
dt = ticker.deltaTime;
}... | https://www.rorydriscoll.com/2016/03/07/frame-rate-independent-damping-using-lerp/
@param {Number} start
@param {Number} end
@param {Number} amount
@param {Renderable|Boolean} [renderable]
@return {Number} | lerp | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
chain = fn => {
return (...args) => {
const result = fn(...args);
return new Proxy(noop, {
apply: (_, __, [v]) => result(v),
get: (_, prop) => chain(/**@param {...Number|String} nextArgs */(...nextArgs) => {
const nextResult = utils[prop](...nextArgs);
return (/**@type {Number|Str... | @param {Function} fn
@return {function(...(Number|String))} | chain | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
getPrevChildOffset = (timeline, timePosition) => {
if (stringStartsWith(timePosition, '<')) {
const goToPrevAnimationOffset = timePosition[1] === '<';
const prevAnimation = /** @type {Tickable} */(timeline._tail);
const prevOffset = prevAnimation ? prevAnimation._offset + prevAnimation._delay : 0;
ret... | Timeline's children offsets positions parser
@param {Timeline} timeline
@param {String} timePosition
@return {Number} | getPrevChildOffset | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
parseTimelinePosition = (timeline, timePosition) => {
let tlDuration = timeline.iterationDuration;
if (tlDuration === minValue) tlDuration = 0;
if (isUnd(timePosition)) return tlDuration;
if (isNum(+timePosition)) return +timePosition;
const timePosStr = /** @type {String} */(timePosition);
const tlLabels =... | @param {Timeline} timeline
@param {TimePosition} [timePosition]
@return {Number} | parseTimelinePosition | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
function addTlChild(childParams, tl, timePosition, targets, index, length) {
const isSetter = isNum(childParams.duration) && /** @type {Number} */(childParams.duration) <= minValue;
// Offset the tl position with -minValue for 0 duration animations or .set() calls in order to align their end value with the defined ... | @overload
@param {TimerParams} childParams
@param {Timeline} tl
@param {Number} timePosition
@return {Timeline}
@overload
@param {AnimationParams} childParams
@param {Timeline} tl
@param {Number} timePosition
@param {TargetsParam} targets
@param {Number} [index]
@param {Number} [length]
@return {Timeline}
@p... | addTlChild | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
add(a1, a2, a3) {
const isAnim = isObj(a2);
const isTimer = isObj(a1);
if (isAnim || isTimer) {
this._hasChildren = true;
if (isAnim) {
const childParams = /** @type {AnimationParams} */(a2);
// Check for function for children stagger positions
if (isFnc(a3)) {
... | @overload
@param {TargetsParam} a1
@param {AnimationParams} a2
@param {TimePosition} [a3]
@return {this}
@overload
@param {TimerParams} a1
@param {TimePosition} [a2]
@return {this}
@param {TargetsParam|TimerParams} a1
@param {AnimationParams|TimePosition} a2
@param {TimePosition} [a3] | add | javascript | juliangarnier/anime | lib/anime.esm.js | https://github.com/juliangarnier/anime/blob/master/lib/anime.esm.js | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.