scroll-slides 0.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 agoudbg
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,2 @@
1
+ # scroll-slides
2
+
@@ -0,0 +1,155 @@
1
+ declare const sliderRef: import("vue").Ref<HTMLElement | null, HTMLElement | null>;
2
+ declare const itemStates: {
3
+ [key: number]: {
4
+ scale: number;
5
+ translate: number;
6
+ opacity: number;
7
+ };
8
+ };
9
+ declare const isVertical: import("vue").ComputedRef<boolean>;
10
+ declare const transformProperty: import("vue").ComputedRef<"translateY" | "translateX">;
11
+ declare const itemIndices: import("vue").ComputedRef<number[]>;
12
+ declare const __VLS_ctx: InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>;
13
+ declare var __VLS_2: `item-${number}`, __VLS_3: {
14
+ index: number;
15
+ }, __VLS_5: {
16
+ index: number;
17
+ };
18
+ type __VLS_Slots = __VLS_PrettifyGlobal<__VLS_OmitStringIndex<typeof __VLS_ctx.$slots> & {
19
+ [K in NonNullable<typeof __VLS_2>]?: (props: typeof __VLS_3) => any;
20
+ } & {
21
+ item?: (props: typeof __VLS_5) => any;
22
+ }>;
23
+ declare const __VLS_self: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
24
+ direction: {
25
+ type: StringConstructor;
26
+ default: string;
27
+ validator: (value: string) => boolean;
28
+ };
29
+ itemGap: {
30
+ type: NumberConstructor;
31
+ default: number;
32
+ };
33
+ itemCount: {
34
+ type: NumberConstructor;
35
+ default: number;
36
+ };
37
+ scaleRatio: {
38
+ type: NumberConstructor;
39
+ default: number;
40
+ };
41
+ scaleStartPercent: {
42
+ type: NumberConstructor;
43
+ default: number;
44
+ };
45
+ translateFactor: {
46
+ type: NumberConstructor;
47
+ default: number;
48
+ };
49
+ }>, {
50
+ sliderRef: typeof sliderRef;
51
+ itemStates: typeof itemStates;
52
+ isVertical: typeof isVertical;
53
+ transformProperty: typeof transformProperty;
54
+ itemIndices: typeof itemIndices;
55
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
56
+ direction: {
57
+ type: StringConstructor;
58
+ default: string;
59
+ validator: (value: string) => boolean;
60
+ };
61
+ itemGap: {
62
+ type: NumberConstructor;
63
+ default: number;
64
+ };
65
+ itemCount: {
66
+ type: NumberConstructor;
67
+ default: number;
68
+ };
69
+ scaleRatio: {
70
+ type: NumberConstructor;
71
+ default: number;
72
+ };
73
+ scaleStartPercent: {
74
+ type: NumberConstructor;
75
+ default: number;
76
+ };
77
+ translateFactor: {
78
+ type: NumberConstructor;
79
+ default: number;
80
+ };
81
+ }>> & Readonly<{}>, {
82
+ direction: string;
83
+ itemGap: number;
84
+ itemCount: number;
85
+ scaleRatio: number;
86
+ scaleStartPercent: number;
87
+ translateFactor: number;
88
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
89
+ declare const __VLS_component: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
90
+ direction: {
91
+ type: StringConstructor;
92
+ default: string;
93
+ validator: (value: string) => boolean;
94
+ };
95
+ itemGap: {
96
+ type: NumberConstructor;
97
+ default: number;
98
+ };
99
+ itemCount: {
100
+ type: NumberConstructor;
101
+ default: number;
102
+ };
103
+ scaleRatio: {
104
+ type: NumberConstructor;
105
+ default: number;
106
+ };
107
+ scaleStartPercent: {
108
+ type: NumberConstructor;
109
+ default: number;
110
+ };
111
+ translateFactor: {
112
+ type: NumberConstructor;
113
+ default: number;
114
+ };
115
+ }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
116
+ direction: {
117
+ type: StringConstructor;
118
+ default: string;
119
+ validator: (value: string) => boolean;
120
+ };
121
+ itemGap: {
122
+ type: NumberConstructor;
123
+ default: number;
124
+ };
125
+ itemCount: {
126
+ type: NumberConstructor;
127
+ default: number;
128
+ };
129
+ scaleRatio: {
130
+ type: NumberConstructor;
131
+ default: number;
132
+ };
133
+ scaleStartPercent: {
134
+ type: NumberConstructor;
135
+ default: number;
136
+ };
137
+ translateFactor: {
138
+ type: NumberConstructor;
139
+ default: number;
140
+ };
141
+ }>> & Readonly<{}>, {
142
+ direction: string;
143
+ itemGap: number;
144
+ itemCount: number;
145
+ scaleRatio: number;
146
+ scaleStartPercent: number;
147
+ translateFactor: number;
148
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
149
+ declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
150
+ export default _default;
151
+ type __VLS_WithSlots<T, S> = T & {
152
+ new (): {
153
+ $slots: S;
154
+ };
155
+ };
@@ -0,0 +1,2 @@
1
+ import ScrollSlide from './components/ScrollSlide.vue';
2
+ export { ScrollSlide };
@@ -0,0 +1 @@
1
+ .slider[data-v-11b44448]{position:relative;width:100%;height:100%;overflow-y:auto;overflow-x:hidden;padding:20px;box-sizing:border-box}.slider.horizontal[data-v-11b44448]{overflow-x:auto;overflow-y:hidden;white-space:nowrap}.slider-item[data-v-11b44448]{position:relative;background-color:#fff0;padding:0}.slider-item .slider-slot[data-v-11b44448]{display:flex;justify-content:center;align-items:center;box-shadow:0 2px 10px #0000001a;backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);border-radius:12px;transition:transform .04s}.horizontal .slider-item[data-v-11b44448]{display:inline-block;vertical-align:middle;transform-origin:center right}
@@ -0,0 +1,97 @@
1
+ import { defineComponent as w, ref as R, reactive as L, computed as y, onMounted as A, createElementBlock as h, openBlock as g, normalizeClass as F, Fragment as G, renderList as I, normalizeStyle as _, createElementVNode as V, renderSlot as $ } from "vue";
2
+ const q = /* @__PURE__ */ w({
3
+ __name: "ScrollSlide",
4
+ props: {
5
+ direction: {
6
+ type: String,
7
+ default: "vertical",
8
+ // 'vertical' or 'horizontal'
9
+ validator: (l) => ["vertical", "horizontal"].includes(l)
10
+ },
11
+ itemGap: {
12
+ type: Number,
13
+ default: 20
14
+ },
15
+ itemCount: {
16
+ type: Number,
17
+ default: 0
18
+ },
19
+ scaleRatio: {
20
+ type: Number,
21
+ default: 0.7
22
+ },
23
+ scaleStartPercent: {
24
+ type: Number,
25
+ default: 0.8
26
+ },
27
+ translateFactor: {
28
+ type: Number,
29
+ default: 100
30
+ }
31
+ },
32
+ setup(l) {
33
+ const n = l, t = R(null), c = R([]), o = L({}), s = y(() => n.direction === "vertical"), b = y(() => s.value ? "translateY" : "translateX"), z = (e, r) => Math.min(Math.max(e / r, 0), 1), E = (e) => e * e * (3 - 2 * e), S = y(() => Array.from({ length: n.itemCount }, (e, r) => r)), u = () => {
34
+ if (!t.value) return;
35
+ const e = t.value, r = e[s.value ? "clientHeight" : "clientWidth"];
36
+ c.value.forEach((a, m) => {
37
+ const i = a.getBoundingClientRect(), v = s.value ? i.top : i.left, P = e.getBoundingClientRect(), M = v - (s.value ? P.top : P.left), C = Math.min(
38
+ Math.max(0, (r - M) / r),
39
+ 1
40
+ ), N = z(1 - C - n.scaleStartPercent, 1 - n.scaleStartPercent), f = E(N), k = 1 + (n.scaleRatio - 1) * f, B = f * n.translateFactor;
41
+ let d;
42
+ const p = Math.min(Math.max(f || 0, 0), 1);
43
+ p > 0.6 ? d = 0 : p < 0.4 ? d = 1 : d = (0.6 - p) / 0.2, o[m] = {
44
+ scale: k,
45
+ translate: B,
46
+ opacity: d
47
+ };
48
+ });
49
+ };
50
+ return A(() => {
51
+ t.value && (c.value = Array.from(t.value.querySelectorAll(".slider-item")), c.value.forEach((e, r) => {
52
+ o[r] = {
53
+ scale: 1,
54
+ translate: 0,
55
+ opacity: 1
56
+ };
57
+ }), t.value.addEventListener("scroll", u), window.addEventListener("resize", u), t.value.addEventListener("touchmove", u, { passive: !0 }), u());
58
+ }), (e, r) => (g(), h("div", {
59
+ class: F(["slider", { horizontal: !s.value }]),
60
+ ref_key: "sliderRef",
61
+ ref: t
62
+ }, [
63
+ (g(!0), h(G, null, I(S.value, (a) => {
64
+ var m, i, v;
65
+ return g(), h("div", {
66
+ key: a,
67
+ class: "slider-item",
68
+ style: _({
69
+ marginBottom: s.value ? `${l.itemGap}px` : "0",
70
+ marginRight: s.value ? "0" : `${l.itemGap}px`,
71
+ zIndex: S.value.length - a
72
+ })
73
+ }, [
74
+ V("div", {
75
+ class: "slider-slot",
76
+ style: _({
77
+ transform: `${b.value}(${-((m = o[a]) == null ? void 0 : m.translate) || 0}%) scale(${((i = o[a]) == null ? void 0 : i.scale) || 1})`,
78
+ opacity: (v = o[a]) == null ? void 0 : v.opacity
79
+ })
80
+ }, [
81
+ $(e.$slots, `item-${a}`, { index: a }, () => [
82
+ $(e.$slots, "item", { index: a }, void 0, !0)
83
+ ], !0)
84
+ ], 4)
85
+ ], 4);
86
+ }), 128))
87
+ ], 2));
88
+ }
89
+ }), H = (l, n) => {
90
+ const t = l.__vccOpts || l;
91
+ for (const [c, o] of n)
92
+ t[c] = o;
93
+ return t;
94
+ }, T = /* @__PURE__ */ H(q, [["__scopeId", "data-v-11b44448"]]);
95
+ export {
96
+ T as ScrollSlide
97
+ };
@@ -0,0 +1 @@
1
+ (function(c,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(c=typeof globalThis<"u"?globalThis:c||self,e(c.ScrollSlide={},c.Vue))})(this,function(c,e){"use strict";const _=((n,o)=>{const r=n.__vccOpts||n;for(const[m,s]of o)r[m]=s;return r})(e.defineComponent({__name:"ScrollSlide",props:{direction:{type:String,default:"vertical",validator:n=>["vertical","horizontal"].includes(n)},itemGap:{type:Number,default:20},itemCount:{type:Number,default:0},scaleRatio:{type:Number,default:.7},scaleStartPercent:{type:Number,default:.8},translateFactor:{type:Number,default:100}},setup(n){const o=n,r=e.ref(null),m=e.ref([]),s=e.reactive({}),i=e.computed(()=>o.direction==="vertical"),P=e.computed(()=>i.value?"translateY":"translateX"),R=(t,l)=>Math.min(Math.max(t/l,0),1),b=t=>t*t*(3-2*t),v=e.computed(()=>Array.from({length:o.itemCount},(t,l)=>l)),u=()=>{if(!r.value)return;const t=r.value,l=t[i.value?"clientHeight":"clientWidth"];m.value.forEach((a,f)=>{const d=a.getBoundingClientRect(),p=i.value?d.top:d.left,g=t.getBoundingClientRect(),k=p-(i.value?g.top:g.left),B=Math.min(Math.max(0,(l-k)/l),1),E=R(1-B-o.scaleStartPercent,1-o.scaleStartPercent),S=b(E),z=1+(o.scaleRatio-1)*S,M=S*o.translateFactor;let y;const h=Math.min(Math.max(S||0,0),1);h>.6?y=0:h<.4?y=1:y=(.6-h)/.2,s[f]={scale:z,translate:M,opacity:y}})};return e.onMounted(()=>{r.value&&(m.value=Array.from(r.value.querySelectorAll(".slider-item")),m.value.forEach((t,l)=>{s[l]={scale:1,translate:0,opacity:1}}),r.value.addEventListener("scroll",u),window.addEventListener("resize",u),r.value.addEventListener("touchmove",u,{passive:!0}),u())}),(t,l)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["slider",{horizontal:!i.value}]),ref_key:"sliderRef",ref:r},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(v.value,a=>{var f,d,p;return e.openBlock(),e.createElementBlock("div",{key:a,class:"slider-item",style:e.normalizeStyle({marginBottom:i.value?`${n.itemGap}px`:"0",marginRight:i.value?"0":`${n.itemGap}px`,zIndex:v.value.length-a})},[e.createElementVNode("div",{class:"slider-slot",style:e.normalizeStyle({transform:`${P.value}(${-((f=s[a])==null?void 0:f.translate)||0}%) scale(${((d=s[a])==null?void 0:d.scale)||1})`,opacity:(p=s[a])==null?void 0:p.opacity})},[e.renderSlot(t.$slots,`item-${a}`,{index:a},()=>[e.renderSlot(t.$slots,"item",{index:a},void 0,!0)],!0)],4)],4)}),128))],2))}}),[["__scopeId","data-v-11b44448"]]);c.ScrollSlide=_,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "scroll-slides",
3
+ "version": "0.0.0",
4
+ "type": "module",
5
+ "types": "./dist/index.d.ts",
6
+ "files": [
7
+ "dist"
8
+ ],
9
+ "main": "./dist/scroll-slides.umd.cjs",
10
+ "module": "./dist/scroll-slides.js",
11
+ "scripts": {
12
+ "dev": "vite",
13
+ "build": "vite build && vue-tsc --emitDeclarationOnly --project tsconfig.app.json",
14
+ "types": "vue-tsc --declaration --emitDeclarationOnly --project tsconfig.app.json",
15
+ "preview": "vite preview"
16
+ },
17
+ "dependencies": {
18
+ "vue": "^3.5.13"
19
+ },
20
+ "devDependencies": {
21
+ "@types/node": "^22.14.0",
22
+ "@vitejs/plugin-vue": "^5.2.1",
23
+ "@vue/tsconfig": "^0.7.0",
24
+ "typescript": "~5.7.2",
25
+ "vite": "^6.2.0",
26
+ "vue-tsc": "^2.2.4"
27
+ }
28
+ }