szld-libs 0.2.41 → 0.2.42

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.
@@ -1,6 +1,6 @@
1
- import { jsx } from "react/jsx-runtime";
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import classNames from "classnames";
3
- import { useRef, useEffect } from "react";
3
+ import { useRef, useMemo, useEffect } from "react";
4
4
  const wrapper = "LoopSlide-module_wrapper_dde90";
5
5
  const container = "LoopSlide-module_container_be123";
6
6
  const scrollContent = "LoopSlide-module_scrollContent_36ed7";
@@ -26,17 +26,25 @@ const LoopSlide = ({
26
26
  const containerRef = useRef(null);
27
27
  const contentRef = useRef(null);
28
28
  const resizeObserverRef = useRef(null);
29
- useRef(false);
30
29
  const scrollVelocity = useRef(0);
31
30
  const animationFrameId = useRef();
32
31
  const lastScrollTime = useRef(0);
32
+ const extraClone = useMemo(() => {
33
+ if (!containerRef.current || !contentRef.current)
34
+ return;
35
+ const container2 = containerRef.current;
36
+ const content2 = contentRef.current;
37
+ const contentHeight = parseFloat(content2.scrollHeight.toString());
38
+ if (contentHeight * 2 - container2.clientHeight < contentHeight) {
39
+ return true;
40
+ }
41
+ return false;
42
+ }, []);
33
43
  const setupAnimation = () => {
34
44
  if (!containerRef.current || !contentRef.current)
35
45
  return;
36
46
  const container2 = containerRef.current;
37
47
  const content2 = contentRef.current;
38
- const clones = container2.querySelectorAll(`.${styles.content}:not(:first-child)`);
39
- clones.forEach((clone) => container2.removeChild(clone));
40
48
  const contentHeight = parseFloat(content2.scrollHeight.toString());
41
49
  if (contentHeight * 2 <= container2.clientHeight) {
42
50
  container2.style.animation = "none";
@@ -47,15 +55,6 @@ const LoopSlide = ({
47
55
  container2.style.animationDuration = `${speed * scale}s`;
48
56
  container2.style.animationDelay = `${delay}s`;
49
57
  container2.style.animationTimingFunction = timingFunction;
50
- const cloneContent = () => {
51
- const clone = content2.cloneNode(true);
52
- clone.className = `${styles.content}`;
53
- container2.appendChild(clone);
54
- };
55
- cloneContent();
56
- if (contentHeight * 2 - container2.clientHeight < contentHeight) {
57
- cloneContent();
58
- }
59
58
  };
60
59
  useEffect(() => {
61
60
  setupAnimation();
@@ -145,7 +144,11 @@ const LoopSlide = ({
145
144
  style: { height, ...style },
146
145
  onMouseEnter: handleMouseEnter,
147
146
  onMouseLeave: handleMouseLeave,
148
- children: /* @__PURE__ */ jsx("div", { ref: containerRef, className: classNames(styles.container, classes == null ? void 0 : classes.container), children: /* @__PURE__ */ jsx("div", { ref: contentRef, className: classNames(styles.content, classes == null ? void 0 : classes.content), children }) })
147
+ children: /* @__PURE__ */ jsxs("div", { ref: containerRef, className: classNames(styles.container, classes == null ? void 0 : classes.container), children: [
148
+ /* @__PURE__ */ jsx("div", { ref: contentRef, className: classNames(styles.content, classes == null ? void 0 : classes.content), children }),
149
+ /* @__PURE__ */ jsx("div", { className: classNames(styles.content, classes == null ? void 0 : classes.content), children }),
150
+ extraClone && /* @__PURE__ */ jsx("div", { className: classNames(styles.content, classes == null ? void 0 : classes.content), children })
151
+ ] })
149
152
  }
150
153
  );
151
154
  };
package/es/index.js CHANGED
@@ -62,7 +62,14 @@ const Demo = () => {
62
62
  margin: "20px"
63
63
  },
64
64
  children: /* @__PURE__ */ jsx(LoopSlide, { speed: 6, height: "100%", mouseControl: true, children: /* @__PURE__ */ jsx("div", { style: { padding: "0px", textAlign: "center" }, children: creditsData.map((section, i) => /* @__PURE__ */ jsxs("div", { children: [
65
- /* @__PURE__ */ jsx("h2", { style: { fontSize: "40px", marginBottom: "20px", fontWeight: "normal" }, children: section.title }),
65
+ /* @__PURE__ */ jsx(
66
+ "h2",
67
+ {
68
+ onClick: () => void 0,
69
+ style: { fontSize: "40px", marginBottom: "20px", fontWeight: "normal" },
70
+ children: section.title
71
+ }
72
+ ),
66
73
  section.people.map((person, j) => /* @__PURE__ */ jsxs("div", { children: [
67
74
  /* @__PURE__ */ jsx("p", { style: { fontSize: "15px", margin: "5px 0" }, children: person.name }),
68
75
  person.role && /* @__PURE__ */ jsx("p", { style: { fontSize: "12px", color: "#aaa", marginBottom: "15px" }, children: person.role })
@@ -27,17 +27,25 @@ const LoopSlide = ({
27
27
  const containerRef = react.useRef(null);
28
28
  const contentRef = react.useRef(null);
29
29
  const resizeObserverRef = react.useRef(null);
30
- react.useRef(false);
31
30
  const scrollVelocity = react.useRef(0);
32
31
  const animationFrameId = react.useRef();
33
32
  const lastScrollTime = react.useRef(0);
33
+ const extraClone = react.useMemo(() => {
34
+ if (!containerRef.current || !contentRef.current)
35
+ return;
36
+ const container2 = containerRef.current;
37
+ const content2 = contentRef.current;
38
+ const contentHeight = parseFloat(content2.scrollHeight.toString());
39
+ if (contentHeight * 2 - container2.clientHeight < contentHeight) {
40
+ return true;
41
+ }
42
+ return false;
43
+ }, []);
34
44
  const setupAnimation = () => {
35
45
  if (!containerRef.current || !contentRef.current)
36
46
  return;
37
47
  const container2 = containerRef.current;
38
48
  const content2 = contentRef.current;
39
- const clones = container2.querySelectorAll(`.${styles.content}:not(:first-child)`);
40
- clones.forEach((clone) => container2.removeChild(clone));
41
49
  const contentHeight = parseFloat(content2.scrollHeight.toString());
42
50
  if (contentHeight * 2 <= container2.clientHeight) {
43
51
  container2.style.animation = "none";
@@ -48,15 +56,6 @@ const LoopSlide = ({
48
56
  container2.style.animationDuration = `${speed * scale}s`;
49
57
  container2.style.animationDelay = `${delay}s`;
50
58
  container2.style.animationTimingFunction = timingFunction;
51
- const cloneContent = () => {
52
- const clone = content2.cloneNode(true);
53
- clone.className = `${styles.content}`;
54
- container2.appendChild(clone);
55
- };
56
- cloneContent();
57
- if (contentHeight * 2 - container2.clientHeight < contentHeight) {
58
- cloneContent();
59
- }
60
59
  };
61
60
  react.useEffect(() => {
62
61
  setupAnimation();
@@ -146,7 +145,11 @@ const LoopSlide = ({
146
145
  style: { height, ...style },
147
146
  onMouseEnter: handleMouseEnter,
148
147
  onMouseLeave: handleMouseLeave,
149
- children: /* @__PURE__ */ jsxRuntime.jsx("div", { ref: containerRef, className: classNames(styles.container, classes == null ? void 0 : classes.container), children: /* @__PURE__ */ jsxRuntime.jsx("div", { ref: contentRef, className: classNames(styles.content, classes == null ? void 0 : classes.content), children }) })
148
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: containerRef, className: classNames(styles.container, classes == null ? void 0 : classes.container), children: [
149
+ /* @__PURE__ */ jsxRuntime.jsx("div", { ref: contentRef, className: classNames(styles.content, classes == null ? void 0 : classes.content), children }),
150
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: classNames(styles.content, classes == null ? void 0 : classes.content), children }),
151
+ extraClone && /* @__PURE__ */ jsxRuntime.jsx("div", { className: classNames(styles.content, classes == null ? void 0 : classes.content), children })
152
+ ] })
150
153
  }
151
154
  );
152
155
  };
package/lib/index.js CHANGED
@@ -63,7 +63,14 @@ const Demo = () => {
63
63
  margin: "20px"
64
64
  },
65
65
  children: /* @__PURE__ */ jsxRuntime.jsx(main.LoopSlide, { speed: 6, height: "100%", mouseControl: true, children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: { padding: "0px", textAlign: "center" }, children: creditsData.map((section, i) => /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
66
- /* @__PURE__ */ jsxRuntime.jsx("h2", { style: { fontSize: "40px", marginBottom: "20px", fontWeight: "normal" }, children: section.title }),
66
+ /* @__PURE__ */ jsxRuntime.jsx(
67
+ "h2",
68
+ {
69
+ onClick: () => void 0,
70
+ style: { fontSize: "40px", marginBottom: "20px", fontWeight: "normal" },
71
+ children: section.title
72
+ }
73
+ ),
67
74
  section.people.map((person, j) => /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
68
75
  /* @__PURE__ */ jsxRuntime.jsx("p", { style: { fontSize: "15px", margin: "5px 0" }, children: person.name }),
69
76
  person.role && /* @__PURE__ */ jsxRuntime.jsx("p", { style: { fontSize: "12px", color: "#aaa", marginBottom: "15px" }, children: person.role })
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "szld-libs",
3
3
  "private": false,
4
- "version": "0.2.41",
4
+ "version": "0.2.42",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "vite",