@dpouris/gswap 0.0.1-alpha → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/README.md +160 -0
  2. package/package.json +3 -2
package/README.md ADDED
@@ -0,0 +1,160 @@
1
+ # GSwap 🌠
2
+
3
+ ### Create a gallery of images with ease.
4
+
5
+ ---
6
+
7
+ To get started, in your project folder, run:
8
+
9
+ ```
10
+ npm i @dpouris/gswap
11
+ ```
12
+
13
+ # Usage 🔨
14
+
15
+ First, import the library and create a new gswap instance:
16
+
17
+ ```
18
+ import { GSwap } from '@dpouris/gswap';
19
+
20
+ ...
21
+
22
+ const = document.getElementById("gallery")
23
+
24
+ const gswap = new GSwap({
25
+ containerElem: galleryContainer,
26
+
27
+ images: ["./1.jpg", "./2.jpg", "./3.webp"],
28
+
29
+ options : {
30
+ //animation: "fade", -> Todo
31
+ animationDuration: "300",
32
+ navigation: true,
33
+ // repeat: true, -> Todo
34
+ imgDimensions: { height: 300, width: 300 },
35
+ }
36
+ });
37
+ ```
38
+
39
+ This will create a new instance of gswap and will place the gallery absolutely inside the container you specified.
40
+
41
+ - **containerElem** (_required_):
42
+ - The container (div) element where the gallery will be placed absolutely.
43
+ - **images** (_required_):
44
+ - An array of image paths.
45
+ - **options** (_optional_):
46
+ - An object of options.
47
+ - See the [options](#Options) section for more details.
48
+
49
+ # Options ⚙️
50
+
51
+ ## **animation** (_fade_ | _slide_ | _none_) -> [wip]
52
+
53
+ Takes in an animation eg. fade or slide and applies it to the switching motion of the images.
54
+
55
+ - **fade**:
56
+ Fades the images in and out.
57
+ - **slide**:
58
+ Slides the images in and out.
59
+ - **none**:
60
+ Does not apply any animation.
61
+
62
+ - **Default**: fade
63
+
64
+ ---
65
+
66
+ ## **animationDuration** (_number_)
67
+
68
+ Takes in the duration of the animation that occurs upon switching the images and the speed at which the images move, in milliseconds. # 1000 = 1 second.
69
+
70
+ - **Default**: 300
71
+
72
+ ---
73
+
74
+ ## **navigation** (_boolean_ | forwardOnly | backOnly)
75
+
76
+ If true, the navigation arrows will be displayed. # true | false | "forwardOnly" | "backOnly"
77
+
78
+ - **forwardOnly**:
79
+ Only the forward arrow will be displayed.
80
+ - **backOnly**:
81
+ Only the back arrow will be displayed.
82
+
83
+ - **Default**: true
84
+
85
+ ---
86
+
87
+ ## **repeat** (_boolean_) -> [wip]
88
+
89
+ If true, the gallery will loop infinitely. # true || false
90
+
91
+ [wip]
92
+
93
+ - **Default**: true
94
+
95
+ ## direction (_top_ | _bottom_ | _left_ | _right_)
96
+
97
+ The direction of the gallery. # top || bottom
98
+
99
+ ## imgDimensions (_object_ : {height : number, width: number})
100
+
101
+ Takes in an object that contains the keys of width and height that will be applied as the dimensions of the images. # { height: 300, width: 300 }
102
+
103
+ Default: { height: 300, width: 300 }
104
+
105
+ # Methods 🧑‍💻
106
+
107
+ - [**gswap.next()**](<##gswap.next()>)
108
+ - [**gswap.prev()**](<##gswap.next()>)
109
+ - [**gswap.goTo(index)**](<##gswap.goTo(index)>) -> [wip]
110
+ - [**gswap.stackImages()**](<##gswap.stackImages()>)
111
+
112
+ ---
113
+
114
+ ## **gswap.next()**
115
+
116
+ Displays the next image in the gallery.
117
+ You can call the **next()** method by calling it from the gallery instance like so.
118
+
119
+ ```
120
+ const gallery = new GSwap(...);
121
+
122
+ ...
123
+
124
+ gallery.next();
125
+ ```
126
+
127
+ OR
128
+
129
+ You can bind the **next()** method to an onclick event like so.
130
+
131
+ ```
132
+ const gallery = new GSwap(...);
133
+ const nextBtn = document.getElementById('nextGalleryBtn')
134
+
135
+ nextBtn.onclick = gallery.next;
136
+ ```
137
+
138
+ **The same concept applies for the .prev() method the only difference being the it moves backwards through the images.**
139
+
140
+ ## **gswap.goTo(index)** -> wip
141
+
142
+ Takes in an index and displays the image at that index.
143
+
144
+ [wip]
145
+
146
+ ## **gswap.stackImages()**
147
+
148
+ Stacks the images in the gallery in case their position was altered.
149
+
150
+ Can be called from the gallery instance like so.
151
+
152
+ ```
153
+ const gallery = new GSwap(...);
154
+
155
+ ...
156
+
157
+ gallery.stackImages();
158
+ ```
159
+
160
+ Thank you for trying out my first library and I hope you enjoy it. 🫡
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@dpouris/gswap",
3
- "version": "0.0.1-alpha",
3
+ "version": "0.0.1",
4
4
  "description": "A library for swapping between images in a gallery",
5
5
  "main": "./dist/main.js",
6
6
  "types": "./dist/main.d.ts",
7
7
  "files": [
8
- "./dist"
8
+ "./dist",
9
+ "./README.md"
9
10
  ],
10
11
  "directories": {
11
12
  "example": "examples"