New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@react-hook/size

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-hook/size - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

46

dist/main/index.js

@@ -75,23 +75,20 @@ 'use strict'

const targetEl = target && 'current' in target ? target.current : target
const initialRect = targetEl
? targetEl.getBoundingClientRect()
: {
width:
(_options$initialWidth =
options === null || options === void 0
? void 0
: options.initialWidth) !== null &&
_options$initialWidth !== void 0
? _options$initialWidth
: 0,
height:
(_options$initialHeigh =
options === null || options === void 0
? void 0
: options.initialHeight) !== null &&
_options$initialHeigh !== void 0
? _options$initialHeigh
: 0,
}
return [initialRect.width, initialRect.height]
return targetEl
? [targetEl.offsetWidth, targetEl.offsetHeight]
: [
(_options$initialWidth =
options === null || options === void 0
? void 0
: options.initialWidth) !== null &&
_options$initialWidth !== void 0
? _options$initialWidth
: 0,
(_options$initialHeigh =
options === null || options === void 0
? void 0
: options.initialHeight) !== null &&
_options$initialHeigh !== void 0
? _options$initialHeigh
: 0,
]
})

@@ -101,9 +98,8 @@ ;(0, _passiveLayoutEffect.default)(() => {

if (!targetEl) return
const rect = targetEl.getBoundingClientRect()
setSize([rect.width, rect.height])
setSize([targetEl.offsetWidth, targetEl.offsetHeight])
}, [target]) // Where the magic happens
;(0, _resizeObserver.default)(target, (entry) => {
const {width, height} = entry.contentRect
setSize([width, height])
const target = entry.target
setSize([target.offsetWidth, target.offsetHeight])
})

@@ -110,0 +106,0 @@ return size

@@ -16,23 +16,20 @@ import * as React from 'react'

const targetEl = target && 'current' in target ? target.current : target
const initialRect = targetEl
? targetEl.getBoundingClientRect()
: {
width:
(_options$initialWidth =
options === null || options === void 0
? void 0
: options.initialWidth) !== null &&
_options$initialWidth !== void 0
? _options$initialWidth
: 0,
height:
(_options$initialHeigh =
options === null || options === void 0
? void 0
: options.initialHeight) !== null &&
_options$initialHeigh !== void 0
? _options$initialHeigh
: 0,
}
return [initialRect.width, initialRect.height]
return targetEl
? [targetEl.offsetWidth, targetEl.offsetHeight]
: [
(_options$initialWidth =
options === null || options === void 0
? void 0
: options.initialWidth) !== null &&
_options$initialWidth !== void 0
? _options$initialWidth
: 0,
(_options$initialHeigh =
options === null || options === void 0
? void 0
: options.initialHeight) !== null &&
_options$initialHeigh !== void 0
? _options$initialHeigh
: 0,
]
})

@@ -42,9 +39,8 @@ useLayoutEffect(() => {

if (!targetEl) return
const rect = targetEl.getBoundingClientRect()
setSize([rect.width, rect.height])
setSize([targetEl.offsetWidth, targetEl.offsetHeight])
}, [target]) // Where the magic happens
useResizeObserver(target, (entry) => {
const {width, height} = entry.contentRect
setSize([width, height])
const target = entry.target
setSize([target.offsetWidth, target.offsetHeight])
})

@@ -51,0 +47,0 @@ return size

{
"name": "@react-hook/size",
"version": "1.0.0",
"version": "2.0.0",
"homepage": "https://github.com/jaredLunde/react-hook#readme",

@@ -5,0 +5,0 @@ "repository": "github:jaredLunde/react-hook",

@@ -38,2 +38,3 @@ <hr>

- [x] Determines the size of the element including any padding, borders, and scroll bars.
- [x] The size reported by the hook updates each time the size of the element changes.

@@ -40,0 +41,0 @@ - [x] Uses a single `ResizeObserver` for tracking all elements used by the hooks.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc