{"_id":"normalize-scroll-left","_rev":"2829075","name":"normalize-scroll-left","description":"Utility library to determine and normalize Element.scrollLeft behavior","dist-tags":{"latest":"0.2.1"},"maintainers":[{"name":"alitaheri","email":""}],"time":{"modified":"2022-09-06T14:41:37.000Z","created":"2017-10-03T09:18:11.236Z","0.2.1":"2020-09-07T20:27:26.608Z","0.2.0":"2019-06-01T17:41:15.121Z","0.1.2":"2017-10-13T09:43:14.208Z","0.1.1":"2017-10-09T19:24:48.807Z","0.1.0":"2017-10-03T09:18:11.236Z"},"users":{},"author":{"name":"Ali Taheri Moghaddar","email":"ali.taheri.m@gmail.com"},"repository":{"type":"git","url":"git+ssh://git@github.com/alitaheri/normalize-scroll-left.git"},"versions":{"0.2.1":{"name":"normalize-scroll-left","description":"Utility library to determine and normalize Element.scrollLeft behavior","version":"0.2.1","author":{"name":"Ali Taheri Moghaddar","email":"ali.taheri.m@gmail.com"},"repository":{"type":"git","url":"git+ssh://git@github.com/alitaheri/normalize-scroll-left.git"},"keywords":["rtl","dom","scroll-left","scrollLeft","normalize","browser","element"],"scripts":{"build":"rimraf cjs esm && tsc --module commonjs --outDir cjs && tsc --module es6 --outDir esm","prepublishOnly":"npm run build","lint":"tslint -e \"node_modules/**\" \"src/**/*.ts\"","test":"mocha -r ts-node/register \"src/**/*.spec.ts\""},"license":"MIT","main":"cjs/main.js","module":"esm/main.js","types":"cjs/main.d.ts","devDependencies":{"@types/chai":"^4.2.12","@types/mocha":"^8.0.3","@types/node":"^14.6.4","chai":"^4.2.0","mocha":"^8.1.3","rimraf":"^3.0.2","ts-loader":"^8.0.3","ts-node":"^9.0.0","tslint":"^6.1.3","tslint-eslint-rules":"^5.4.0","tslint-microsoft-contrib":"^6.2.0","typescript":"^4.0.2"},"gitHead":"eef5dd4bfe62d7b5e5ee8103d40ba66f401cb094","bugs":{"url":"https://github.com/alitaheri/normalize-scroll-left/issues"},"homepage":"https://github.com/alitaheri/normalize-scroll-left#readme","_id":"normalize-scroll-left@0.2.1","_nodeVersion":"12.11.0","_npmVersion":"6.13.3","dist":{"shasum":"978fdd04bfeb2d3543e16696814285557c127502","size":3815,"noattachment":false,"key":"/normalize-scroll-left/-/normalize-scroll-left-0.2.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/normalize-scroll-left/download/normalize-scroll-left-0.2.1.tgz"},"maintainers":[{"name":"alitaheri","email":""}],"_npmUser":{"name":"alitaheri","email":"ali.taheri.m@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/normalize-scroll-left_0.2.1_1599510446491_0.8244516919463856"},"_hasShrinkwrap":false,"publish_time":1599510446608,"_cnpm_publish_time":1599510446608,"_cnpmcore_publish_time":"2021-12-16T10:34:28.655Z"},"0.2.0":{"name":"normalize-scroll-left","description":"Utility library to determine and normalize Element.scrollLeft behavior","version":"0.2.0","author":{"name":"Ali Taheri Moghaddar","email":"ali.taheri.m@gmail.com"},"repository":{"type":"git","url":"git+ssh://git@github.com/alitaheri/normalize-scroll-left.git"},"keywords":["rtl","dom","scroll-left","scrollLeft","normalize","browser","element"],"scripts":{"build":"rimraf cjs esm && tsc --module commonjs --outDir cjs && tsc --module es6 --outDir esm","prepublishOnly":"npm run build","lint":"tslint -e \"node_modules/**\" \"src/**/*.ts\"","test":"mocha -r ts-node/register \"src/**/*.spec.ts\""},"license":"MIT","main":"cjs/main.js","module":"esm/main.js","types":"cjs/main.d.ts","devDependencies":{"@types/chai":"^4.1.7","@types/mocha":"^5.2.7","@types/node":"^12.0.4","chai":"^4.2.0","mocha":"^6.1.4","rimraf":"^2.6.3","ts-loader":"^6.0.2","ts-node":"^8.2.0","tslint":"^5.17.0","tslint-eslint-rules":"^5.4.0","tslint-microsoft-contrib":"^6.2.0","typescript":"^3.5.1"},"gitHead":"2120cf215d146cd586b0a294da819642c7c977bf","bugs":{"url":"https://github.com/alitaheri/normalize-scroll-left/issues"},"homepage":"https://github.com/alitaheri/normalize-scroll-left#readme","_id":"normalize-scroll-left@0.2.0","_npmVersion":"6.1.0","_nodeVersion":"12.1.0","_npmUser":{"name":"alitaheri","email":"ali.taheri.m@gmail.com"},"dist":{"shasum":"9445d74275f303cc661e113329aefa492f58114c","size":3778,"noattachment":false,"key":"/normalize-scroll-left/-/normalize-scroll-left-0.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/normalize-scroll-left/download/normalize-scroll-left-0.2.0.tgz"},"maintainers":[{"name":"alitaheri","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/normalize-scroll-left_0.2.0_1559410875018_0.8373502041912004"},"_hasShrinkwrap":false,"publish_time":1559410875121,"_cnpm_publish_time":1559410875121,"_cnpmcore_publish_time":"2021-12-16T10:34:28.877Z"},"0.1.2":{"name":"normalize-scroll-left","description":"Utility library to determine and normalize Element.scrollLeft behavior","version":"0.1.2","author":{"name":"Ali Taheri Moghaddar","email":"ali.taheri.m@gmail.com"},"files":["lib"],"repository":{"type":"git","url":"git+ssh://git@github.com/alitaheri/normalize-scroll-left.git"},"keywords":["rtl","dom","scroll-left","scrollLeft","normalize","browser","element"],"scripts":{"build":"rimraf lib && tsc","prepublishOnly":"npm run build","lint":"tslint -e \"node_modules/**\" \"src/**/*.ts\"","test":"mocha --compilers ts:ts-node/register \"src/**/*.spec.ts\""},"license":"MIT","main":"lib/main.js","types":"lib/main.d.ts","devDependencies":{"@types/chai":"^4.0.4","@types/mocha":"^2.2.43","@types/node":"^8.0.34","chai":"^4.1.2","mocha":"^4.0.1","rimraf":"^2.6.2","ts-loader":"^2.3.7","ts-node":"^3.3.0","tslint":"^5.7.0","tslint-eslint-rules":"^4.1.1","tslint-microsoft-contrib":"^5.0.1","typescript":"^2.5.3"},"gitHead":"bdc4ac297fdf1cd4920998456cd09f9dc0293e71","bugs":{"url":"https://github.com/alitaheri/normalize-scroll-left/issues"},"homepage":"https://github.com/alitaheri/normalize-scroll-left#readme","_id":"normalize-scroll-left@0.1.2","_npmVersion":"5.4.2","_nodeVersion":"8.6.0","_npmUser":{"name":"alitaheri","email":"ali.taheri.m@gmail.com"},"dist":{"shasum":"6b79691ba79eb5fb107fa5edfbdc06b55caee2aa","size":3655,"noattachment":false,"key":"/normalize-scroll-left/-/normalize-scroll-left-0.1.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/normalize-scroll-left/download/normalize-scroll-left-0.1.2.tgz"},"maintainers":[{"name":"alitaheri","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/normalize-scroll-left-0.1.2.tgz_1507887793335_0.37238744203932583"},"directories":{},"publish_time":1507887794208,"_hasShrinkwrap":false,"_cnpm_publish_time":1507887794208,"_cnpmcore_publish_time":"2021-12-16T10:34:29.119Z"},"0.1.1":{"name":"normalize-scroll-left","description":"Utility library to determine and normalize Element.scrollLeft behavior","version":"0.1.1","author":{"name":"Ali Taheri Moghaddar","email":"ali.taheri.m@gmail.com"},"files":["lib"],"repository":{"type":"git","url":"git+ssh://git@github.com/alitaheri/normalize-scroll-left.git"},"keywords":["rtl","dom","scroll-left","scrollLeft","normalize","browser","element"],"scripts":{"build":"rimraf lib && tsc","prepublishOnly":"npm run build","lint":"tslint -e \"node_modules/**\" \"**/*.ts\"","test":"mocha --compilers ts:ts-node/register \"src/**/*.spec.ts\""},"license":"MIT","main":"lib/main.js","types":"lib/main.d.ts","devDependencies":{"@types/chai":"^4.0.4","@types/mocha":"^2.2.43","@types/node":"^8.0.33","chai":"^4.1.2","mocha":"^4.0.1","rimraf":"^2.6.2","ts-loader":"^2.3.7","ts-node":"^3.3.0","tslint":"^5.7.0","tslint-eslint-rules":"^4.1.1","tslint-microsoft-contrib":"^5.0.1","typescript":"^2.5.3"},"gitHead":"ccdc46745034b91216fee45ca491d194e1319ab1","bugs":{"url":"https://github.com/alitaheri/normalize-scroll-left/issues"},"homepage":"https://github.com/alitaheri/normalize-scroll-left#readme","_id":"normalize-scroll-left@0.1.1","_npmVersion":"5.4.2","_nodeVersion":"8.6.0","_npmUser":{"name":"alitaheri","email":"ali.taheri.m@gmail.com"},"dist":{"shasum":"a31d3eb670eea165b171cabc9d9ca6ae645a64c0","size":4341,"noattachment":false,"key":"/normalize-scroll-left/-/normalize-scroll-left-0.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/normalize-scroll-left/download/normalize-scroll-left-0.1.1.tgz"},"maintainers":[{"name":"alitaheri","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/normalize-scroll-left-0.1.1.tgz_1507577087544_0.16197808901779354"},"directories":{},"publish_time":1507577088807,"_hasShrinkwrap":false,"_cnpm_publish_time":1507577088807,"_cnpmcore_publish_time":"2021-12-16T10:34:29.333Z"},"0.1.0":{"name":"normalize-scroll-left","description":"Utility library to determine and normalize Element.scrollLeft behavior","version":"0.1.0","author":{"name":"Ali Taheri Moghaddar","email":"ali.taheri.m@gmail.com"},"files":["lib"],"repository":{"type":"git","url":"git+ssh://git@github.com/alitaheri/normalize-scroll-left.git"},"keywords":["rtl","dom","scroll-left","scrollLeft","normalize","browser","element"],"scripts":{"build":"rimraf lib && tsc","prepublishOnly":"npm run build","lint":"tslint -e \"node_modules/**\" \"**/*.ts\"","test":"mocha --compilers ts:ts-node/register \"src/**/*.spec.ts\""},"license":"MIT","main":"lib/main.js","types":"lib/main.d.ts","devDependencies":{"@types/chai":"^4.0.4","@types/mocha":"^2.2.43","@types/node":"^8.0.31","chai":"^4.1.2","mocha":"^4.0.0","rimraf":"^2.6.2","ts-loader":"^2.3.7","ts-node":"^3.3.0","tslint":"^5.7.0","tslint-eslint-rules":"^4.1.1","tslint-microsoft-contrib":"^5.0.1","typescript":"^2.5.3"},"gitHead":"31b614d3013752740bf15815f17cc53f4524c7a1","bugs":{"url":"https://github.com/alitaheri/normalize-scroll-left/issues"},"homepage":"https://github.com/alitaheri/normalize-scroll-left#readme","_id":"normalize-scroll-left@0.1.0","_npmVersion":"5.4.2","_nodeVersion":"8.3.0","_npmUser":{"name":"alitaheri","email":"ali.taheri.m@gmail.com"},"dist":{"shasum":"917d04b9d80e390797209424f8baa2453daacb90","size":4334,"noattachment":false,"key":"/normalize-scroll-left/-/normalize-scroll-left-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/normalize-scroll-left/download/normalize-scroll-left-0.1.0.tgz"},"maintainers":[{"name":"alitaheri","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/normalize-scroll-left-0.1.0.tgz_1507022290351_0.4849068778567016"},"directories":{},"publish_time":1507022291236,"_hasShrinkwrap":false,"_cnpm_publish_time":1507022291236,"_cnpmcore_publish_time":"2021-12-16T10:34:29.533Z"}},"readme":"# Normalize Scroll Left for Right-to-Left\r\n\r\nThis library normalizes the `Element.scrollLeft` property when direction is `rtl`.\r\n\r\nAll the hardwork are based on [this juqery plugin](https://github.com/othree/jquery.rtl-scroll-type)\r\nand [this stackoverflow answer](https://stackoverflow.com/a/24394376).\r\n\r\nSince `Element.scrollLeft`'s behavior with `dir=\"rtl\"` is not defined in any spec we use\r\na feature detection logic to determine the behavior of the current browser.\r\n\r\nTypes of `scrollLeft` (`scrollWidth` = 100) (Copied from \r\n[here](https://github.com/othree/jquery.rtl-scroll-type#3-types-of-scrollleft-scrollwidth--100))\r\n\r\nBrowser        | Type          | Most Left | Most Right | Initial\r\n-------------- | ------------- | --------- | ---------- | -------\r\nWebKit         | default       | 0         | 100        | 100\r\nFirefox/Opera  | negative      | -100      | 0          | 0\r\nIE/Edge        | reverse       | 100       | 0          | 0\r\n\r\n## Installation\r\n\r\nYou can install this package with the following command:\r\n\r\n```sh\r\nnpm install normalize-scroll-left\r\n```\r\n\r\n## API\r\n\r\nThis library exposes these methods:\r\n\r\n### `detectScrollType`\r\n\r\n```ts\r\ntype ScrollType = 'indeterminate' | 'default' | 'negative' | 'reverse';\r\nfunction detectScrollType(): ScrollType;\r\n```\r\n\r\nThis function returns the scroll type detected, Keep in mind, this function\r\ncaches the result as it should render a dummy on the DOM (which is expensive).\r\nMake sure the first invocation of this function happens **after** the body is loaded.\r\n\r\n**note**: To support server-side-rendering, it will output `indeterminate` if\r\nit detects a non-browser environment.\r\n\r\n```javascript\r\nimport { detectScrollType } from 'normalize-scroll-left';\r\n\r\nconst type = detectScrollType();\r\n```\r\n\r\nThe output is not based on the browser, but feature detection:\r\n\r\nBrowser        | Type\r\n-------------- | -------------\r\nWebKit         | `default`\r\nFirefox/Opera  | `negative`\r\nIE/Edge        | `reverse`\r\nOther/Server   | `indeterminate`\r\n\r\n### `getNormalizedScrollLeft`\r\n\r\n```ts\r\nfunction getNormalizedScrollLeft(element: HTMLElement, direction: 'rtl' | 'ltr'): number;\r\n```\r\n\r\nYou can use this method to get the normalized `scrollLeft` property of an element.\r\nYou should explicitly pass the direction for the following reasons:\r\n\r\n1. Querying the `getComputedStyle` is expensive and might cause a reflow.\r\n2. The behavior shouldn't be changed when direction is `ltr`.\r\n\r\nThe output is `NaN` on the server. Otherwise, it will mimic the behavior of\r\n`WebKit` as it's the esiest to work with.\r\n\r\n```ts\r\nimport { getNormalizedScrollLeft } from 'normalize-scroll-left';\r\n\r\nconst element = document.getElementById('my-scrollable-container');\r\n\r\n// element.scrollWidth = 100;\r\n\r\nconst scrollLeft = getNormalizedScrollLeft(element, 'rtl');\r\n\r\n// scrollLeft will always be from 0 (Most Left) to 100 (Most Right).\r\n// It will initially be 100, That means the most right.\r\n```\r\n\r\n### `setNormalizedScrollLeft`\r\n\r\n```ts\r\nfunction setNormalizedScrollLeft(\r\n  element: HTMLElement,\r\n  scrollLeft: number,\r\n  direction: 'rtl' | 'ltr',\r\n): void;\r\n```\r\n\r\nYou can use this method to set the `scrollLeft` property of an element as normalized.\r\nYou should explicitly pass the direction for the same reasons as `getNormalizedScrollLeft`:\r\n\r\nFor `scrollWidth = 100` the argument `scrollLeft` must be between `0` and `100`. This\r\nfunction will automatically convert it into something the current browser understands.\r\n\r\n```ts\r\nimport { setNormalizedScrollLeft } from 'normalize-scroll-left';\r\n\r\nconst element = document.getElementById('my-scrollable-container');\r\n\r\n// element.scrollWidth = 100, element.clientWidth = 20;\r\n\r\nsetNormalizedScrollLeft(element, 20, 'rtl');\r\n\r\n// Will set element.scrollLeft to ...\r\n//  20 in WebKit (chrome)\r\n//  -60 in Firefox/Opera\r\n//  60 in IE/Edge\r\n// Does nothing on the server\r\n```\r\n\r\n## Typings\r\n\r\nThe typescript type definitions are also available and are installed via npm.\r\n\r\n## License\r\nThis project is licensed under the\r\n[MIT license](https://github.com/alitaheri/normalize-scroll-left/blob/master/LICENSE).","_attachments":{},"homepage":"https://github.com/alitaheri/normalize-scroll-left#readme","bugs":{"url":"https://github.com/alitaheri/normalize-scroll-left/issues"},"license":"MIT"}