Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-scroll-into-view

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-scroll-into-view - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

2

package.json
{
"name": "react-scroll-into-view",
"version": "1.2.0",
"version": "1.3.0",
"description": "Simple React element that when clicked scrolls to any element on page",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -46,3 +46,3 @@ # React scroll-into-view

## Changelog
See [releases](/dominikbulaj/react-scroll-into-view/releases) tab
See [releases](https://github.com/dominikbulaj/react-scroll-into-view/releases) tab

@@ -49,0 +49,0 @@ ## TODO

import React from 'react'
import PropTypes from 'prop-types'
import { compose, withHandlers } from 'recompose'
import { compose, defaultProps, withHandlers } from 'recompose'
const defaultStyle = {
display:'inline',
display: 'inline',
}
const ScrollInto = ({ children, scrollIntoView, style }) => (
<div style={{...defaultStyle, style}} onClick={scrollIntoView}>
<div style={{ ...defaultStyle, style }} onClick={scrollIntoView}>
{children}

@@ -19,17 +19,25 @@ </div>

style: PropTypes.object,
alignToTop: PropTypes.bool,
}
ScrollInto.defaultProps = {
smooth: true,
style: {}
}
export default compose(
defaultProps({
smooth: true,
style: {},
alignToTop: false
}),
withHandlers({
scrollIntoView: ({ selector, smooth = true }) => e => {
scrollIntoView: ({ selector, smooth, alignToTop }) => _ => {
const behavior = smooth ? 'smooth' : 'instant'
const options = { behavior }
// scroll to top
if (alignToTop) {
options.block = 'start'
options.inline = 'nearest'
}
const el = document.querySelector(selector)
el.scrollIntoView({ behavior })
el.scrollIntoView(options)
}
})
)(ScrollInto)
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