Skip to content

Commit 770d3fc

Browse files
chore(prettier): 🤖 ✨
1 parent 7a68079 commit 770d3fc

File tree

16 files changed

+3946
-3460
lines changed

16 files changed

+3946
-3460
lines changed

‎package.json

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,32 @@
11
{
22
"name": "scroll-into-view-if-needed",
3+
"version": "2.0.0-dev",
34
"description": "Ponyfill for upcoming Element.scrollIntoView() APIs like scrollMode: if-needed, behavior: smooth and block: center",
4-
"license": "MIT",
5-
"author": "Cody Olsen",
5+
"keywords": [
6+
"behavior-smooth",
7+
"if-needed",
8+
"polyfill",
9+
"ponyfill",
10+
"scroll",
11+
"scroll-into-view",
12+
"scrollIntoView",
13+
"scrollIntoViewIfNeeded",
14+
"scrollMode",
15+
"smooth",
16+
"smoothscroll",
17+
"typescript"
18+
],
619
"homepage": "https://scroll-into-view.dev",
720
"repository": {
821
"type": "git",
922
"url": "git+https://github.com/scroll-into-view/scroll-into-view-if-needed.git"
1023
},
11-
"version": "2.0.0-dev",
24+
"license": "MIT",
25+
"author": "Cody Olsen",
26+
"sideEffects": false,
1227
"main": "index.js",
1328
"module": "es/index.js",
29+
"typings": "typings/index.d.ts",
1430
"files": [
1531
"es",
1632
"typings",
@@ -25,14 +41,30 @@
2541
"build:umd": "BABEL_ENV=umd NODE_ENV=development rollup -c -f umd -o umd/scroll-into-view-if-needed.js",
2642
"build:umd.min": "BABEL_ENV=umd NODE_ENV=production rollup -c -f umd -o umd/scroll-into-view-if-needed.min.js",
2743
"clean": "rimraf 'umd' 'es' 'typings'",
28-
"precommit": "lint-staged",
2944
"dev": "concurrently 'tsc --noEmit --watch' 'tsc --noEmit -p tests/typescript --watch' 'npm run build:cjs --watch' 'npm run build:es --watch' 'npm run build:umd --watch' 'npm run build:umd.min --watch'",
3045
"lint": "eslint ./integration-examples",
46+
"precommit": "lint-staged",
3147
"prepublishOnly": "npm run build",
3248
"typecheck": "tsc --noEmit && tsc --noEmit -p tests/typescript"
3349
},
34-
"sideEffects": false,
35-
"typings": "typings/index.d.ts",
50+
"browserify": {
51+
"transform": [
52+
"loose-envify"
53+
]
54+
},
55+
"prettier": {
56+
"semi": false,
57+
"singleQuote": true,
58+
"trailingComma": "es5",
59+
"overrides": [
60+
{
61+
"files": ".babelrc",
62+
"options": {
63+
"parser": "json"
64+
}
65+
}
66+
]
67+
},
3668
"dependencies": {
3769
"compute-scroll-into-view": "^1.0.17"
3870
},
@@ -68,43 +100,11 @@
68100
"tslint-config-prettier": "1.18.0",
69101
"typescript": "4.6.4"
70102
},
71-
"keywords": [
72-
"behavior-smooth",
73-
"if-needed",
74-
"polyfill",
75-
"ponyfill",
76-
"scroll",
77-
"scroll-into-view",
78-
"scrollIntoView",
79-
"scrollIntoViewIfNeeded",
80-
"scrollMode",
81-
"smooth",
82-
"smoothscroll",
83-
"typescript"
84-
],
85-
"browserify": {
86-
"transform": [
87-
"loose-envify"
88-
]
89-
},
90103
"bundlesize": [
91104
{
92105
"path": "./umd/scroll-into-view-if-needed.min.js",
93106
"maxSize": "3.3 kB",
94107
"compression": "none"
95108
}
96-
],
97-
"prettier": {
98-
"semi": false,
99-
"singleQuote": true,
100-
"trailingComma": "es5",
101-
"overrides": [
102-
{
103-
"files": ".babelrc",
104-
"options": {
105-
"parser": "json"
106-
}
107-
}
108-
]
109-
}
109+
]
110110
}

‎renovate.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
{
2-
"extends": [
3-
"github>stipsan/renovate-presets:auto"
4-
],
2+
"extends": ["github>stipsan/renovate-presets:auto"],
53
"packageRules": [
64
{
75
"paths": ["tests/**"],

‎tests/.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@
1515
"react/react-jsx-in-scope": false,
1616
"react/display-name": false
1717
}
18-
}
18+
}

