
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
on-el-resize
Advanced tools
on-el-resize
is a simple helper which provides an API for attaching resize event firing to HTML elements.
This can simplify creation of some dynamic and responsive components which styles and structure depend on absolute width and height values.
npm install on-el-resize # or yarn add on-el-resize
import { Resize } from 'on-el-resize';
const resize = new Resize();
const element = document.querySelector('.selector');
const resizeHandler = () => {
console.log({
width: element.offsetWidth,
heigth: element.offsetHeight
});
};
// Attach event
resize.addResizeListener(element, resizeHandler);
// Detach event
resize.removeResizeListener(element, resizeHandler);
import * as React from 'react';
import { Resize } from 'on-el-resize';
export interface IProps {}
export interface IState {
componentWidth?: number;
componentHeight?: number;
}
export class Example extends React.Component<IProps, IState> {
private parentRef: HTMLElement;
private resize: Resize;
constructor(props: IProps) {
super(props);
this.resize = new Resize();
this.state = {};
this.onComponentResize = this.onComponentResize.bind(this);
}
public render() {
return (
<div ref={el => this.parentRef = el}>
<div>Width: {this.state.componentWidth}</div>
<div>Height: {this.state.componentHeight}</div>
</div>
);
}
public componentDidMount() {
this.resize.addResizeListener(this.parentRef, this.onComponentResize);
this.onComponentResize();
}
public componentWillUnmount() {
this.resize.removeResizeListener(this.parentRef, this.onComponentResize);
}
private onComponentResize() {
this.setState({
componentWidth: this.parentRef.offsetWidth,
componentHeight: this.parentRef.offsetHeight
});
}
}
Component is in draft status
import * as React from 'react';
import { Resizable } from 'on-el-resize/lib/components';
export default class Example extends React.Component<{}, {}> {
public render() {
return (
<Resizable render={({ width }) => <div>Width: {width}</div>} />
);
}
}
FAQs
On HTML element resize event helper
The npm package on-el-resize receives a total of 8 weekly downloads. As such, on-el-resize popularity was classified as not popular.
We found that on-el-resize demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.