mirari / v-viewer

Image viewer component for vue, supports rotation, scale, zoom and so on, based on viewer.js
https://mirari.cc/v-viewer/
MIT License
2.46k stars 292 forks source link

modal模式下怎么做到 pre和next监听(主要是键盘事件的自定义) #332

Closed weifengliuhen closed 1 month ago

weifengliuhen commented 3 months ago
找了半天只有toolbar的prev和next

const $viewer = VueViewer.api({
  images: sourceImages,
  options: {
    button:false,
    toolbar:{ 
      prev: { show: true,  click: (e)=>{
        $viewer.prev(true);
        console.log(e)
      } },
      next:{ show: true,  click: (e)=>{
        $viewer.next(true);
        console.log(e)
      } }
    },
    navbar:false,
    viewed: (e)=> {
      //console.log(e)
      sourceImages.push(this.images[this.tmp++])
      $viewer.image.addEventListener("keyown",()=>{
        console.log($viewer)
      })
    },
    ready:(e)=>{

    }
  } 

})
mirari commented 3 months ago

监听事件?api模式下只能在options里定义回调 组件和指令都可以在元素上直接监听这两个事件


我看错了,没有这两个原生事件,只能监听view事件,看index的变化