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.5.3 to 1.5.4

2

dist/index.js

@@ -1,1 +0,1 @@

"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var React=require("react"),React__default=_interopDefault(React);function _extends(){return(_extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function _inheritsLoose(e,t){e.prototype=Object.create(t.prototype),(e.prototype.constructor=e).__proto__=t}function unwrapExports(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function createCommonjsModule(e,t){return e(t={exports:{}},t.exports),t.exports}var lib=createCommonjsModule(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});t.createChangeEmitter=function(){var n=[],r=n;function o(){r===n&&(r=n.slice())}return{listen:function(t){if("function"!=typeof t)throw new Error("Expected listener to be a function.");var n=!0;return o(),r.push(t),function(){if(n){n=!1,o();var e=r.indexOf(t);r.splice(e,1)}}},emit:function(){for(var e=n=r,t=0;t<e.length;t++)e[t].apply(e,arguments)}}}});unwrapExports(lib);var root,lib_1=lib.createChangeEmitter;function symbolObservablePonyfill(e){var t,n=e.Symbol;return"function"==typeof n?n.observable?t=n.observable:(t=n("observable"),n.observable=t):t="@@observable",t}var result=symbolObservablePonyfill(root="undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof module?module:Function("return this")()),setStatic=function(t,n){return function(e){return e[t]=n,e}},setDisplayName=function(e){return setStatic("displayName",e)},getDisplayName=function(e){return"string"==typeof e?e:e?e.displayName||e.name||"Component":void 0},wrapDisplayName=function(e,t){return t+"("+getDisplayName(e)+")"},mapValues=function(e,t){var n={};for(var r in e)e.hasOwnProperty(r)&&(n[r]=t(e[r],r));return n},withHandlers=function(a){return function(e){var t=React.createFactory(e),n=function(o){function e(){for(var n,e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return(n=o.call.apply(o,[this].concat(t))||this).handlers=mapValues("function"==typeof a?a(n.props):a,function(t){return function(){var e=t(n.props);return"production"!==process.env.NODE_ENV&&"function"!=typeof e&&console.error("withHandlers(): Expected a map of higher-order functions. Refer to the docs for more info."),e.apply(void 0,arguments)}}),n}return _inheritsLoose(e,o),e.prototype.render=function(){return t(_extends({},this.props,this.handlers))},e}(React.Component);return"production"!==process.env.NODE_ENV?setDisplayName(wrapDisplayName(e,"withHandlers"))(n):n}},defaultProps=function(r){return function(e){function t(e){return n(e)}var n=React.createFactory(e);return t.defaultProps=r,"production"!==process.env.NODE_ENV?setDisplayName(wrapDisplayName(e,"defaultProps"))(t):t}},compose=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.reduce(function(e,t){return function(){return e(t.apply(void 0,arguments))}},function(e){return e})},ScrollInto=function(e){var t=e.children,n=e.scrollIntoView,r=e.style,o=e.className;return React__default.createElement("div",{style:r,className:o,onClick:n},t)},index=compose(defaultProps({smooth:!0,style:{},alignToTop:!1,className:""}),withHandlers({scrollIntoView:function(e){var n=e.selector,r=e.smooth,o=e.alignToTop;return function(e){var t={behavior:r?"smooth":"instant"};o&&(t.block="start",t.inline="nearest"),document.querySelector(n).scrollIntoView(t)}}}))(ScrollInto);module.exports=index;
"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var React=_interopDefault(require("react")),ScrollInto=function(e){var t=e.children,o=e.selector,r=e.smooth,n=void 0===r||r,l=e.style,i=void 0===l?{}:l,a=e.alignToTop,c=void 0!==a&&a,s=e.className,u=void 0===s?"":s;return React.createElement("div",{style:i,className:u,onClick:function(){var e={behavior:n?"smooth":"instant"};c&&(e.block="start",e.inline="nearest"),document.querySelector(o).scrollIntoView(e)}},t)};module.exports=ScrollInto;
{
"name": "react-scroll-into-view",
"version": "1.5.3",
"version": "1.5.4",
"description": "Simple React element that when clicked scrolls to any element on page",

@@ -37,3 +37,2 @@ "main": "dist/index.js",

"react-test-renderer": "^16.5.2",
"recompose": "^0.30.0",
"rollup": "1.20.3",

@@ -40,0 +39,0 @@ "rollup-plugin-babel": "^4.0.3",

@@ -1,10 +0,23 @@

import React from 'react';
import PropTypes from 'prop-types';
import { compose, defaultProps, withHandlers } from 'recompose';
import React from 'react'
import PropTypes from 'prop-types'
const ScrollInto = ({ children, scrollIntoView, style, className }) => (
<div style={style} className={className} onClick={scrollIntoView}>
const ScrollInto = ({ children, selector, smooth = true, style = {}, alignToTop = false, className = '' }) => {
const scrollIntoView = _ => {
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(options)
}
return <div style={style} className={className} onClick={scrollIntoView}>
{children}
</div>
);
}

@@ -17,25 +30,4 @@ ScrollInto.propTypes = {

className: PropTypes.string
};
}
export default compose(
defaultProps({
smooth: true,
style: {},
alignToTop: false,
className: ''
}),
withHandlers({
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(options);
}
})
)(ScrollInto);
export default 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