@devil7softwares/react-drifter-stars
Advanced tools
Comparing version 1.0.5 to 1.0.6
import React, { useRef, useEffect } from 'react'; | ||
/*! ***************************************************************************** | ||
/****************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
@@ -30,2 +30,7 @@ | ||
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { | ||
var e = new Error(message); | ||
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; | ||
}; | ||
const EPSILON = 1.0 / 1048576.0; | ||
@@ -483,3 +488,3 @@ class Delaunay { | ||
const DrifterStars = (props) => { | ||
const { color, flare, glare, links, motion, particle, blurSize, renderMesh } = props, rest = __rest(props, ["color", "flare", "glare", "links", "motion", "particle", "blurSize", "renderMesh"]); | ||
const { color, flare, glare, links, motion, particle, blurSize, renderMesh, transformCanvasSize } = props, rest = __rest(props, ["color", "flare", "glare", "links", "motion", "particle", "blurSize", "renderMesh", "transformCanvasSize"]); | ||
const canvasRef = useRef(null); | ||
@@ -638,4 +643,11 @@ const contextRef = useRef(null); | ||
if (canvasRef.current) { | ||
canvasRef.current.width = window.innerWidth; | ||
canvasRef.current.height = window.innerHeight; | ||
if (typeof transformCanvasSize === 'function') { | ||
const size = transformCanvasSize(window.innerWidth, window.innerHeight); | ||
canvasRef.current.width = (size === null || size === void 0 ? void 0 : size.width) || window.innerWidth; | ||
canvasRef.current.height = (size === null || size === void 0 ? void 0 : size.height) || window.innerHeight; | ||
} | ||
else { | ||
canvasRef.current.width = window.innerWidth; | ||
canvasRef.current.height = window.innerHeight; | ||
} | ||
} | ||
@@ -662,3 +674,3 @@ } | ||
export default DrifterStars; | ||
export { DrifterStars as default }; | ||
//# sourceMappingURL=index.es.js.map |
@@ -11,3 +11,3 @@ 'use strict'; | ||
/*! ***************************************************************************** | ||
/****************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
@@ -39,2 +39,7 @@ | ||
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { | ||
var e = new Error(message); | ||
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; | ||
}; | ||
const EPSILON = 1.0 / 1048576.0; | ||
@@ -492,3 +497,3 @@ class Delaunay { | ||
const DrifterStars = (props) => { | ||
const { color, flare, glare, links, motion, particle, blurSize, renderMesh } = props, rest = __rest(props, ["color", "flare", "glare", "links", "motion", "particle", "blurSize", "renderMesh"]); | ||
const { color, flare, glare, links, motion, particle, blurSize, renderMesh, transformCanvasSize } = props, rest = __rest(props, ["color", "flare", "glare", "links", "motion", "particle", "blurSize", "renderMesh", "transformCanvasSize"]); | ||
const canvasRef = React.useRef(null); | ||
@@ -647,4 +652,11 @@ const contextRef = React.useRef(null); | ||
if (canvasRef.current) { | ||
canvasRef.current.width = window.innerWidth; | ||
canvasRef.current.height = window.innerHeight; | ||
if (typeof transformCanvasSize === 'function') { | ||
const size = transformCanvasSize(window.innerWidth, window.innerHeight); | ||
canvasRef.current.width = (size === null || size === void 0 ? void 0 : size.width) || window.innerWidth; | ||
canvasRef.current.height = (size === null || size === void 0 ? void 0 : size.height) || window.innerHeight; | ||
} | ||
else { | ||
canvasRef.current.width = window.innerWidth; | ||
canvasRef.current.height = window.innerHeight; | ||
} | ||
} | ||
@@ -668,6 +680,6 @@ } | ||
}, [canvasRef, canvasRef.current, props]); | ||
return React__default['default'].createElement("canvas", Object.assign({}, rest, { className: rest.className || 'drifter-stars', width: '300', height: '300', ref: canvasRef })); | ||
return React__default["default"].createElement("canvas", Object.assign({}, rest, { className: rest.className || 'drifter-stars', width: '300', height: '300', ref: canvasRef })); | ||
}; | ||
exports.default = DrifterStars; | ||
exports["default"] = DrifterStars; | ||
//# sourceMappingURL=index.js.map |
@@ -5,3 +5,3 @@ (function (global, factory) { | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.DrifterStars = factory(global.React)); | ||
}(this, (function (React) { 'use strict'; | ||
})(this, (function (React) { 'use strict'; | ||
@@ -12,3 +12,3 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
/*! ***************************************************************************** | ||
/****************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
@@ -40,2 +40,7 @@ | ||
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { | ||
var e = new Error(message); | ||
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; | ||
}; | ||
const EPSILON = 1.0 / 1048576.0; | ||
@@ -493,3 +498,3 @@ class Delaunay { | ||
const DrifterStars = (props) => { | ||
const { color, flare, glare, links, motion, particle, blurSize, renderMesh } = props, rest = __rest(props, ["color", "flare", "glare", "links", "motion", "particle", "blurSize", "renderMesh"]); | ||
const { color, flare, glare, links, motion, particle, blurSize, renderMesh, transformCanvasSize } = props, rest = __rest(props, ["color", "flare", "glare", "links", "motion", "particle", "blurSize", "renderMesh", "transformCanvasSize"]); | ||
const canvasRef = React.useRef(null); | ||
@@ -648,4 +653,11 @@ const contextRef = React.useRef(null); | ||
if (canvasRef.current) { | ||
canvasRef.current.width = window.innerWidth; | ||
canvasRef.current.height = window.innerHeight; | ||
if (typeof transformCanvasSize === 'function') { | ||
const size = transformCanvasSize(window.innerWidth, window.innerHeight); | ||
canvasRef.current.width = (size === null || size === void 0 ? void 0 : size.width) || window.innerWidth; | ||
canvasRef.current.height = (size === null || size === void 0 ? void 0 : size.height) || window.innerHeight; | ||
} | ||
else { | ||
canvasRef.current.width = window.innerWidth; | ||
canvasRef.current.height = window.innerHeight; | ||
} | ||
} | ||
@@ -669,3 +681,3 @@ } | ||
}, [canvasRef, canvasRef.current, props]); | ||
return React__default['default'].createElement("canvas", Object.assign({}, rest, { className: rest.className || 'drifter-stars', width: '300', height: '300', ref: canvasRef })); | ||
return React__default["default"].createElement("canvas", Object.assign({}, rest, { className: rest.className || 'drifter-stars', width: '300', height: '300', ref: canvasRef })); | ||
}; | ||
@@ -675,2 +687,2 @@ | ||
}))); | ||
})); |
@@ -40,2 +40,13 @@ import { HTMLAttributes } from 'react'; | ||
motion?: IMotionOptions; | ||
/** | ||
* On every render the canvas size will be adusted to the window size. If you want to override this behavior, you can use this function. | ||
* | ||
* @param width Width of the canvas. Defaults to window.innerWidth. | ||
* @param height Height of the canvas. Defaults to window.innerHeight. | ||
* @returns Object containing width & height of the canvas. | ||
*/ | ||
transformCanvasSize?: (width: number, height: number) => { | ||
width: number; | ||
height: number; | ||
}; | ||
} |
{ | ||
"name": "@devil7softwares/react-drifter-stars", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "React version of Drifter Stars by Cory Hughart", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
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
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
315772
2492