@player-ui/auto-scroll-manager-plugin-react 0.4.0-next.5 → 0.4.0-next.7

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
@@ -84,9 +84,9 @@ class AutoScrollManagerPlugin {
84
84
  this.alreadyScrolledTo.push(id);
85
85
  }
86
86
  const epos = element == null ? void 0 : element.getBoundingClientRect().top;
87
- if (epos && (epos + ypos > highestElement.ypos || highestElement.ypos === 0)) {
87
+ if (epos !== void 0 && (epos + ypos < highestElement.ypos || highestElement.id === "")) {
88
88
  highestElement.id = id;
89
- highestElement.ypos = ypos - epos;
89
+ highestElement.ypos = ypos + epos;
90
90
  }
91
91
  });
92
92
  return highestElement.id;
package/dist/index.esm.js CHANGED
@@ -75,9 +75,9 @@ class AutoScrollManagerPlugin {
75
75
  this.alreadyScrolledTo.push(id);
76
76
  }
77
77
  const epos = element == null ? void 0 : element.getBoundingClientRect().top;
78
- if (epos && (epos + ypos > highestElement.ypos || highestElement.ypos === 0)) {
78
+ if (epos !== void 0 && (epos + ypos < highestElement.ypos || highestElement.id === "")) {
79
79
  highestElement.id = id;
80
- highestElement.ypos = ypos - epos;
80
+ highestElement.ypos = ypos + epos;
81
81
  }
82
82
  });
83
83
  return highestElement.id;
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@player-ui/auto-scroll-manager-plugin-react",
3
- "version": "0.4.0-next.5",
3
+ "version": "0.4.0-next.7",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org"
7
7
  },
8
8
  "peerDependencies": {
9
- "@player-ui/react": "0.4.0-next.5"
9
+ "@player-ui/react": "0.4.0-next.7"
10
10
  },
11
11
  "dependencies": {
12
12
  "smooth-scroll-into-view-if-needed": "1.1.32",
package/src/plugin.tsx CHANGED
@@ -75,22 +75,19 @@ export class AutoScrollManagerPlugin implements ReactPlayerPlugin {
75
75
  }
76
76
 
77
77
  const epos = element?.getBoundingClientRect().top;
78
-
79
78
  if (
80
- epos &&
81
- (epos + ypos > highestElement.ypos || highestElement.ypos === 0)
79
+ epos !== undefined &&
80
+ (epos + ypos < highestElement.ypos || highestElement.id === '')
82
81
  ) {
83
82
  highestElement.id = id;
84
- highestElement.ypos = ypos - epos;
83
+ highestElement.ypos = ypos + epos;
85
84
  }
86
85
  });
87
-
88
86
  return highestElement.id;
89
87
  }
90
88
 
91
89
  calculateScroll(scrollableElements: Map<ScrollType, Set<string>>) {
92
90
  let currentScroll = ScrollType.FirstAppearance;
93
-
94
91
  if (this.initialRender) {
95
92
  if (this.autoScrollOnLoad) {
96
93
  currentScroll = ScrollType.ValidationError;
@@ -106,13 +103,11 @@ export class AutoScrollManagerPlugin implements ReactPlayerPlugin {
106
103
  }
107
104
 
108
105
  const elementList = scrollableElements.get(currentScroll);
109
-
110
106
  if (elementList) {
111
107
  const element = this.getFirstScrollableElement(
112
108
  elementList,
113
109
  currentScroll
114
110
  );
115
-
116
111
  return element ?? '';
117
112
  }
118
113
 
@@ -142,7 +137,6 @@ export class AutoScrollManagerPlugin implements ReactPlayerPlugin {
142
137
  reactPlayer.hooks.webComponent.tap(this.name, (Comp) => {
143
138
  return () => {
144
139
  const { scrollFn } = this;
145
-
146
140
  return (
147
141
  <AutoScrollProvider getElementToScrollTo={scrollFn}>
148
142
  <Comp />