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.12.2 to 2.0.1

2

dist/index.cjs.js

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

"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var t=e(require("react"));function r(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function o(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==r)return;var n,o,i=[],c=!0,a=!1;try{for(r=r.call(e);!(c=(n=r.next()).done)&&(i.push(n.value),!t||i.length!==t);c=!0);}catch(e){a=!0,o=e}finally{try{c||null==r.return||r.return()}finally{if(a)throw o}}return i}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return i(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return i(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}module.exports=function(e){var i=e.children,c=e.selector,a=e.smooth,u=void 0===a||a,l=e.style,s=void 0===l?{}:l,f=e.alignToTop,b=void 0!==f&&f,y=e.className,p=void 0===y?"":y,v=e.onClick,d=e.scrollOptions,m=void 0===d?{}:d,O=function(){var e=function(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?r(Object(o),!0).forEach((function(t){n(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):r(Object(o)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}({behavior:u?"smooth":"instant"},function(e){var t={};return e instanceof Object&&Object.entries(e).forEach((function(e){var r=o(e,2),n=r[0],i=r[1];switch(n){case"behavior":"auto"!==i&&"smooth"!==i||(t[n]=i);case"block":case"inline":"start"!==i&&"center"!==i&&"end"!==i&&"nearest"!==i||(t[n]=i)}})),t}(m));b&&(e.block="start",e.inline="nearest"),document.querySelector(c).scrollIntoView(e)};return t.default.createElement("div",{style:s,className:p,onClick:function(e){"function"==typeof v?(v(e),setTimeout(O,1e3/60)):O()}},i)};
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var t=e(require("react"));module.exports=({children:e,selector:o,smooth:r=!0,style:n={},alignToTop:s=!1,className:c="",onClick:i,scrollOptions:l={}})=>{const a=()=>{var e;const t=r?"smooth":"auto",n=Object.assign({behavior:t},(e=>"object"!=typeof e?{}:Object.entries(e).reduce(((e,[t,o])=>{switch(t){case"behavior":"auto"!==o&&"smooth"!==o||(e[t]=o);case"block":case"inline":"start"!==o&&"center"!==o&&"end"!==o&&"nearest"!==o||(e[t]=o)}return e}),{}))(l));s&&(n.block="start",n.inline="nearest"),null===(e=document.querySelector(o))||void 0===e||e.scrollIntoView(n)};return t.default.createElement("div",{style:n,className:c,onClick:e=>{if("function"==typeof i)return i(e),void setTimeout(a,1e3/60);a()}},e)};

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

