{"name":"scroll-into-view-if-needed","description":"Ponyfill for upcoming Element.scrollIntoView() APIs like scrollMode: if-needed, behavior: smooth and block: center","license":"MIT","author":{"name":"Stian Didriksen"},"homepage":"https://scroll-into-view-if-needed.netlify.com","repository":{"type":"git","url":"git+https://github.com/stipsan/scroll-into-view-if-needed.git"},"version":"1.5.1","main":"index.js","files":["compute.js","es","typings","umd"],"scripts":{"prebuild":"yarn clean","build":"yarn build:d.ts && yarn build:cjs && yarn build:es && yarn build:umd && yarn build:umd.min","build:cjs":"BABEL_ENV=cjs babel src -d . --extensions '.ts'","build:d.ts":"tsc --emitDeclarationOnly","build:es":"BABEL_ENV=es babel src -d es --extensions '.ts'","build:umd":"BABEL_ENV=umd NODE_ENV=development rollup -c -f umd -o umd/scroll-into-view-if-needed.js","build:umd.min":"BABEL_ENV=umd NODE_ENV=production rollup -c -f umd -o umd/scroll-into-view-if-needed.min.js","clean":"rimraf 'umd' 'es' 'typings'","precommit":"lint-staged","dev":"concurrently 'tsc --watch' 'yarn build:cjs --watch'","lint":"eslint ./integration-examples","prepublishOnly":"unset npm_config_cafile && yarn build","typecheck":"tsc --noEmit"},"devDependencies":{"@babel/cli":"7.0.0-beta.46","@babel/core":"7.0.0-beta.46","@babel/plugin-external-helpers":"7.0.0-beta.46","@babel/preset-env":"7.0.0-beta.46","@babel/preset-typescript":"7.0.0-beta.46","babel-eslint":"8.2.3","babel-plugin-add-module-exports":"0.2.1","babel-plugin-dev-expression":"0.2.1","concurrently":"3.5.1","eslint":"4.19.1","eslint-config-prettier":"2.9.0","eslint-plugin-import":"2.11.0","eslint-plugin-react":"7.7.0","husky":"0.14.3","lint-staged":"7.0.5","prettier":"1.12.1","prettier-package-json":"1.5.1","rimraf":"2.6.2","rollup":"0.58.2","rollup-plugin-babel":"4.0.0-beta.4","rollup-plugin-commonjs":"9.1.0","rollup-plugin-node-resolve":"3.3.0","rollup-plugin-replace":"2.0.0","rollup-plugin-uglify":"3.0.0","semantic-release":"15.1.7","typescript":"2.8.3"},"keywords":["behavior-smooth","if-needed","polyfill","ponyfill","scroll","scroll-into-view","scrollIntoView","scrollIntoViewIfNeeded","scrollMode","smooth","smoothscroll","typescript"],"publishConfig":{"tag":"next"},"browserify":{"transform":["loose-envify"]},"lint-staged":{"*.js":["prettier --write","git add"],"*.{ts,tsx}":["prettier --write","git add"],"*.json":["prettier --write","git add"],"*.css":["prettier --write","git add"],"*.md":["prettier --write","git add"],"**/package.json":["prettier-package-json --write","git add"],"**/.babelrc":["prettier --write","git add"]},"module":"es/index.js","prettier":{"semi":false,"singleQuote":true,"trailingComma":"es5","overrides":[{"files":".babelrc","options":{"parser":"json"}}]},"release":{"prepare":["@semantic-release/npm"]},"sideEffects":false,"typings":"typings/index.d.ts","readme":"# This is the work-in-progress, the current stable version is [here](https://github.com/stipsan/scroll-into-view-if-needed/tree/v1)\n\n[![CircleCI Status](https://img.shields.io/circleci/project/github/stipsan/scroll-into-view-if-needed.svg?style=flat-square)](https://circleci.com/gh/stipsan/scroll-into-view-if-needed)\n[![npm stat](https://img.shields.io/npm/dm/scroll-into-view-if-needed.svg?style=flat-square)](https://npm-stat.com/charts.html?package=scroll-into-view-if-needed)\n[![npm version](https://img.shields.io/npm/v/scroll-into-view-if-needed.svg?style=flat-square)](https://www.npmjs.com/package/scroll-into-view-if-needed)\n[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)](https://github.com/semantic-release/semantic-release)\n![scroll-into-view-if-needed](https://user-images.githubusercontent.com/81981/39338772-34165fb2-49c5-11e8-9d29-38acb6842db8.png)\n\nThis used to be just a [ponyfill](https://ponyfill.com) for\n`Element.scrollIntoViewIfNeeded` but is currently being rewritten to cover\n`Element.scrollIntoView(ScrollIntoViewOptions)` including the new `scrollMode: \"if-needed\"` option. This readme will be updated when it's ready for stable\nrelease.\n\n## [Demo](https://scroll-into-view-if-needed.netlify.com)\n\n## Install\n\n```bash\nyarn add scroll-into-view-if-needed\n```\n\n## Usage\n\n```js\nimport scrollIntoView from 'scroll-into-view-if-needed'\nconst node = document.getElementById('hero')\n\n// similar behavior as Element.scrollIntoView({block: \"nearest\", inline: \"nearest\"})\n// only that it is a no-op if `node` is already visible\n// see: https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView\n// same behavior as Element.scrollIntoViewIfNeeded()\n// see: https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoViewIfNeeded\nscrollIntoView(node, {\n  scrollMode: 'if-needed',\n  block: 'nearest',\n  inline: 'nearest',\n})\n\n// same behavior as Element.scrollIntoViewIfNeeded(true) without the \"IfNeeded\" behavior\n// see: https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoViewIfNeeded\nscrollIntoView(node, { block: 'center', inline: 'center' })\n// scrollMode is \"always\" by default\n\n// smooth scroll if the browser supports it and if the element isn't visible\nscrollIntoView(node, { behavior: 'smooth', scrollMode: 'if-needed' })\n```\n\n### Ponyfill smooth scrolling\n\nIf you're ok with a larger bundlesize and want the smooth scrolling behavior to be ponyfilled you can use the [`smooth-scroll-into-view-if-needed`](https://github.com/stipsan/smooth-scroll-into-view-if-needed) addon.\n\n### Custom scrolling transition\n\nIf the default smooth scrolling ponyfill isn't the duration or easing you want,\nyou can provide your own scrolling logic by giving `behavior` a callback.\n\n```js\nimport scrollIntoView from 'scroll-into-view-if-needed'\nconst node = document.getElementById('hero')\n\nscrollIntoView(node, {\n  // Your scroll actions will always be an array, even if there is nothing to scroll\n  behavior: scrollActions =>\n    // list is sorted from innermost (closest parent to your target) to outermost (often the document.body or viewport)\n    scrollActions.forEach(([el, scrollTop, scrollLeft]) => {\n      // implement the scroll anyway you want\n      el.scrollTop = scrollTop\n      el.scrollLeft = scrollLeft\n\n      // If you need the relative scroll coordinates, for things like window.scrollBy style logic, just do the math\n      const offsetTop = el.scrollTop - scrollTop\n      const offsetLeft = el.scrollLeft - scrollLeft\n    }),\n  // all the other options (scrollMode, block, inline) still work, so you don't need to reimplement them (unless you really really want to)\n})\n```\n\n## More documentation will be added (hang in there)\n","readmeFilename":"README.md","gitHead":"2ee61bd8fde564870589e052e8c7d7d7aa20c5f2","bugs":{"url":"https://github.com/stipsan/scroll-into-view-if-needed/issues"},"_id":"scroll-into-view-if-needed@1.5.1","_npmVersion":"5.6.0","_nodeVersion":"8.11.1","_npmUser":{"name":"stipsan","email":"stipsan@gmail.com"},"dist":{"integrity":"sha512-Bkd1QjLu2gbqwWTvcODeFnYMBurIzqOMKdf+mHFG8emwIxCAV22vDZLCSSotKQUeGGDYy58fq+ciRpEsuiUzeg==","shasum":"79e6bad6cd93d723e5b2fef3bddbcff55475e781","tarball":"http://registry-npm.ywwl.com/scroll-into-view-if-needed/download/scroll-into-view-if-needed-1.5.1.tgz","fileCount":12,"unpackedSize":48362,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJa5K0kCRA9TVsSAnZWagAAZgoP/3eRPEA7BORpL6hPVnWd\nH6wqg87NPY3orBZvsdG9heSyGdRG4YK8maHvN9ghCYuIGAYtR1WVJsXA5EyU\nymhqfvv4Vp51Q1yqyxmJZ9Im18x9kHc09nXdpGDVvPbOsLNHnsMcKpklbFb9\nDTb8RX1hgmUzEdETFo1gzPh1kzOCFWtKlEeMdwM0WHqUC84r5j2ZKjrogD32\nmhhlu3AARN/51FI0eD4gvAS1DJg3d7HguNfg2+TQYZHFueh9ltSHkq5eQDII\nB1wWR8IRarD9cfEq+oOHm11BMPuGzrHTmV1CE7O4ZopWBW/oBT4nJKj5OR/7\n1IJarIw2Sj66WKlXy9tgeOa9tof0GRXTKQW0IbSQPzqicqwuohCXaSdRNe83\naTCUGEwJX267z2FX92qb/82F4wfXTIjZj6Umnsq7mSZ7CcQpAtP2lAe9SuYs\nWJoKMJq3iRy+klL71+h2riuhnJrYglsqnz85/Tjb5/7UOAPEiADiAB6fXsz3\nreeTIx8dmY3+3DOo+mNvbb8ZdrzMtDVDTyRux1mbNc28Pui40DzEr7zWuQGc\nOUPohWPTR8IsF1BDFJeH/nK3m+OXIUpdCnWRKYWIYIdwiYO1zu53Cd80KxjQ\nJA00Pa/Gt2GDcTQfU0DkmCMxg4iJ8Cicm0mEkqKwWluJyUbv1IoIHBAAhfUP\nj6rv\r\n=dLU0\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDZrajAInlj6QOf5bcE9IMUdJrni8aOMLuckxoeeIlsIQIgWdiyyaPCODT6Bq6/HDwO7XSgTe3KfECrrUp13vHkFfo="}],"size":9614,"noattachment":false,"key":"/scroll-into-view-if-needed/-/scroll-into-view-if-needed-1.5.1.tgz"},"maintainers":[{"name":"stipsan","email":"stipsan@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/scroll-into-view-if-needed_1.5.1_1524935971797_0.7345063509541805"},"_hasShrinkwrap":false,"deprecated":"this version is actually an v2 alpha, please use 1.5.0 instead or consider upgrading to the latest v2","publish_time":1524935971864,"_cnpm_publish_time":1524935971864,"dist-tags":{"latest":"3.1.0"}}