Git Product home page Git Product logo

v-viewer's Introduction

v-viewer

Image viewer component for vue, supports rotation, scale, zoom and so on, based on viewer.js

npm version language

npm version language

npm download license

Quick Example

Installation

Install from NPM

npm install v-viewer viewerjs

Usage

To use v-viewer, simply import it and the css file, and call app.use() to install.

The component, directive and api will be installed together in the global.

Two different API styles are both supported: Options API and Composition API.

import { createApp } from 'vue'
import App from './App.vue'
import 'viewerjs/dist/viewer.css'
import VueViewer from 'v-viewer'
const app = createApp(App)
app.use(VueViewer)
app.mount('#app')
<template>
  <div>
    <!-- directive -->
    <div class="images" v-viewer>
      <img v-for="src in images" :key="src" :src="src">
    </div>
    <!-- component -->
    <viewer :images="images">
      <img v-for="src in images" :key="src" :src="src">
    </viewer>
    <!-- api -->
    <button type="button" @click="show">Click to show</button>
  </div>
</template>
<!-- Options API -->
<script lang="ts">
  import { defineComponent } from 'vue'
  export default defineComponent({
    data() {
      return {
        images: [
          "https://picsum.photos/200/200",
          "https://picsum.photos/300/200",
          "https://picsum.photos/250/200"
        ]
      }
    },
    methods: {
      show() {
        this.$viewerApi({
          images: this.images
        })
      }
    }
  })
</script>
<!-- Composition API -->
<!-- <script lang="ts" setup>
  import { api as viewerApi } from 'v-viewer'
  const images = [
    "https://picsum.photos/200/200",
    "https://picsum.photos/300/200",
    "https://picsum.photos/250/200"
  ]
  const show = () => {
    viewerApi({
      images
    })
  }
</script> -->

Support UMD

Browser

<link href="//unpkg.com/viewerjs/dist/viewer.css" rel="stylesheet">
<script src="//unpkg.com/vue"></script>
<script src="//unpkg.com/viewerjs/dist/viewer.js"></script>
<script src="//unpkg.com/v-viewer/dist/index.umd.js"></script>
<script>
  app.use(VueViewer.default)
</script>

CommonJS

var VueViewer = require('VueViewer')

AMD

require(['VueViewer'], function (VueViewer) {});

Usage of directive

Just add the directive v-viewer to any element, then all img elements in it will be handled by viewer.

You can set the options like this: v-viewer="{inline: true}"

Get the element by selector and then use el.$viewer to get the viewer instance if you need.

<template>
  <div>
    <div class="images" v-viewer="{movable: false}">
      <img v-for="src in images" :src="src" :key="src">
    </div>
    <button type="button" @click="show">Show</button>
  </div>
</template>
<!-- Options API -->
<script lang="ts">
  import { defineComponent } from 'vue'
  import 'viewerjs/dist/viewer.css'
  import { directive as viewer } from "v-viewer"
  export default defineComponent({
    directives: {
      viewer: viewer({
        debug: true
      })
    },
    data() {
      return {
        images: [
          "https://picsum.photos/200/200",
          "https://picsum.photos/300/200",
          "https://picsum.photos/250/200"
        ]
      }
    },
    methods: {
      show () {
        const viewer = this.$el.querySelector('.images').$viewer
        viewer.show()
      }
    }
  })
</script>
<!-- Composition API -->
<!-- <script lang="ts" setup>
  import 'viewerjs/dist/viewer.css'
  import { directive as viewer } from "v-viewer"
  const vViewer = viewer({
    debug: true
  })
  const images = [
    "https://picsum.photos/200/200",
    "https://picsum.photos/300/200",
    "https://picsum.photos/250/200"
  ]
  const show = () => {
    const viewer = document.querySelector('.images').$viewer
    viewer.show()
  }
</script> -->

Directive modifiers

static

The viewer instance will be created only once after the directive binded.

If you're sure the images inside this element won't change again, use it to avoid unnecessary re-render.

<div class="images" v-viewer.static="{inline: true}">
  <img v-for="src in images" :src="src" :key="src">
</div>
rebuild

The viewer instance will be updated by update method when the source images changed (added, removed or sorted) by default.

