@player-ui/auto-scroll-manager-plugin-react 0.3.1-next.0 → 0.4.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -39,8 +39,8 @@ const AutoScrollProvider = ({
39
39
  const node = document.getElementById(getElementToScrollTo(scrollableMap));
40
40
  if (node) {
41
41
  scrollIntoView__default["default"](node, {
42
- block: "nearest",
43
- inline: "nearest"
42
+ block: "center",
43
+ inline: "center"
44
44
  });
45
45
  }
46
46
  });
@@ -67,7 +67,10 @@ class AutoScrollManagerPlugin {
67
67
  this.scrollFn = this.calculateScroll.bind(this);
68
68
  }
69
69
  getFirstScrollableElement(idList, type) {
70
- const highestElement = { id: "", ypos: 0 };
70
+ const highestElement = {
71
+ id: "",
72
+ ypos: 0
73
+ };
71
74
  const ypos = window.scrollY;
72
75
  idList.forEach((id) => {
73
76
  const element = document.getElementById(id);
@@ -116,9 +119,10 @@ class AutoScrollManagerPlugin {
116
119
  this.failedNavigation = false;
117
120
  this.alreadyScrolledTo = [];
118
121
  });
119
- flow.hooks.beforeTransition.tap(this.name, (state) => {
120
- this.failedNavigation = true;
121
- return state;
122
+ flow.hooks.skipTransition.intercept({
123
+ call: () => {
124
+ this.failedNavigation = true;
125
+ }
122
126
  });
123
127
  });
124
128
  });
package/dist/index.esm.js CHANGED
@@ -30,8 +30,8 @@ const AutoScrollProvider = ({
30
30
  const node = document.getElementById(getElementToScrollTo(scrollableMap));
31
31
  if (node) {
32
32
  scrollIntoView(node, {
33
- block: "nearest",
34
- inline: "nearest"
33
+ block: "center",
34
+ inline: "center"
35
35
  });
36
36
  }
37
37
  });
@@ -58,7 +58,10 @@ class AutoScrollManagerPlugin {
58
58
  this.scrollFn = this.calculateScroll.bind(this);
59
59
  }
60
60
  getFirstScrollableElement(idList, type) {
61
- const highestElement = { id: "", ypos: 0 };
61
+ const highestElement = {
62
+ id: "",
63
+ ypos: 0
64
+ };
62
65
  const ypos = window.scrollY;
63
66
  idList.forEach((id) => {
64
67
  const element = document.getElementById(id);
@@ -107,9 +110,10 @@ class AutoScrollManagerPlugin {
107
110
  this.failedNavigation = false;
108
111
  this.alreadyScrolledTo = [];
109
112
  });
110
- flow.hooks.beforeTransition.tap(this.name, (state) => {
111
- this.failedNavigation = true;
112
- return state;
113
+ flow.hooks.skipTransition.intercept({
114
+ call: () => {
115
+ this.failedNavigation = true;
116
+ }
113
117
  });
114
118
  });
115
119
  });
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@player-ui/auto-scroll-manager-plugin-react",
3
- "version": "0.3.1-next.0",
3
+ "version": "0.4.0-next.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org"
7
7
  },
8
8
  "peerDependencies": {
9
- "@player-ui/react": "0.3.1-next.0"
9
+ "@player-ui/react": "0.4.0-next.0"
10
10
  },
11
11
  "dependencies": {
12
12
  "smooth-scroll-into-view-if-needed": "1.1.32",
package/src/hooks.tsx CHANGED
@@ -69,8 +69,8 @@ export const AutoScrollProvider = ({
69
69
 
70
70
  if (node) {
71
71
  scrollIntoView(node, {
72
- block: 'nearest',
73
- inline: 'nearest',
72
+ block: 'center',
73
+ inline: 'center',
74
74
  });
75
75
  }
76
76
  });
package/src/plugin.tsx CHANGED
@@ -48,7 +48,10 @@ export class AutoScrollManagerPlugin implements ReactPlayerPlugin {
48
48
  }
49
49
 
50
50
  getFirstScrollableElement(idList: Set<string>, type: ScrollType) {
51
- const highestElement = { id: '', ypos: 0 };
51
+ const highestElement = {
52
+ id: '',
53
+ ypos: 0,
54
+ };
52
55
  const ypos = window.scrollY;
53
56
  idList.forEach((id) => {
54
57
  const element = document.getElementById(id);
@@ -126,12 +129,10 @@ export class AutoScrollManagerPlugin implements ReactPlayerPlugin {
126
129
  this.failedNavigation = false;
127
130
  this.alreadyScrolledTo = [];
128
131
  });
129
- flow.hooks.beforeTransition.tap(this.name, (state) => {
130
- // will get reset to false if view successfully transitions
131
- // otherwise stays as true when view get rerendered with errors
132
- this.failedNavigation = true;
133
-
134
- return state;
132
+ flow.hooks.skipTransition.intercept({
133
+ call: () => {
134
+ this.failedNavigation = true;
135
+ },
135
136
  });
136
137
  });
137
138
  });