‎tests/integration/cypress/integration/block.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
describe('ScrollLogicalPosition: block', function() {
2-
before(function() {
1+
describe('ScrollLogicalPosition: block', function () {
2+
before(function () {
33
cy.visit('/block')
44
})
55

66
const simplePositions = ['start', 'center', 'end']
77
context('one scrollbox', () => {
8-
simplePositions.forEach(position => {
8+
simplePositions.forEach((position) => {
99
it(`should align to ${position} correctly`, () => {
1010
cy.get(`#${position}`).click()
1111
cy.wait(200)

‎tests/integration/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"private": true,
32
"name": "@integration-tests/core",
4-
"description": "Ensures the core functionality is correct",
53
"version": "1.0.0",
4+
"private": true,
5+
"description": "Ensures the core functionality is correct",
66
"main": "index.js",
77
"scripts": {
88
"build": "next build",

‎tests/integration/pages/block.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const tests = {
1111
start: () => (
1212
<Expect
1313
options={{ block: 'start' }}
14-
toBe={node => {
14+
toBe={(node) => {
1515
const clientRect = node.getBoundingClientRect()
1616
return clientRect.top === 0
1717
}}
@@ -28,7 +28,7 @@ const tests = {
2828
center: () => (
2929
<Expect
3030
options={{ block: 'center' }}
31-
toBe={node => {
31+
toBe={(node) => {
3232
const clientRect = node.getBoundingClientRect()
3333
return clientRect.top === Math.round(window.innerHeight / 2 - SIZE / 2)
3434
}}
@@ -45,7 +45,7 @@ const tests = {
4545
end: () => (
4646
<Expect
4747
options={{ block: 'end' }}
48-
toBe={node => {
48+
toBe={(node) => {
4949
const clientRect = node.getBoundingClientRect()
5050
return clientRect.bottom === window.innerHeight
5151
}}
@@ -71,7 +71,7 @@ export default class extends Component {
7171
return (
7272
<Fragment>
7373
<navbar className="test-switcher">
74-
{buttons.map(name => (
74+
{buttons.map((name) => (
7575
<button
7676
key={name}
7777
onClick={() => this.setState({ test: name })}

‎tests/integration/pages/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default () => (
1111
gridAutoRows: 'minmax(150px, auto)',
1212
}}
1313
>
14-
{suites.map(suite => (
14+
{suites.map((suite) => (
1515
<Link key={suite} href={`/${suite}`}>
1616
<a>{suite}</a>
1717
</Link>

‎tests/typescript/generics.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const node = document.body
55
// Ensuring that the generics support doesn't break
66
async function main() {
77
const didScroll = await scrollIntoView<Promise<boolean>>(node, {
8-
behavior: actions => {
8+
behavior: (actions) => {
99
actions.forEach(({ el, left, top }) => {
1010
el.scroll({ left, top })
1111
})

‎tests/typescript/simple.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@ scrollIntoView(node, { skipOverflowHiddenElements: true })
2929
scrollIntoView(node, { skipOverflowHiddenElements: false })
3030
scrollIntoView(node, { boundary: document.documentElement })
3131
// This test relies on deeper type information, if el is suddenly `any` it'll fail
32-
scrollIntoView(node, { boundary: el => el.classList.contains('should-scroll') })
32+
scrollIntoView(node, {
33+
boundary: (el) => el.classList.contains('should-scroll'),
34+
})
3335

3436
// Ensure the custom behavior callback option contains enough type information to be typesafe
3537
const actionsCount: number = scrollIntoView(node, {
36-
behavior: actions => {
38+
behavior: (actions) => {
3739
const scrollframes = actions.length
3840
actions.forEach(({ el, left, top }) => {
3941
el.scroll({ left, top })
Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,38 @@
1-
<!DOCTYPE HTML>
1+
<!DOCTYPE html>
22
<script src="/node_modules/scroll-into-view-if-needed/umd/scroll-into-view-if-needed.js"></script>
33
<script src="/resources/testharness.js"></script>
44
<script src="/resources/testharnessreport.js"></script>
55
<title>Check End Position of scrollIntoView of shadow elements</title>
66
<div id="container">
7-
<div id="space1" style="height: 2000px; width: 2000px;background-color: yellow">
8-
</div>
7+
<div
8+
id="space1"
9+
style="height: 2000px; width: 2000px; background-color: yellow"
10+
></div>
911
<div id="shadow"></div>
10-
<div id="space2" style="height: 2000px; width: 2000px;background-color: blue">
11-
</div>
12+
<div
13+
id="space2"
14+
style="height: 2000px; width: 2000px; background-color: blue"
15+
></div>
1216
</div>
1317
<script>
14-
add_completion_callback(() => document.getElementById("container").remove());
18+
add_completion_callback(() => document.getElementById('container').remove())
1519

16-
test(t => {
17-
var shadow = document.getElementById("shadow");
18-
var shadowRoot = shadow.attachShadow({ mode: "open" });
19-
var shadowDiv = document.createElement("div");
20-
shadowDiv.style.height = "200px";
21-
shadowDiv.style.width = "200px";
22-
shadowDiv.style.backgroundColor = "green";
23-
shadowRoot.appendChild(shadowDiv);
20+
test((t) => {
21+
var shadow = document.getElementById('shadow')
22+
var shadowRoot = shadow.attachShadow({ mode: 'open' })
23+
var shadowDiv = document.createElement('div')
24+
shadowDiv.style.height = '200px'
25+
shadowDiv.style.width = '200px'
26+
shadowDiv.style.backgroundColor = 'green'
27+
shadowRoot.appendChild(shadowDiv)
2428

25-
window.scrollTo(0, 0);
26-
var expected_x = shadowDiv.offsetLeft;
27-
var expected_y = shadowDiv.offsetTop;
28-
assert_not_equals(window.scrollX, expected_x);
29-
assert_not_equals(window.scrollY, expected_y);
30-
scrollIntoView(shadowDiv, {block: "start", inline: "start"});
31-
assert_approx_equals(window.scrollX, expected_x, 1);
32-
assert_approx_equals(window.scrollY, expected_y, 1);
33-
}, "scrollIntoView should behave correctly if applies to shadow dom elements");
34-
</script>
29+
window.scrollTo(0, 0)
30+
var expected_x = shadowDiv.offsetLeft
31+
var expected_y = shadowDiv.offsetTop
32+
assert_not_equals(window.scrollX, expected_x)
33+
assert_not_equals(window.scrollY, expected_y)
34+
scrollIntoView(shadowDiv, { block: 'start', inline: 'start' })
35+
assert_approx_equals(window.scrollX, expected_x, 1)
36+
assert_approx_equals(window.scrollY, expected_y, 1)
37+
}, 'scrollIntoView should behave correctly if applies to shadow dom elements')
38+
</script>

0 commit comments

Comments
 (0)