If you encounter any display problems, try rebuilding instead of updating.

<div class="images" v-viewer.rebuild="{inline: true}">
  <img v-for="src in images" :src="src" :key="src">
</div>

Usage of component

You can simply import the component and register it locally too.

<template>
  <div>
    <viewer :images="images"
            @inited="inited"
            class="viewer"
            ref="viewer"
            >
      <template #default="scope">
        <img v-for="src in scope.images" :src="src" :key="src">
        {{scope.options}}
      </template>
    </viewer>
    <button type="button" @click="show">Show</button>
  </div>
</template>
<!-- Options API -->
<script lang="ts">
  import { defineComponent } from 'vue'
  import 'viewerjs/dist/viewer.css'
  import { component as Viewer } from "v-viewer"
  export default defineComponent({
    components: {
      Viewer,
    },
    data() {
      return {
        images: [
          "https://picsum.photos/200/200",
          "https://picsum.photos/300/200",
          "https://picsum.photos/250/200"
        ]
      }
    },
    methods: {
      inited (viewer) {
        this.$viewer = viewer
      },
      show () {
        this.$viewer.show()
      }
    }
  })
</script>
<!-- Composition API -->
<!-- <script lang="ts" setup>
  import 'viewerjs/dist/viewer.css'
  import { component as Viewer } from "v-viewer"
  const images = [
    "https://picsum.photos/200/200",
    "https://picsum.photos/300/200",
    "https://picsum.photos/250/200"
  ]
  let $viewer:any = null
  const inited = (viewer) => {
    $viewer = viewer
  }
  const show = () => {
    $viewer.show()
  }
</script> -->

Component props

images
  • Type: Array
trigger
  • Type: Object

You can replace images with trigger, to accept any type of prop. when the trigger changes, the component will re-render the viewer.

<viewer :trigger="externallyGeneratedHtmlWithImages">
  <div v-html="externallyGeneratedHtmlWithImages"/>
</viewer>
rebuild
  • Type: Boolean
  • Default: false

The viewer instance will be updated by update method when the source images changed (added, removed or sorted) by default.

If you encounter any display problems, try rebuilding instead of updating.

<viewer
  ref="viewer"
  :options="options"
  :images="images"
  rebuild
  class="viewer"
  @inited="inited"
>
  <template #default="scope">
    <img v-for="src in scope.images" :src="src" :key="src">
    {{scope.options}}
  </template>
</viewer>

Component events

inited
  • viewer: Viewer

Listen for the inited event to get the viewer instance, or use this.refs.xxx.$viewer.

Usage of api

Only available in modal mode.

You can call the function: this.$viewerApi({options: {}, images: []}) to show gallery without rendering the img elements yourself.

The function returns the current viewer instance.

<template>
  <div>
    <button type="button" class="button" @click="previewURL">URL Array</button>
    <button type="button" class="button" @click="previewImgObject">Img-Object Array</button>
  </div>
</template>
<!-- Options API -->
<script lang="ts">
  import { defineComponent } from 'vue'
  import 'viewerjs/dist/viewer.css'
  import { api as viewerApi } from "v-viewer"
  export default defineComponent({
    data() {
      return {
        sourceImageURLs: [
          'https://picsum.photos/200/200?random=1',
          'https://picsum.photos/200/200?random=2'
        ],
        sourceImageObjects: [
          {
            'src': 'https://picsum.photos/200/200?random=3',
            'data-source': 'https://picsum.photos/800/800?random=3'
          },
          {
            'src': 'https://picsum.photos/200/200?random=4',
            'data-source': 'https://picsum.photos/800/800?random=4'
          }
        ]
      }
    },
    methods: {
      previewURL () {
        // If you use the `app.use` full installation, you can use `this.$viewerApi` directly like this
        const $viewer = this.$viewerApi({
          images: this.sourceImageURLs
        })
      },
      previewImgObject () {
        // Or you can just import the api method and call it.
        const $viewer = viewerApi({
          options: {
            toolbar: true,
            url: 'data-source',
            initialViewIndex: 1
          },
          images: this.sourceImageObjects
        })
      }
    }
  })
