From 54bb2f3e8cc3b8a2583a2228c0da1e626135700e Mon Sep 17 00:00:00 2001 From: Alexey Date: Tue, 11 Jun 2019 19:56:10 +0300 Subject: [PATCH] feat($plugin-medium-zoom): custom options (#1649) Also update medium-zoom to v1.0.4 --- .../plugin-medium-zoom/clientRootMixin.js | 4 ++-- .../@vuepress/plugin-medium-zoom/index.js | 3 ++- .../@vuepress/plugin-medium-zoom/package.json | 2 +- .../plugin/official/plugin-medium-zoom.md | 23 +++++++++++++++++++ 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/packages/@vuepress/plugin-medium-zoom/clientRootMixin.js b/packages/@vuepress/plugin-medium-zoom/clientRootMixin.js index e0a054539c..a83e01c980 100644 --- a/packages/@vuepress/plugin-medium-zoom/clientRootMixin.js +++ b/packages/@vuepress/plugin-medium-zoom/clientRootMixin.js @@ -1,4 +1,4 @@ -/* global SELECTOR */ +/* global SELECTOR, OPTIONS */ import './style.css' import zoom from 'medium-zoom' @@ -20,7 +20,7 @@ export default { if (this.zoom) { this.zoom.detach() } - this.zoom = zoom(SELECTOR) + this.zoom = zoom(SELECTOR, OPTIONS) }, 1000) } } diff --git a/packages/@vuepress/plugin-medium-zoom/index.js b/packages/@vuepress/plugin-medium-zoom/index.js index c9a956af81..3d2fbf2387 100644 --- a/packages/@vuepress/plugin-medium-zoom/index.js +++ b/packages/@vuepress/plugin-medium-zoom/index.js @@ -2,7 +2,8 @@ const { path } = require('@vuepress/shared-utils') module.exports = (options, context) => ({ define: { - SELECTOR: options.selector || '.content img' + SELECTOR: options.selector || '.content img', + OPTIONS: options.options }, clientRootMixin: path.resolve(__dirname, 'clientRootMixin.js') }) diff --git a/packages/@vuepress/plugin-medium-zoom/package.json b/packages/@vuepress/plugin-medium-zoom/package.json index e927b6ffcc..57b11f879c 100644 --- a/packages/@vuepress/plugin-medium-zoom/package.json +++ b/packages/@vuepress/plugin-medium-zoom/package.json @@ -18,7 +18,7 @@ "generator" ], "dependencies": { - "medium-zoom": "^0.4.0" + "medium-zoom": "^1.0.4" }, "author": "ULIVZ ", "license": "MIT", diff --git a/packages/docs/docs/plugin/official/plugin-medium-zoom.md b/packages/docs/docs/plugin/official/plugin-medium-zoom.md index 92369d5681..2f3a2a53d0 100644 --- a/packages/docs/docs/plugin/official/plugin-medium-zoom.md +++ b/packages/docs/docs/plugin/official/plugin-medium-zoom.md @@ -16,15 +16,38 @@ yarn add -D @vuepress/plugin-medium-zoom@next ## Usage +**Simple**: + ```javascript module.exports = { plugins: ['@vuepress/medium-zoom'] } ``` +**With options**: + +```javascript +module.exports = { + plugins: { + '@vuepress/medium-zoom': { + selector: 'img.zoom-custom-imgs', + + // medium-zoom options here (https://github.com/francoischalifour/medium-zoom#options) + options: { + margin: 16 + } + } + } +} +``` + ## Options ### selector - Type: `string` - Default: `.content img` + +### options + +Other `medium-zoom` options. [See documentation](https://github.com/francoischalifour/medium-zoom#options).