import t from"react";function e(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function r(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function n(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null==r)return;var n,o,i=[],c=!0,a=!1;try{for(r=r.call(t);!(c=(n=r.next()).done)&&(i.push(n.value),!e||i.length!==e);c=!0);}catch(t){a=!0,o=t}finally{try{c||null==r.return||r.return()}finally{if(a)throw o}}return i}(t,e)||function(t,e){if(!t)return;if("string"==typeof t)return o(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return o(t,e)}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var i=function(o){var i=o.children,c=o.selector,a=o.smooth,l=void 0===a||a,u=o.style,s=void 0===u?{}:u,f=o.alignToTop,b=void 0!==f&&f,y=o.className,p=void 0===y?"":y,v=o.onClick,m=o.scrollOptions,O=void 0===m?{}:m,d=function(){var t=function(t){for(var n=1;n<arguments.length;n++){var o=null!=arguments[n]?arguments[n]:{};n%2?e(Object(o),!0).forEach((function(e){r(t,e,o[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):e(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}))}return t}({behavior:l?"smooth":"instant"},function(t){var e={};return t instanceof Object&&Object.entries(t).forEach((function(t){var r=n(t,2),o=r[0],i=r[1];switch(o){case"behavior":"auto"!==i&&"smooth"!==i||(e[o]=i);case"block":case"inline":"start"!==i&&"center"!==i&&"end"!==i&&"nearest"!==i||(e[o]=i)}})),e}(O));b&&(t.block="start",t.inline="nearest"),document.querySelector(c).scrollIntoView(t)};return t.createElement("div",{style:s,className:p,onClick:function(t){"function"==typeof v?(v(t),setTimeout(d,1e3/60)):d()}},i)};export{i as default};
import e from"react";const t=({children:t,selector:o,smooth:s=!0,style:c={},alignToTop:n=!1,className:r="",onClick:a,scrollOptions:i={}})=>{const l=()=>{var e;const t=s?"smooth":"auto",c=Object.assign({behavior:t},(e=>"object"!=typeof e?{}:Object.entries(e).reduce(((e,[t,o])=>{switch(t){case"behavior":"auto"!==o&&"smooth"!==o||(e[t]=o);case"block":case"inline":"start"!==o&&"center"!==o&&"end"!==o&&"nearest"!==o||(e[t]=o)}return e}),{}))(i));n&&(c.block="start",c.inline="nearest"),null===(e=document.querySelector(o))||void 0===e||e.scrollIntoView(c)};return e.createElement("div",{style:c,className:r,onClick:e=>{if("function"==typeof a)return a(e),void setTimeout(l,1e3/60);l()}},t)};export{t as default};
{
"name": "react-scroll-into-view",
"version": "1.12.2",
"version": "2.0.1",
"description": "Simple React element that when clicked scrolls to any element on page",

@@ -12,8 +12,10 @@ "main": "./dist/index.cjs.js",

"files": [
"dist/",
"react-scroll-into-view.d.ts"
"dist/"
],
"scripts": {
"build": "package-check && rollup -c",
"test": "jest"
"build": "package-check && rollup -c && npm run move_types",
"test": "jest",
"tsc": "tsc",
"move_types": "mv dist/*.ts types/",
"prepare": "husky install"
},

@@ -39,9 +41,18 @@ "repository": {

"@babel/preset-react": "^7.0.0",
"@commitlint/cli": "^17.0.3",
"@commitlint/config-conventional": "^17.0.3",
"@rollup/plugin-babel": "^5.3.0",
"@rollup/plugin-node-resolve": "^13.0.5",
"@rollup/plugin-typescript": "^8.3.4",
"@skypack/package-check": "^0.2.2",
"babel-jest": "^27.2.2",
"babel-plugin-transform-react-remove-prop-types": "^0.4.18",
"jest": "^27.2.2",
"prop-types": "^15.6.1",
"@testing-library/react": "12.1.5",
"@types/jest": "^28.1.6",
"@types/node": "^18.6.3",
"@types/react": "^18.0.15",
"@types/react-dom": "^18.0.6",
"@types/react-test-renderer": "^18.0.0",
"babel-jest": "^28.1.3",
"husky": "^8.0.0",
"jest": "^28.1.3",
"jest-environment-jsdom": "^28.1.3",
"react": "^16.5.2",

@@ -51,3 +62,7 @@ "react-dom": "^16.5.2",

"rollup": "^2.57.0",
"rollup-plugin-terser": "^7.0.2"
"rollup-plugin-filesize": "^9.1.2",
"rollup-plugin-terser": "^7.0.2",
"ts-jest": "^28.0.7",
"tslib": "^2.4.0",
"typescript": "^4.7.4"
},

@@ -64,3 +79,3 @@ "peerDependencies": {

},
"types": "react-scroll-into-view.d.ts"
"types": "types/index.d.ts"
}

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

| selector | String | | **Required**. Valid [CSS Selector](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors) to element to which we want to scroll |
| smooth | Boolean | true | Scroll behaviour; when true - transition animation will be smooth. Otherwise instant. |
| smooth | Boolean | true | Scroll behavior; when true - transition animation will be smooth. Same as setting `scrollOptions.behavior = smooth` |
| style | Object | {} | CSS styles passed to element <br>**NOTE** prior v1.4.0 default value was `{display: 'inline'}` |

@@ -59,0 +59,0 @@ | alignToTop | Boolean | false | Whether top of the element should be aligned to the top of the visible area. Default: aligns to bottom of element |

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