scroll-slides 0.0.0 → 0.1.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/components/ScrollSlide.vue.d.ts +38 -18
- package/dist/scroll-slides.css +1 -1
- package/dist/scroll-slides.js +81 -48
- package/dist/scroll-slides.umd.cjs +1 -1
- package/dist/vite.svg +1 -0
- package/package.json +1 -1
|
@@ -9,6 +9,7 @@ declare const itemStates: {
|
|
|
9
9
|
declare const isVertical: import("vue").ComputedRef<boolean>;
|
|
10
10
|
declare const transformProperty: import("vue").ComputedRef<"translateY" | "translateX">;
|
|
11
11
|
declare const itemIndices: import("vue").ComputedRef<number[]>;
|
|
12
|
+
declare const spacerSize: import("vue").ComputedRef<number>;
|
|
12
13
|
declare const __VLS_ctx: InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>;
|
|
13
14
|
declare var __VLS_2: `item-${number}`, __VLS_3: {
|
|
14
15
|
index: number;
|
|
@@ -26,10 +27,6 @@ declare const __VLS_self: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
26
27
|
default: string;
|
|
27
28
|
validator: (value: string) => boolean;
|
|
28
29
|
};
|
|
29
|
-
itemGap: {
|
|
30
|
-
type: NumberConstructor;
|
|
31
|
-
default: number;
|
|
32
|
-
};
|
|
33
30
|
itemCount: {
|
|
34
31
|
type: NumberConstructor;
|
|
35
32
|
default: number;
|
|
@@ -46,22 +43,27 @@ declare const __VLS_self: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
46
43
|
type: NumberConstructor;
|
|
47
44
|
default: number;
|
|
48
45
|
};
|
|
46
|
+
allowScrollToFirst: {
|
|
47
|
+
type: BooleanConstructor;
|
|
48
|
+
default: boolean;
|
|
49
|
+
};
|
|
50
|
+
spacerEnabled: {
|
|
51
|
+
type: BooleanConstructor;
|
|
52
|
+
default: boolean;
|
|
53
|
+
};
|
|
49
54
|
}>, {
|
|
50
55
|
sliderRef: typeof sliderRef;
|
|
51
56
|
itemStates: typeof itemStates;
|
|
52
57
|
isVertical: typeof isVertical;
|
|
53
58
|
transformProperty: typeof transformProperty;
|
|
54
59
|
itemIndices: typeof itemIndices;
|
|
60
|
+
spacerSize: typeof spacerSize;
|
|
55
61
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
56
62
|
direction: {
|
|
57
63
|
type: StringConstructor;
|
|
58
64
|
default: string;
|
|
59
65
|
validator: (value: string) => boolean;
|
|
60
66
|
};
|
|
61
|
-
itemGap: {
|
|
62
|
-
type: NumberConstructor;
|
|
63
|
-
default: number;
|
|
64
|
-
};
|
|
65
67
|
itemCount: {
|
|
66
68
|
type: NumberConstructor;
|
|
67
69
|
default: number;
|
|
@@ -78,13 +80,22 @@ declare const __VLS_self: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
78
80
|
type: NumberConstructor;
|
|
79
81
|
default: number;
|
|
80
82
|
};
|
|
83
|
+
allowScrollToFirst: {
|
|
84
|
+
type: BooleanConstructor;
|
|
85
|
+
default: boolean;
|
|
86
|
+
};
|
|
87
|
+
spacerEnabled: {
|
|
88
|
+
type: BooleanConstructor;
|
|
89
|
+
default: boolean;
|
|
90
|
+
};
|
|
81
91
|
}>> & Readonly<{}>, {
|
|
82
92
|
direction: string;
|
|
83
|
-
itemGap: number;
|
|
84
93
|
itemCount: number;
|
|
85
94
|
scaleRatio: number;
|
|
86
95
|
scaleStartPercent: number;
|
|
87
96
|
translateFactor: number;
|
|
97
|
+
allowScrollToFirst: boolean;
|
|
98
|
+
spacerEnabled: boolean;
|
|
88
99
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
89
100
|
declare const __VLS_component: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
90
101
|
direction: {
|
|
@@ -92,10 +103,6 @@ declare const __VLS_component: import("vue").DefineComponent<import("vue").Extra
|
|
|
92
103
|
default: string;
|
|
93
104
|
validator: (value: string) => boolean;
|
|
94
105
|
};
|
|
95
|
-
itemGap: {
|
|
96
|
-
type: NumberConstructor;
|
|
97
|
-
default: number;
|
|
98
|
-
};
|
|
99
106
|
itemCount: {
|
|
100
107
|
type: NumberConstructor;
|
|
101
108
|
default: number;
|
|
@@ -112,16 +119,20 @@ declare const __VLS_component: import("vue").DefineComponent<import("vue").Extra
|
|
|
112
119
|
type: NumberConstructor;
|
|
113
120
|
default: number;
|
|
114
121
|
};
|
|
122
|
+
allowScrollToFirst: {
|
|
123
|
+
type: BooleanConstructor;
|
|
124
|
+
default: boolean;
|
|
125
|
+
};
|
|
126
|
+
spacerEnabled: {
|
|
127
|
+
type: BooleanConstructor;
|
|
128
|
+
default: boolean;
|
|
129
|
+
};
|
|
115
130
|
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
116
131
|
direction: {
|
|
117
132
|
type: StringConstructor;
|
|
118
133
|
default: string;
|
|
119
134
|
validator: (value: string) => boolean;
|
|
120
135
|
};
|
|
121
|
-
itemGap: {
|
|
122
|
-
type: NumberConstructor;
|
|
123
|
-
default: number;
|
|
124
|
-
};
|
|
125
136
|
itemCount: {
|
|
126
137
|
type: NumberConstructor;
|
|
127
138
|
default: number;
|
|
@@ -138,13 +149,22 @@ declare const __VLS_component: import("vue").DefineComponent<import("vue").Extra
|
|
|
138
149
|
type: NumberConstructor;
|
|
139
150
|
default: number;
|
|
140
151
|
};
|
|
152
|
+
allowScrollToFirst: {
|
|
153
|
+
type: BooleanConstructor;
|
|
154
|
+
default: boolean;
|
|
155
|
+
};
|
|
156
|
+
spacerEnabled: {
|
|
157
|
+
type: BooleanConstructor;
|
|
158
|
+
default: boolean;
|
|
159
|
+
};
|
|
141
160
|
}>> & Readonly<{}>, {
|
|
142
161
|
direction: string;
|
|
143
|
-
itemGap: number;
|
|
144
162
|
itemCount: number;
|
|
145
163
|
scaleRatio: number;
|
|
146
164
|
scaleStartPercent: number;
|
|
147
165
|
translateFactor: number;
|
|
166
|
+
allowScrollToFirst: boolean;
|
|
167
|
+
spacerEnabled: boolean;
|
|
148
168
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
149
169
|
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
150
170
|
export default _default;
|
package/dist/scroll-slides.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.slider[data-v-
|
|
1
|
+
.slider[data-v-55bb67bd]{position:relative;width:100%;height:100%;overflow-y:auto;overflow-x:hidden;box-sizing:border-box}.slider.horizontal[data-v-55bb67bd]{overflow-x:auto;overflow-y:hidden;white-space:nowrap}.slider-item[data-v-55bb67bd]{position:relative}.slider-item .slider-slot[data-v-55bb67bd]{position:relative;transition:transform .04s}.horizontal .slider-item[data-v-55bb67bd]{display:inline-block;vertical-align:middle;transform-origin:center right}.slider-spacer[data-v-55bb67bd]{pointer-events:none}
|
package/dist/scroll-slides.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
const q = /* @__PURE__ */
|
|
1
|
+
import { defineComponent as I, ref as C, reactive as F, computed as p, watch as x, onMounted as A, onUnmounted as H, createElementBlock as h, openBlock as y, normalizeClass as T, createCommentVNode as V, normalizeStyle as E, Fragment as W, renderList as O, createElementVNode as j, renderSlot as _ } from "vue";
|
|
2
|
+
const q = /* @__PURE__ */ I({
|
|
3
3
|
__name: "ScrollSlide",
|
|
4
4
|
props: {
|
|
5
5
|
direction: {
|
|
6
6
|
type: String,
|
|
7
7
|
default: "vertical",
|
|
8
8
|
// 'vertical' or 'horizontal'
|
|
9
|
-
validator: (
|
|
10
|
-
},
|
|
11
|
-
itemGap: {
|
|
12
|
-
type: Number,
|
|
13
|
-
default: 20
|
|
9
|
+
validator: (s) => ["vertical", "horizontal"].includes(s)
|
|
14
10
|
},
|
|
15
11
|
itemCount: {
|
|
16
12
|
type: Number,
|
|
@@ -27,71 +23,108 @@ const q = /* @__PURE__ */ w({
|
|
|
27
23
|
translateFactor: {
|
|
28
24
|
type: Number,
|
|
29
25
|
default: 100
|
|
26
|
+
},
|
|
27
|
+
allowScrollToFirst: {
|
|
28
|
+
type: Boolean,
|
|
29
|
+
default: !1
|
|
30
|
+
},
|
|
31
|
+
// Updating prop name to be clearer
|
|
32
|
+
spacerEnabled: {
|
|
33
|
+
type: Boolean,
|
|
34
|
+
default: !1
|
|
30
35
|
}
|
|
31
36
|
},
|
|
32
|
-
setup(
|
|
33
|
-
const
|
|
37
|
+
setup(s) {
|
|
38
|
+
const r = s, t = C(null), u = C([]), n = F({}), o = p(() => r.direction === "vertical"), P = p(() => o.value ? "translateY" : "translateX"), R = (e, a) => Math.min(Math.max(e / a, 0), 1), $ = (e) => e * e * (3 - 2 * e), g = p(() => Array.from({ length: r.itemCount }, (e, a) => a)), i = () => {
|
|
34
39
|
if (!t.value) return;
|
|
35
|
-
const e = t.value,
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
Math.max(0, (
|
|
40
|
+
const e = t.value, a = e[o.value ? "clientHeight" : "clientWidth"];
|
|
41
|
+
u.value.forEach((l, c) => {
|
|
42
|
+
const v = l.getBoundingClientRect(), d = o.value ? v.top : v.left, z = e.getBoundingClientRect(), k = d - (o.value ? z.top : z.left), M = Math.min(
|
|
43
|
+
Math.max(0, (a - k) / a),
|
|
39
44
|
1
|
|
40
|
-
),
|
|
41
|
-
let
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
scale:
|
|
45
|
-
translate:
|
|
46
|
-
opacity:
|
|
45
|
+
), B = R(1 - M - r.scaleStartPercent, 1 - r.scaleStartPercent), S = $(B), L = 1 + (r.scaleRatio - 1) * S, N = S * r.translateFactor;
|
|
46
|
+
let f;
|
|
47
|
+
const b = Math.min(Math.max(S || 0, 0), 1);
|
|
48
|
+
b > 0.6 ? f = 0 : b < 0.4 ? f = 1 : f = (0.6 - b) / 0.2, n[c] = {
|
|
49
|
+
scale: L,
|
|
50
|
+
translate: N,
|
|
51
|
+
opacity: f
|
|
47
52
|
};
|
|
48
53
|
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
o[r] = {
|
|
54
|
+
}, w = () => {
|
|
55
|
+
t.value && (u.value = Array.from(t.value.querySelectorAll(".slider-item")), g.value.forEach((e) => {
|
|
56
|
+
n[e] || (n[e] = {
|
|
53
57
|
scale: 1,
|
|
54
58
|
translate: 0,
|
|
55
59
|
opacity: 1
|
|
56
|
-
};
|
|
57
|
-
}),
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
});
|
|
61
|
+
}), Object.keys(n).forEach((e) => {
|
|
62
|
+
const a = Number(e);
|
|
63
|
+
a >= r.itemCount && delete n[a];
|
|
64
|
+
}), i());
|
|
65
|
+
};
|
|
66
|
+
x(() => r.itemCount, (e, a) => {
|
|
67
|
+
setTimeout(() => {
|
|
68
|
+
w();
|
|
69
|
+
}, 0);
|
|
70
|
+
}, { immediate: !1 });
|
|
71
|
+
const m = p(() => {
|
|
72
|
+
if (!t.value) return 0;
|
|
73
|
+
const e = t.value[o.value ? "clientHeight" : "clientWidth"];
|
|
74
|
+
let a = 0;
|
|
75
|
+
if (u.value.length > 0) {
|
|
76
|
+
const l = u.value[0];
|
|
77
|
+
if (l) {
|
|
78
|
+
const c = l.getBoundingClientRect();
|
|
79
|
+
a = o.value ? c.height : c.width;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return Math.max(0, e - a);
|
|
83
|
+
});
|
|
84
|
+
return A(() => {
|
|
85
|
+
t.value && (t.value.addEventListener("scroll", i), window.addEventListener("resize", i), t.value.addEventListener("touchmove", i, { passive: !0 }), w());
|
|
86
|
+
}), H(() => {
|
|
87
|
+
t.value && (t.value.removeEventListener("scroll", i), t.value.removeEventListener("touchmove", i)), window.removeEventListener("resize", i);
|
|
88
|
+
}), (e, a) => (y(), h("div", {
|
|
89
|
+
class: T(["slider", { horizontal: !o.value }]),
|
|
60
90
|
ref_key: "sliderRef",
|
|
61
91
|
ref: t
|
|
62
92
|
}, [
|
|
63
|
-
(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
93
|
+
s.spacerEnabled ? (y(), h("div", {
|
|
94
|
+
key: 0,
|
|
95
|
+
class: "slider-spacer",
|
|
96
|
+
style: E(o.value ? { height: `${m.value}px`, minHeight: `${m.value}px` } : { width: `${m.value}px`, minWidth: `${m.value}px`, display: "inline-block" })
|
|
97
|
+
}, null, 4)) : V("", !0),
|
|
98
|
+
(y(!0), h(W, null, O(g.value, (l) => {
|
|
99
|
+
var c, v, d;
|
|
100
|
+
return y(), h("div", {
|
|
101
|
+
key: l,
|
|
67
102
|
class: "slider-item",
|
|
68
|
-
style:
|
|
69
|
-
|
|
70
|
-
marginRight: s.value ? "0" : `${l.itemGap}px`,
|
|
71
|
-
zIndex: S.value.length - a
|
|
103
|
+
style: E({
|
|
104
|
+
zIndex: g.value.length - l
|
|
72
105
|
})
|
|
73
106
|
}, [
|
|
74
|
-
|
|
107
|
+
j("div", {
|
|
75
108
|
class: "slider-slot",
|
|
76
|
-
style:
|
|
77
|
-
transform: `${
|
|
78
|
-
opacity: (
|
|
109
|
+
style: E({
|
|
110
|
+
transform: `${P.value}(${-((c = n[l]) == null ? void 0 : c.translate) || 0}%) scale(${((v = n[l]) == null ? void 0 : v.scale) || 1})`,
|
|
111
|
+
opacity: (d = n[l]) == null ? void 0 : d.opacity
|
|
79
112
|
})
|
|
80
113
|
}, [
|
|
81
|
-
|
|
82
|
-
|
|
114
|
+
_(e.$slots, `item-${l}`, { index: l }, () => [
|
|
115
|
+
_(e.$slots, "item", { index: l }, void 0, !0)
|
|
83
116
|
], !0)
|
|
84
117
|
], 4)
|
|
85
118
|
], 4);
|
|
86
119
|
}), 128))
|
|
87
120
|
], 2));
|
|
88
121
|
}
|
|
89
|
-
}),
|
|
90
|
-
const t =
|
|
91
|
-
for (const [
|
|
92
|
-
t[
|
|
122
|
+
}), U = (s, r) => {
|
|
123
|
+
const t = s.__vccOpts || s;
|
|
124
|
+
for (const [u, n] of r)
|
|
125
|
+
t[u] = n;
|
|
93
126
|
return t;
|
|
94
|
-
},
|
|
127
|
+
}, Y = /* @__PURE__ */ U(q, [["__scopeId", "data-v-55bb67bd"]]);
|
|
95
128
|
export {
|
|
96
|
-
|
|
129
|
+
Y as ScrollSlide
|
|
97
130
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(s,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(s=typeof globalThis<"u"?globalThis:s||self,e(s.ScrollSlide={},s.Vue))})(this,function(s,e){"use strict";const b=((c,a)=>{const l=c.__vccOpts||c;for(const[u,r]of a)l[u]=r;return l})(e.defineComponent({__name:"ScrollSlide",props:{direction:{type:String,default:"vertical",validator:c=>["vertical","horizontal"].includes(c)},itemCount:{type:Number,default:0},scaleRatio:{type:Number,default:.7},scaleStartPercent:{type:Number,default:.8},translateFactor:{type:Number,default:100},allowScrollToFirst:{type:Boolean,default:!1},spacerEnabled:{type:Boolean,default:!1}},setup(c){const a=c,l=e.ref(null),u=e.ref([]),r=e.reactive({}),i=e.computed(()=>a.direction==="vertical"),k=e.computed(()=>i.value?"translateY":"translateX"),z=(t,n)=>Math.min(Math.max(t/n,0),1),B=t=>t*t*(3-2*t),y=e.computed(()=>Array.from({length:a.itemCount},(t,n)=>n)),d=()=>{if(!l.value)return;const t=l.value,n=t[i.value?"clientHeight":"clientWidth"];u.value.forEach((o,m)=>{const f=o.getBoundingClientRect(),v=i.value?f.top:f.left,_=t.getBoundingClientRect(),w=v-(i.value?_.top:_.left),C=Math.min(Math.max(0,(n-w)/n),1),P=z(1-C-a.scaleStartPercent,1-a.scaleStartPercent),S=B(P),R=1+(a.scaleRatio-1)*S,$=S*a.translateFactor;let h;const g=Math.min(Math.max(S||0,0),1);g>.6?h=0:g<.4?h=1:h=(.6-g)/.2,r[m]={scale:R,translate:$,opacity:h}})},E=()=>{l.value&&(u.value=Array.from(l.value.querySelectorAll(".slider-item")),y.value.forEach(t=>{r[t]||(r[t]={scale:1,translate:0,opacity:1})}),Object.keys(r).forEach(t=>{const n=Number(t);n>=a.itemCount&&delete r[n]}),d())};e.watch(()=>a.itemCount,(t,n)=>{setTimeout(()=>{E()},0)},{immediate:!1});const p=e.computed(()=>{if(!l.value)return 0;const t=l.value[i.value?"clientHeight":"clientWidth"];let n=0;if(u.value.length>0){const o=u.value[0];if(o){const m=o.getBoundingClientRect();n=i.value?m.height:m.width}}return Math.max(0,t-n)});return e.onMounted(()=>{l.value&&(l.value.addEventListener("scroll",d),window.addEventListener("resize",d),l.value.addEventListener("touchmove",d,{passive:!0}),E())}),e.onUnmounted(()=>{l.value&&(l.value.removeEventListener("scroll",d),l.value.removeEventListener("touchmove",d)),window.removeEventListener("resize",d)}),(t,n)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["slider",{horizontal:!i.value}]),ref_key:"sliderRef",ref:l},[c.spacerEnabled?(e.openBlock(),e.createElementBlock("div",{key:0,class:"slider-spacer",style:e.normalizeStyle(i.value?{height:`${p.value}px`,minHeight:`${p.value}px`}:{width:`${p.value}px`,minWidth:`${p.value}px`,display:"inline-block"})},null,4)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(y.value,o=>{var m,f,v;return e.openBlock(),e.createElementBlock("div",{key:o,class:"slider-item",style:e.normalizeStyle({zIndex:y.value.length-o})},[e.createElementVNode("div",{class:"slider-slot",style:e.normalizeStyle({transform:`${k.value}(${-((m=r[o])==null?void 0:m.translate)||0}%) scale(${((f=r[o])==null?void 0:f.scale)||1})`,opacity:(v=r[o])==null?void 0:v.opacity})},[e.renderSlot(t.$slots,`item-${o}`,{index:o},()=>[e.renderSlot(t.$slots,"item",{index:o},void 0,!0)],!0)],4)],4)}),128))],2))}}),[["__scopeId","data-v-55bb67bd"]]);s.ScrollSlide=b,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
|
package/dist/vite.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|