Skip to content

Commit 54bb2f3

Browse files
Raiondesuulivz
authored andcommitted
feat($plugin-medium-zoom): custom options (#1649)
Also update medium-zoom to v1.0.4
1 parent 6c60e54 commit 54bb2f3

File tree

4 files changed

+28
-4
lines changed

4 files changed

+28
-4
lines changed

packages/@vuepress/plugin-medium-zoom/clientRootMixin.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* global SELECTOR */
1+
/* global SELECTOR, OPTIONS */
22

33
import './style.css'
44
import zoom from 'medium-zoom'
@@ -20,7 +20,7 @@ export default {
2020
if (this.zoom) {
2121
this.zoom.detach()
2222
}
23-
this.zoom = zoom(SELECTOR)
23+
this.zoom = zoom(SELECTOR, OPTIONS)
2424
}, 1000)
2525
}
2626
}

packages/@vuepress/plugin-medium-zoom/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ const { path } = require('@vuepress/shared-utils')
22

33
module.exports = (options, context) => ({
44
define: {
5-
SELECTOR: options.selector || '.content img'
5+
SELECTOR: options.selector || '.content img',
6+
OPTIONS: options.options
67
},
78
clientRootMixin: path.resolve(__dirname, 'clientRootMixin.js')
89
})

packages/@vuepress/plugin-medium-zoom/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"generator"
1919
],
2020
"dependencies": {
21-
"medium-zoom": "^0.4.0"
21+
"medium-zoom": "^1.0.4"
2222
},
2323
"author": "ULIVZ <[email protected]>",
2424
"license": "MIT",

packages/docs/docs/plugin/official/plugin-medium-zoom.md

+23
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,38 @@ yarn add -D @vuepress/plugin-medium-zoom@next
1616

1717
## Usage
1818

19+
**Simple**:
20+
1921
```javascript
2022
module.exports = {
2123
plugins: ['@vuepress/medium-zoom']
2224
}
2325
```
2426

27+
**With options**:
28+
29+
```javascript
30+
module.exports = {
31+
plugins: {
32+
'@vuepress/medium-zoom': {
33+
selector: 'img.zoom-custom-imgs',
34+
35+
// medium-zoom options here (https://github.com/francoischalifour/medium-zoom#options)
36+
options: {
37+
margin: 16
38+
}
39+
}
40+
}
41+
}
42+
```
43+
2544
## Options
2645

2746
### selector
2847

2948
- Type: `string`
3049
- Default: `.content img`
50+
51+
### options
52+
53+
Other `medium-zoom` options. [See documentation](https://github.com/francoischalifour/medium-zoom#options).

0 commit comments

Comments
 (0)