</script>
<!-- Composition API -->
<!-- <script lang="ts" setup>
import 'viewerjs/dist/viewer.css'
import { api as viewerApi } from 'v-viewer'
const sourceImageURLs = [
  'https://picsum.photos/200/200?random=1',
  'https://picsum.photos/200/200?random=2'
]
const sourceImageObjects = [
  {
    src: 'https://picsum.photos/200/200?random=3',
    'data-source': 'https://picsum.photos/800/800?random=3'
  },
  {
    src: 'https://picsum.photos/200/200?random=4',
    'data-source': 'https://picsum.photos/800/800?random=4'
  }
]
const previewURL = () => {
  // If you use the `app.use` full installation, you can use `this.$viewerApi` directly like this
  const $viewer = this.$viewerApi({
    images: sourceImageURLs
  })
}
const previewImgObject = () => {
  // Or you can just import the api method and call it.
  const $viewer = viewerApi({
    options: {
      toolbar: true,
      url: 'data-source',
      initialViewIndex: 1
    },
    images: sourceImageObjects
  })
}
</script> -->

Options & Methods of Viewer

Refer to viewer.js.

Plugin options

name

  • Type: String
  • Default: viewer

If you need to avoid name conflict, you can import it like this:

import { createApp } from 'vue'
import 'viewerjs/dist/viewer.css'
import VueViewer from 'v-viewer'
import App from './App.vue'

export const app = createApp(App)
app.use(VueViewer, {
  name: 'vuer',
  debug: true,
})
app.mount('#app')
<template>
<div>
  <!-- directive name -->
  <div class="images" v-vuer="{movable: false}">
    <img v-for="src in images" :src="src" :key="src">
  </div>
  <button type="button" @click="show">Show</button>
  <!-- component name -->
  <vuer :images="images">
    <img v-for="src in images" :src="src" :key="src">
  </vuer>
  </div>
</template>
<!-- Options API -->
<script lang="ts">
  import { defineComponent } from 'vue'
  export default defineComponent({
    data() {
      return {
        images: [
          "https://picsum.photos/200/200",
          "https://picsum.photos/300/200",
          "https://picsum.photos/250/200"
        ]
      };
    },
    methods: {
      show () {
        // viewerjs instance name
        const vuer = this.$el.querySelector('.images').$vuer
        vuer.show()
        // api name
        this.$vuerApi({
          images: this.images
        })
      }
    }
  })
</script>
<!-- Composition API -->
<script lang="ts" setup>
  import { api as vuerApi } from 'v-viewer'
  const images = [
    "https://picsum.photos/200/200",
    "https://picsum.photos/300/200",
    "https://picsum.photos/250/200"
  ]
  const show = () => {
    // viewerjs instance name
    const vuer = document.querySelector('.images').$vuer
    vuer.show()
    // api name
    vuerApi({
      images
    })
  }
</script>

defaultOptions

  • Type: Object
  • Default: undefined

If you need to set the viewer default options, you can import it like this:

import { createApp } from 'vue'
import 'viewerjs/dist/viewer.css'
import VueViewer from 'v-viewer'
import App from './App.vue'

export const app = createApp(App)
app.use(VueViewer, {
  defaultOptions: {
    zIndex: 9999
  }
})
app.mount('#app')

And you can reset the default options at any other time:

import VueViewer from 'v-viewer'

VueViewer.setDefaults({
  zIndexInline: 2021,
})

v-viewer's People

Contributors

dependabot[bot] avatar golevka2001 avatar haiweilian avatar mirari avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

v-viewer's Issues

Capture click even on rendered v-viewer image

I am trying to capture a click event on the image element as it is rendered by v-viewer. I have tried adding template markup using scoped slots, and extending the whole component with no luck.

Ultimately I would like to record the X and Y position of the click in order to simulate 'dropping a pin' on the image.

Do you think it is possible?

Thank you for an awesome component!

Getting a "Failed to resolve directive: viewer"?

I downloaded v-viewer.js into my project and registered it using Vue.use(VueViewer). I start getting the warning whenever I use "v-viewer" in my html. I'm assuming there are additional steps to successfully register the directive?

inline 模式时,配合输入框,v-viewer 重复渲染

操作输入框时,v-viewer 重复渲染

<template>
  <section>
    <div class="viewer-box">
      <viewer :images="[images]" :options="options">
        <img class="viewer-image" :src="images">
      </viewer>
    </div>
    <el-input v-model="inputValue"></el-input>
  </section>
</template>
<script>
  import Viewer from 'v-viewer';
  export default {
    components: {
      Catalog,
      XforceHeader
    },
    data() {
      return {
        inputValue: '',
        options: {
          'inline': true,
          'button': false,
          'navbar': false,
          'title': false,
          'toolbar': true,
          'tooltip': false,
          'movable': true,
          'zoomable': true,
          'rotatable': true,
          'scalable': false,
          'transition': true,
          'fullscreen': false,
          'keyboard': false,
          'url': 'data-source'
        },
        images: 'https://avatars2.githubusercontent.com/u/7300964?s=88&v=4'
      }
    }
  }
</script>
<style lang="scss">
  .viewer-box {
    width: 400px;
    height: 400px;
  }
</style>

Re render viewer when resize window

Hi,
Do you have any idea if I can re-render the viewer when I manipulate the window width. I've tried to re-assign the options with a dynamic minWidth param but it doesn't work.
I appreciate with some could help me out with this issue.
Regards,

Component method not working!

<viewer :images="this.awardData.files">
          <img v-for="src in this.awardData.files" :src="'src'" :key="src">
        </viewer>

Hey, above is my code. I tried using component method. But nothing is shown in the browser.

Is that I should use directive method also or any of the methods(component, directives) is fine?

希望能支持一下服务端渲染

目前在服务端渲染中v-viewer directive无法正常识别导致报错,希望能够支持下服务端渲染。例如提供延后处理的方法,把业务推迟到mounted之后。

如何只去掉图片切换时候的动画

这个组件做得很棒,先给作者点个赞。
我在使用的过程中,感觉里面的动画过渡效果很好,比如旋转、缩放时候的动画,但是当切换图片列表上一张下一张的时候,那个从中间缩放出来的效果我不想要,但是我想保留其他的动画效果。
目前只找到一个transition属性来开关所有的动画效果,但是没有办法只去掉图片切换时候的动画。

想请教如何做到,谢谢!

可以修改全局默认配置吗?

我直接在main.js里面import 和 Vue.use后,我就可以在所有路由组件使用了.可是可以修改全局默认配置吗,这样就不需要再在每个使用的地方都写一遍options.Viewer.setDefaults(options)用这个会报错
errMsg:Uncaught TypeError: __WEBPACK_IMPORTED_MODULE_12_v_viewer___default.a.setDefaults is not a function

Allowed formats

First of all, excellent work.
I would like to know if there is any way to show images and other types of files such as a PDF or Videos.
Greetings.

列表中循环多次指令,只能最后一个生效

当在列表中使用指令方式时,只有列表的最后一项可以显示出来,而其他的都报错,因为获取不到$viewer对象。

<template>
  <el-table
    :data="records"
    style="width: 100%"
    :border="true"
    :class="'mbaex-table'"
    :stripe="true"
  >
    <el-table-column
      prop="status"
      label="状态"
      width="125">
      <template slot-scope="scope">
        <div class="color-primary" v-if="scope.row.status == 3">
          等待确认
          <span class="inlin-block pt-15 pb-15 pr-10 pl-5 cursor-pointer" title="点击查看图片" @click="showImgViewer">查看图片</span>
          <div class="hidden viewer-box" v-viewer="{url: 'data-large', navbar: false, movable: false}">
            <img :data-large="scope.row.receiptUrl" alt="">
          </div>
        </div>
        <div class="color-primary" v-if="scope.row.status == 1">
          支付成功
          <span class="inlin-block pt-15 pb-15 pr-10 pl-5 cursor-pointer" title="点击查看图片" @click="showImgViewer">查看图片</span>
          <div class="hidden viewer-box" v-viewer="{url: 'data-large', navbar: false, movable: false}">
            <img :data-large="scope.row.receiptUrl" alt="">
          </div>
        </div>
      </template>
    </el-table-column>
  </el-table>
</template>
<script>
  export default {
    data(){
      records: [
        {
            "receiptUrl": "https://car2.autoimg.cn/cardfs/product/g2/M08/4C/52/1024x0_1_q87_autohomecar__wKgHGVttOOuAZF-3AAmEjM2FLPM352.jpg",
            "status": 1
        },
        {
            "status": 2
        },
        {
            "receiptUrl": "https://car2.autoimg.cn/cardfs/product/g2/M00/4C/52/1024x0_1_q87_autohomecar__wKgHGVttOOeAEBGPAApcgEw-noc081.jpg",
            "status": 1
        },
        {
            "receiptUrl": "https://gss3.bdstatic.com/7Po3dSag_xI4khGkpoWK1HF6hhy/baike/c0%3Dbaike180%2C5%2C5%2C180%2C60/sign=d49cfe51f703918fc3dc359830544df2/6159252dd42a283483209fba5bb5c9ea14cebff9.jpg",
            "status": 1
        }
      ]
    },
    methods: {
      // 点击"图片图标"显示大图
      showImgViewer(e){
        let event = e || window.event;
        this.$nextTick(() => {
          let target = event.currentTarget || event.target.parentElement,
            parent = target.parentElement;
            
          let viewer = parent.querySelector(".viewer-box").$viewer;
          console.log(parent.querySelector(".viewer-box"))
          console.log(viewer)
          viewer.show();
        });        
      }
    }
  }
</script>

在我的项目中,出现的问题就是只有最后一张图片能够点击,并显示出来,其他图片点击就报错

open inline in a specific div

i want the image to open inline in a specific div so that i add more content by the side
how can i do that ? thanks

v0.3.x 升级 v1.x 直接乱

讲真, 给个升级 API 修改提醒啊. 如果不是 vue 版的问题, 那么也在文档说出 viewerjs 在接口做出变更的提醒啊...

Console logs for directive

Hi Mirari,

Console logs for directive are pretty annoying. If you really need them, is it possible to pass some value {verbose : true} through options that will show them, so that they are not showing by default?

Regards,
Marin

electron-vue使用报语法错误 vue直接使用没问题

image

Uncaught SyntaxError: Unexpected token .
at createScript (vm.js:74)
at Object.runInThisContext (vm.js:116)
at Module._compile (module.js:533)
at Object.Module._extensions..js (module.js:580)
at Module.load (module.js:503)
at tryModuleLoad (module.js:466)
at Function.Module._load (module.js:458)
at Module.require (module.js:513)
at require (internal/module.js:11)
at webpackUniversalModuleDefinition (E:

页面会重复多个弹出框

bug效果如下:
gif。。。https://i.loli.net/2018/08/10/5b6ce6e4139b7.gif

下面是代码

<el-card class="box-card" v-viewer>
    <el-collapse v-model="logActive">
      <el-collapse-item name="log">
        <template slot="title">
          <div class="header">日志记录</div>
        </template>
        <el-table :data="formatLog" stripe style="width: 100%">
          <el-table-column prop="OperationTime" label="操作时间">
          </el-table-column>
          <el-table-column prop="CreateUser" label="操作人">
          </el-table-column>
          <el-table-column prop="Remark" label="操作内容">
            <template slot-scope="scope">
              <template v-if="scope.row.TaskType === 'Log'" >
                <span>{{ scope.row.Remark }}</span>
              </template>
              <template v-if="scope.row.TaskType === 'Image'" >
                <img style="max-height: 60px;" :src="scope.row.Remark.url" :title="scope.row.Remark.name" :alt="scope.row.Remark.name"/>
              </template>
              <template v-if="scope.row.TaskType === 'File'" >
                <a :href="scope.row.Remark.url" target="_blank">{{scope.row.Remark.name}}</a>
              </template>
            </template>
          </el-table-column>
        </el-table>
      </el-collapse-item>
    </el-collapse>
  </el-card>
import Viewer from 'v-viewer'
import Vue from 'vue'
Vue.use(Viewer)

viewer.css

import 'viewerjs/dist/viewer.css'
viewer.css 找不到哦

Bounds

Hi, Thank you for the great work.
I'd like to try to use the plugin for displaying examples but I need the option to keep image inside a container.
I mean when edges of a picture can't be moved inside a container
is there a way to set bounds to keep zoomed image inside a container?

IE10,v-viewer.js 源码抛异常 Error in directive viewer bind hook: "TypeError: 对象不支持此操作"

[Vue warn]: Error in directive viewer bind hook: "TypeError: 对象不支持此操作"

(found in )
TypeError: 对象不支持此操作
{
[functions]: ,
description: "对象不支持此操作",
message: "对象不支持此操作",
name: "TypeError",
number: -2146827843,
stack: "TypeError: 对象不支持此操作
at c (http://localhost:8088/asset/js/lib/v-viewer-92fca2ef710c.js:53:29)
at bind (http://localhost:8088/asset/js/lib/v-viewer-92fca2ef710c.js:86:60)
at callHook$1 (http://localhost:8088/asset/js/lib/vue.min-f72e90dab59c.js:6280:7)
at _update (http://localhost:8088/asset/js/lib/vue.min-f72e90dab59c.js:6202:7)
at updateDirectives (http://localhost:8088/asset/js/lib/vue.min-f72e90dab59c.js:6183:5)
at invokeCreateHooks (http://localhost:8088/asset/js/lib/vue.min-f72e90dab59c.js:5685:7)
at createElm (http://localhost:8088/asset/js/lib/vue.min-f72e90dab59c.js:5573:11)
at createChildren (http://localhost:8088/asset/js/lib/vue.min-f72e90dab59c.js:5669:9)
at createElm (http://localhost:8088/asset/js/lib/vue.min-f72e90dab59c.js:5571:9)
at createChildren (http://localhost:8088/asset/js/lib/vue.min-f72e90dab59c.js:5669:9)"
}

Not working with Nuxt.js out of the box, error: Unexpected token .

Problem

require("viewerjs/dist/viewer.css") inside compiled module crashes when running in Nuxt.js webpack environment (and possibly many others).

Steps to reproduce

This recreates full test environment completely from scratch:

mkdir viewtest
cd viewtest
yarn init .
yarn add nuxt v-viewer

create pages/index.vue:

<template>
<div v-viewer>
	<img src="https://lorempixel.com/600/400/">
	<img src="https://lorempixel.com/400/600/">
</div>
</template>

<script>
import Vue from 'vue'
import Viewer from 'v-viewer'
Vue.use(Viewer)

export default {}
</script>

Run server:

node_modules/.bin/nuxt

Open http://localhost:3000, the following error will be printed:

  nuxt:render Rendering url / +0ms
{ /Users/semenov/tmp/viewtest/node_modules/viewerjs/dist/viewer.css:11
.viewer-zoom-in::before,
^

SyntaxError: Unexpected token .
    at new Script (vm.js:51:7)
    at createScript (vm.js:136:10)
    at Object.runInThisContext (vm.js:197:10)
    at Module._compile (internal/modules/cjs/loader.js:618:28)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
    at Module.load (internal/modules/cjs/loader.js:566:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
    at Function.Module._load (internal/modules/cjs/loader.js:498:3)
    at Module.require (internal/modules/cjs/loader.js:598:17)
    at require (internal/modules/cjs/helpers.js:11:18)
    at webpackUniversalModuleDefinition (/Users/semenov/tmp/viewtest/node_modules/v-viewer/dist/v-viewer.js:3:49)
    at Object.<anonymous> (/Users/semenov/tmp/viewtest/node_modules/v-viewer/dist/v-viewer.js:10:3)
    at Module._compile (internal/modules/cjs/loader.js:654:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
    at Module.load (internal/modules/cjs/loader.js:566:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:506:12) statusCode: 500, name: 'SyntaxError' }

Other notes

It is not as simple as CSS loader not being enabled. requiring css from the component script tag works fine:

<script>
require("viewerjs/dist/viewer.css")

export default {}
</script>
  • this works and will actually push CSS into the page.

viewer.view(index) not working

I've got a div element with multiple images inside.

If I do the below
var img = document.getElementById('imgdivid').$viewer; img.show(); img.view(index);

It always shows the first picture, while I want the index one to be loaded instead.

Is there any callback in show that I can use, so I can execute the view(index) once the viewer is shown?

Any idea why is that?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.