11
11
|__/
12
12
```
13
13
14
- A simple library for image zooming; [ as seen on Medium] [ medium-zoom-article ] .
15
-
16
- This is a fork of the [ jQuery plugin by fat] [ fat-zoom ] . These are the key differences:
17
-
18
- 1 . No jQuery dependency; vanilla JavaScript only
19
- 2 . Equivalent file size (the minified version is slightly smaller due to better
20
- minification)
21
- 3 . Includes bug fixes not present in the original, since the original is no
22
- longer being maintained
23
-
24
- ** Live demo** : https://spinningarrow.github.io/zoom-vanilla.js
14
+ ** Live demo** : [ zoom-vanilla.js in action] [ live demo ] .
25
15
16
+ A simple library for image zooming; [ as seen on Medium] [ medium-zoom-article ] .
26
17
It zooms in really smoothly, and zooms out when you click again, scroll away,
27
18
or press the <kbd >esc</kbd > key.
28
19
29
20
If you hold the <kbd >⌘</kbd > or <kbd >Ctrl</kbd > key when clicking the image, it
30
21
will open the image in a new tab instead of zooming it.
31
22
23
+ _ This is a fork of the [ jQuery plugin by fat] [ fat-zoom ] _ . These are the key
24
+ differences:
25
+
26
+ 1 . ** No jQuery dependency** ; vanilla JavaScript only
27
+ 2 . ~ Equivalent~ smaller file size (the minified version is slightly smaller due
28
+ to better minification)
29
+ 3 . Includes bug fixes not present in [ fat/zoom.js] [ fat-zoom ] , which is no
30
+ longer being maintained
31
+
32
32
## Usage
33
33
34
- 1 . Download ` dist/zoom-vanilla.min.js ` and ` dist/zoom.css ` from GitHub, or
35
- install via npm by running ` npm i zoom-vanilla.js ` .
34
+ 1 . Download the JS and CSS files using any of the following methods:
35
+
36
+ - npm: `npm i -D zoom-vanilla.js`. This will download the the necessary
37
+ files to the `node_modules/zoom-vanilla.js/dist/` directory.
38
+
39
+ - Directly link to the files hosted on a CDN:
40
+
41
+ - JS:
42
+ https://cdn.jsdelivr.net/npm/zoom-vanilla.js/dist/zoom-vanilla.min.js
43
+
44
+ - CSS: https://cdn.jsdelivr.net/npm/zoom-vanilla.js/dist/zoom.css
45
+
46
+ - Manually download `dist/zoom-vanilla.min.js` and `dist/zoom.css` from
47
+ GitHub
36
48
37
49
2 . Add the ` zoom-vanilla.min.js ` and ` zoom.css ` files to your HTML page:
38
50
39
- ``` html
40
- <link href =" dist/zoom.css" rel =" stylesheet" > <!-- inside <head> -->
41
- <script src =" dist/zoom-vanilla.min.js" ></script > <!-- before </body> -->
42
- ```
51
+ ``` html
52
+ <!-- inside <head> -->
53
+ <link href =" path/to/dist/zoom.css" rel =" stylesheet" >
54
+
55
+ <!-- before </body> -->
56
+ <script src =" path/to/dist/zoom-vanilla.min.js" ></script >
57
+ ```
43
58
44
59
3. Add a `data-action="zoom"` attribute to the images you want to make
45
60
zoomable:
46
61
47
- ``` html
48
- <img src =" img/blog_post_featured.png" data-action =" zoom" >
49
- ```
62
+ ```html
63
+ <img src =" img/blog_post_featured.png" data-action =" zoom" >
64
+ ```
50
65
51
66
## Browser support
52
67
@@ -71,3 +86,5 @@ an issue! Thanks!
71
86
- `npm run build` to build the minified JS and vendor-prefixed CSS
72
87
- `npm run watch` to rebuild when any JS files change (recommended for
73
88
development)
89
+
90
+ [live demo]: http://code.sahil.me/zoom-vanilla.js
0 commit comments