Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

a advanced zoombox

NotificationsYou must be signed in to change notification settings

vue-comps/vue-zoombox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

a advanced zoombox.

  • Reposition on window resize
  • Full resolution for images
  • support for caption
  • support for scrolling
  • support for thumbs

Install

npm install --save-dev vue-zoombox

or includebuild/bundle.js.

Usage

# in your componentcomponents:"zoombox":require("vue-zoombox")# or, when using bundle.jscomponents:"zoombox":window.vueComps.zoombox
<zoomboxsrc="./path/to/img"thumb="./path/to/thumb"><span>A caption</span><spanslot="loading">loading...</span><spanslot="opened">Will be shown besides the image when opened</span></zoombox>

seedev/ for examples.

Props

Nametypedefaultdescription
srcString-(required) path to image.
thumbString-path to thumb
delayNumber3000Only if thumb is given, delays loading of the image, in ms. 0 to disable auto load of image.
opacityNumber0.5opacity of the overlay
max-scaleNumberNumber.MAX_VALUEmaximal zoom factor
allow-scrollBooleanfalsewill not close on scroll
disable-scrollBooleanfalsewill disable scrolling
is-openedBooleanfalse(two-way) set to open / close
transitionString"zoombox"name of a vue transition.Detailed description
caption-transitionString"zoomboxCaption"name of a vue transition.Detailed description

if thumb is given the image is loaded afterdelay or onmouseenter.
If the image isn't loaded on click, the slotloading is displayed.

Events

Namedescription
before-enterwill be called before open animation
after-enterwill be called when opened
before-leavewill be called before close animation
after-leavewill be called when closed
thumb-loadedwill be called when thumb is ready
image-loadedwill be called when image is ready
toggled(isOpened:Boolean)emitted when gets opened or closed. Alternative to use two-wayis-opened prop

Transition

You can provide a vue transition like this:

Vue.transition("fade",{// your transition})// or in the instance:transitions:{fade:{// your transition}}// usage:template:"<zoombox transition='fade'></zoombox>"

You can access several properties in your hooks:

enter:function(el,cb){self=thisthis.nextTick(function(){self.imgScale// scale to get the small image sizeself.scale// multiply with imgScale to get the big image size// target top and left positions for big image sizeself.relPos.topself.relPos.left// starting position for top and left are 0})}

Example fromdev/basic.vue

Velocity=require("velocity-animate")transitions:zoombox:css:falseenter: (el,done)->Velocity.hook(el,"scale",@imgScale)@$nextTick=>Velocity el, {scale:@imgScale*@scale,top:@relPos.top,left:@relPos.left}, {duration:1000,queue:false,ease:"easeOutQuad",complete: done        }leave: (el,done)->Velocity.hook(el,"scale",@imgScale*@scale)Velocity el, {scale:@imgScale,top:0,left:0}, {duration:1000,queue:false,ease:"easeOutQuad",complete: done      }

Changelog

  • 1.0.2
    added opened slot
    little bugfix with lineheight

  • 1.0.1
    close overlay on destroy
    changed container behavior to allow responsive images (#1)

  • 1.0.0
    removed support for other content (only images now)
    now using vue transitions
    events are renamed after vue transitions
    added support for thumbs
    added unit tests

Development

Clone repository.

npm installnpm run dev

Browse tohttp://localhost:8080/.

License

Copyright (c) 2016 Paul PflugradtLicensed under the MIT license.

About

a advanced zoombox

Resources

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp