react-siriwave
Version:
React version of siriwave.js
48 lines • 2.08 kB
JavaScript
;
exports.__esModule = true;
var tslib_1 = require("tslib");
var react_1 = tslib_1.__importStar(require("react"));
var SiriWave = tslib_1.__importStar(require("siriwave"));
var ReactSiriwave = function (props) {
var siriwaveRef = (0, react_1.useRef)(null);
(0, react_1.useEffect)(function () {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
var siriwave = new SiriWave["default"]({
container: siriwaveRef.current,
style: (_a = props.theme) !== null && _a !== void 0 ? _a : 'ios',
width: (_b = props.width) !== null && _b !== void 0 ? _b : 640,
height: (_c = props.height) !== null && _c !== void 0 ? _c : 200,
speed: (_d = props.speed) !== null && _d !== void 0 ? _d : 0.2,
amplitude: (_e = props.amplitude) !== null && _e !== void 0 ? _e : 1,
frequency: (_f = props.frequency) !== null && _f !== void 0 ? _f : 6,
color: (_g = props.color) !== null && _g !== void 0 ? _g : '#fff',
cover: (_h = props.cover) !== null && _h !== void 0 ? _h : false,
autostart: (_j = props.autostart) !== null && _j !== void 0 ? _j : true,
pixelDepth: (_k = props.pixelDepth) !== null && _k !== void 0 ? _k : 0.02,
lerpSpeed: (_l = props.lerpSpeed) !== null && _l !== void 0 ? _l : 0.01,
curveDefinition: props.curveDefinition
});
if (typeof props.onInit === 'function')
props.onInit(siriwave);
return function () {
siriwave.dispose();
};
}, [
props.amplitude,
props.autostart,
props.color,
props.cover,
props.curveDefinition,
props.frequency,
props.height,
props.lerpSpeed,
props.pixelDepth,
props.speed,
props.theme,
props.width,
props,
]);
return react_1["default"].createElement("div", { ref: siriwaveRef });
};
exports["default"] = ReactSiriwave;
//# sourceMappingURL=App.js.map