hevue-img-preview
Advanced tools
Comparing version 0.0.3 to 0.0.4
{ | ||
"name": "hevue-img-preview", | ||
"description": "基于vue.js的图片预览组件", | ||
"version": "0.0.3", | ||
"description": "一个基于vue的图片预览组件", | ||
"version": "0.0.4", | ||
"author": "贺永胜 <1378431028@qq.com>", | ||
"license": "MIT", | ||
"private": false, | ||
"main": "dist/vue-toast-c.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/heyongsheng/hevue-img-preview" | ||
}, | ||
"scripts": { | ||
@@ -9,0 +14,0 @@ "dev": "cross-env NODE_ENV=development webpack-dev-server --open --hot", |
# hevue-img-preview | ||
> 基于vue.js的图片预览组件 | ||
> 一个基于vue的图片预览组件 | ||
@@ -5,0 +5,0 @@ ## Build Setup |
@@ -1,15 +0,65 @@ | ||
import vueImgPreview from './hevue-img-preview.vue' // 导入组件 | ||
const paykeyboard = { | ||
install (Vue, options) { | ||
Vue.component(vueImgPreview.name, vueImgPreview) // vuePayKeyboard.name 组件的name属性 | ||
// 类似通过 this.$xxx 方式调用插件的 其实只是挂载到原型上而已 | ||
// Vue.prototype.$xxx // 最终可以在任何地方通过 this.$xxx 调用 | ||
// 虽然没有明确规定用$开头 但是大家都默认遵守这个规定 | ||
import Vue from 'vue' | ||
import VueToast from './hevue-img-preview.vue' | ||
const ToastConstructor = Vue.extend(VueToast) | ||
const instance = new ToastConstructor().$mount() | ||
const pageScroll = (() => { | ||
const fn = (e) => { | ||
let evt = e || window.event | ||
evt.preventDefault() | ||
evt.stopPropagation() | ||
} | ||
let islock = false | ||
return { | ||
lock (el) { | ||
if (islock) return | ||
islock = true; | ||
(el || document).addEventListener('mousewheel', fn); | ||
(el || document).addEventListener('touchmove', fn) | ||
}, | ||
unlock (el) { | ||
islock = false; | ||
(el || document).removeEventListener('mousewheel', fn); | ||
(el || document).removeEventListener('touchmove', fn) | ||
} | ||
} | ||
})() | ||
ToastConstructor.prototype.closeToast = function () { | ||
const el = instance.$el | ||
el.parentNode && el.parentNode.removeChild(el) | ||
//恢复滚动 | ||
pageScroll.unlock() | ||
typeof this.callback === 'function' && this.callback() | ||
} | ||
// 新增 | ||
const Toast = (options = {}) => { | ||
instance.mes = options.mes || '正在开发中……' | ||
instance.timeout = ~~options.timeout || 2000 | ||
instance.callback = options.callback | ||
document.body.appendChild(instance.$el) | ||
//禁止滚动 | ||
pageScroll.lock() | ||
// 定时关闭 | ||
const timer = setTimeout(() => { | ||
clearTimeout(timer) | ||
instance.closeToast() | ||
}, instance.timeout + 100) | ||
} | ||
const install = (Vue) => { | ||
Vue.prototype.$hevueImgPreview = Toast | ||
} | ||
if (typeof window !== 'undefined' && window.Vue) { | ||
window.Vue.use(paykeyboard) | ||
window.Vue.use(install) | ||
} | ||
export default paykeyboard // 导出 | ||
export default install |
import Vue from 'vue' | ||
import App from './App.vue' | ||
import hevueImgPreview from './lib/index.js' | ||
Vue.use(hevueImgPreview) | ||
new Vue({ | ||
@@ -5,0 +8,0 @@ el: '#app', |
@@ -11,2 +11,3 @@ var path = require('path') | ||
filename: 'hevue-img-preview.js', | ||
library: 'hevueImgPreview', | ||
libraryTarget: 'umd', | ||
@@ -13,0 +14,0 @@ umdNamedDefine: true |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
1044226
579
1
1