0.1.2 • Published 3 years ago

vue-h-zoom v0.1.2

Weekly downloads
99
License
MIT
Repository
github
Last release
3 years ago

vue-h-zoom

codecov npm vue2

Vue Native Zoom images

Installation

npm i --save-dev vue-h-zoom

About

This plugin is intended to provide native implementation of zooming library. It support thumbnail image and full size image as parameter. Location of zooming preview is configurable through absolute location.

Browser

Include the script file, then install the component with Vue.use(VueHZoom); e.g.:

<script type="text/javascript" src="node_modules/vuejs/dist/vue.min.js"></script>
<script type="text/javascript" src="node_modules/vue-h-zoom/dist/vue-h-zoom.min.js"></script>
<script type="text/javascript">
  Vue.use(VueHZoom);
</script>

Module

import VueHZoom from 'vue-h-zoom';

Usage

Use in template for example as:

<vue-h-zoom image="/assets/bugatti-chiron-white_01_thumb.jpg"
  image-full="/assets/bugatti-chiron-white_01.jpg"
  :zoom-level="4"></vue-h-zoom>

Important notes

To be able to import image locally, you need to register the vue-h-zoom tag to the vue loader, add this to your webpack config:

{
  test: /\.vue$/,
  loader: 'vue-loader',
  options: {
    loaders: {
    },
    // other vue-loader options go here
    transformToRequire: {
      'vue-h-zoom': ['image', 'image-full']
    }
  }
},

Parameters

AttributeTypeDefaultValueDescription
imageString--Image to be displayed in thumbnail. Used also in the zoom if imageFull param is not given (required)
image-fullString''-Large version of image
widthNumber200-Width of thumbnail in px
heightNumber200-Height of thumbnail in px
zoom-levelNumber4-Zoom level
zoom-window-sizeNumber2-Zoom window size multiplier, relative with thumbnail size
zoom-window-xNumber300-Location absolute on x-axis for zoom window
zoom-window-yNumber300-Location absolute on y-axis for zoom window
background-optionsObjectnullBACKGROUND_OPTIONS object or {} or trueOptions to create custom background. Please refer to next section for available properties

BACKGROUND_OPTIONS

PropertiesTypeDefaultDescription
imageString'none'Image url to be used as background
colorString'#fff'Color to be used in background, use any value compatible with background-color css property
repeatBooleanfalseOption to repeat the background image
sizeString'100%'Set the size of background image, use any value compatible with background-size css property
positionString'top left'Set the position of background image, use any value compatible with background-position css property

Additional notes:

  • You can specify truthy value to use default background options, such as <vue-h-zoom background-options="true" /> or <vue-h-zoom background-options="{}" />
  • You only need to specify property (s) that you need, such as <vue-h-zoom background-options="{ color: 'blue' }" />
  • Using background-options automatically update the image size property to background-size: contain;, instead of the default background-size: cover;. This is done so that the background is also included in zoomed preview.

Preview

:copyright: License

MIT

0.1.2

3 years ago

0.1.0

4 years ago

0.1.1

4 years ago

0.0.17

4 years ago

0.0.16

4 years ago

0.0.15

6 years ago

0.0.14

6 years ago

0.0.13

6 years ago

0.0.12

6 years ago

0.0.11

6 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago