Comparing version 1.2.1 to 1.3.0
@@ -102,12 +102,11 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
function createViewer(el, binding) { | ||
var createViewer = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1_throttle_debounce__["a" /* debounce */])(50, function (el, options) { | ||
Vue.nextTick(function () { | ||
destroyViewer(el); | ||
var options = binding.value; | ||
el['$' + name] = new __WEBPACK_IMPORTED_MODULE_0_viewerjs___default.a(el, options); | ||
log('viewer created'); | ||
}); | ||
} | ||
}); | ||
function createObserver(el, binding, debouncedCreateViewer) { | ||
function createObserver(el, binding) { | ||
destroyObserver(el); | ||
@@ -118,3 +117,3 @@ var MutationObserver = global.MutationObserver || global.WebKitMutationObserver || global.MozMutationObserver; | ||
log('viewer mutation:' + mutation.type); | ||
debouncedCreateViewer(el, binding); | ||
createViewer(el, binding.value); | ||
}); | ||
@@ -151,9 +150,16 @@ }); | ||
Vue.directive('viewer', { | ||
bind: function bind(el, binding) { | ||
bind: function bind(el, binding, vnode) { | ||
log('viewer bind'); | ||
var debouncedCreateViewer = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1_throttle_debounce__["a" /* debounce */])(50, createViewer); | ||
debouncedCreateViewer(el, binding); | ||
createViewer(el, binding.value); | ||
el['$viewerUnwatch'] = vnode.context.$watch(binding.expression, function (newVal, oldVal) { | ||
this.$nextTick(function () { | ||
createViewer(el, newVal); | ||
}); | ||
}, { | ||
deep: true | ||
}); | ||
if (!binding.modifiers.static) { | ||
createObserver(el, binding, debouncedCreateViewer); | ||
createObserver(el, binding); | ||
} | ||
@@ -167,2 +173,3 @@ }, | ||
destroyViewer(el); | ||
el['$viewerUnwatch'] && el['$viewerUnwatch'](); | ||
} | ||
@@ -229,3 +236,3 @@ }); | ||
) | ||
Component.options.__file = "D:\\Workspaces\\Web\\Git\\v-viewer\\src\\component.vue" | ||
Component.options.__file = "D:\\Workspaces\\Git\\v-viewer\\src\\component.vue" | ||
if (Component.esModule && Object.keys(Component.esModule).some(function (key) {return key !== "default" && key !== "__esModule"})) {console.error("named exports are not supported in *.vue files.")} | ||
@@ -232,0 +239,0 @@ if (Component.options.functional) {console.error("[vue-loader] component.vue: functional components are not supported with templates, they should use render functions.")} |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("viewerjs")):"function"==typeof define&&define.amd?define(["viewerjs"],t):"object"==typeof exports?exports.VueViewer=t(require("viewerjs")):e.VueViewer=t(e.Viewer)}(this,function(e){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=4)}([function(t,n){t.exports=e},function(e,t,n){"use strict";(function(e){var r=n(0),o=n.n(r),i=n(5),u=function(t,r){function u(e,n){t.nextTick(function(){s(e);var t=n.value;e["$"+v]=new o.a(e,t),f("viewer created")})}function c(t,n,r){a(t);var o=e.MutationObserver||e.WebKitMutationObserver||e.MozMutationObserver,i=new o(function(e){e.forEach(function(e){f("viewer mutation:"+e.type),r(t,n)})}),u={attributes:!0,childList:!0,characterData:!0,subtree:!0};i.observe(t,u),t.$viewerMutationObserver=i,f("observer created")}function s(e){e["$"+v]&&(e["$"+v].destroy(),delete e["$"+v],f("viewer destroyed"))}function a(e){e.$viewerMutationObserver&&(e.$viewerMutationObserver.disconnect(),delete e.$viewerMutationObserver,f("observer destroyed"))}function f(e){p&&console.log(e)}var d=r.name,v=void 0===d?"viewer":d,l=r.debug,p=void 0!==l&&l;t.directive("viewer",{bind:function(e,t){f("viewer bind");var r=n.i(i.a)(50,u);r(e,t),t.modifiers.static||c(e,t,r)},unbind:function(e,t){f("viewer unbind"),a(e),s(e)}})};t.a={install:u}}).call(t,n(7))},function(e,t,n){"use strict";function r(){var e={},t=!1,n=0,o=arguments.length;for("[object Boolean]"===Object.prototype.toString.call(arguments[0])&&(t=arguments[0],n++);n<o;n++){var i=arguments[n];!function(n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t&&"[object Object]"===Object.prototype.toString.call(n[o])?e[o]=r(!0,e[o],n[o]):e[o]=n[o])}(i)}return e}t.a=r},function(e,t,n){var r=n(8)(n(6),n(9),null,null);e.exports=r.exports},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(2),o=n(3),i=n.n(o),u=n(1),c=n(0),s=n.n(c);t.default={install:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=t.name,c=void 0===o?"viewer":o,a=t.debug,f=void 0!==a&&a,d=t.defaultOptions;s.a.setDefaults(d),e.component(c,n.i(r.a)(i.a,{name:c})),e.use(u.a,{name:c,debug:f})},setDefaults:function(e){s.a.setDefaults(e)}}},function(e,t,n){"use strict";function r(e,t,n,r){function o(){function o(){u=Number(new Date),n.apply(s,f)}function c(){i=void 0}var s=this,a=Number(new Date)-u,f=arguments;r&&!i&&o(),i&&clearTimeout(i),void 0===r&&a>e?o():!0!==t&&(i=setTimeout(r?c:o,void 0===r?e-a:e))}var i,u=0;return"boolean"!=typeof t&&(r=n,n=t,t=void 0),o}function o(e,t,n){return void 0===n?r(e,t,!1):r(e,n,!1!==t)}n.d(t,"a",function(){return o})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),o=n.n(r);t.default={props:{images:{type:Array},trigger:{},options:{type:Object}},data:function(){return{}},computed:{},methods:{createViewer:function(){this.$viewer&&this.$viewer.destroy(),this.$viewer=new o.a(this.$el,this.options),this.$emit("inited",this.$viewer)}},watch:{images:function(){var e=this;this.$nextTick(function(){e.createViewer()})},trigger:{handler:function(){var e=this;this.$nextTick(function(){e.createViewer()})},deep:!0},options:{handler:function(){var e=this;this.$nextTick(function(){e.createViewer()})},deep:!0}},mounted:function(){this.createViewer()},destroyed:function(){this.$viewer&&this.$viewer.destroy()}}},function(e,t){var n,r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(e){"object"===("undefined"==typeof window?"undefined":r(window))&&(n=window)}e.exports=n},function(e,t){e.exports=function(e,t,n,r){var o,i=e=e||{},u=typeof e.default;"object"!==u&&"function"!==u||(o=e,i=e.default);var c="function"==typeof i?i.options:i;if(t&&(c.render=t.render,c.staticRenderFns=t.staticRenderFns),n&&(c._scopeId=n),r){var s=Object.create(c.computed||null);Object.keys(r).forEach(function(e){var t=r[e];s[e]=function(){return t}}),c.computed=s}return{esModule:o,exports:i,options:c}}},function(e,t){e.exports={render:function(){var e=this,t=e.$createElement;return(e._self._c||t)("div",[e._t("default",null,{images:e.images,options:e.options})],2)},staticRenderFns:[]}}])}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("viewerjs")):"function"==typeof define&&define.amd?define(["viewerjs"],t):"object"==typeof exports?exports.VueViewer=t(require("viewerjs")):e.VueViewer=t(e.Viewer)}(this,function(e){return function(e){function t(i){if(n[i])return n[i].exports;var r=n[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,i){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:i})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=4)}([function(t,n){t.exports=e},function(e,t,n){"use strict";(function(e){var i=n(0),r=n.n(i),o=n(5),u=function(t,i){function u(t,n){s(t);var i=e.MutationObserver||e.WebKitMutationObserver||e.MozMutationObserver,r=new i(function(e){e.forEach(function(e){a("viewer mutation:"+e.type),p(t,n.value)})}),o={attributes:!0,childList:!0,characterData:!0,subtree:!0};r.observe(t,o),t.$viewerMutationObserver=r,a("observer created")}function c(e){e["$"+d]&&(e["$"+d].destroy(),delete e["$"+d],a("viewer destroyed"))}function s(e){e.$viewerMutationObserver&&(e.$viewerMutationObserver.disconnect(),delete e.$viewerMutationObserver,a("observer destroyed"))}function a(e){l&&console.log(e)}var f=i.name,d=void 0===f?"viewer":f,v=i.debug,l=void 0!==v&&v,p=n.i(o.a)(50,function(e,n){t.nextTick(function(){c(e),e["$"+d]=new r.a(e,n),a("viewer created")})});t.directive("viewer",{bind:function(e,t,n){a("viewer bind"),p(e,t.value),e.$viewerUnwatch=n.context.$watch(t.expression,function(t,n){this.$nextTick(function(){p(e,t)})},{deep:!0}),t.modifiers.static||u(e,t)},unbind:function(e,t){a("viewer unbind"),s(e),c(e),e.$viewerUnwatch&&e.$viewerUnwatch()}})};t.a={install:u}}).call(t,n(7))},function(e,t,n){"use strict";function i(){var e={},t=!1,n=0,r=arguments.length;for("[object Boolean]"===Object.prototype.toString.call(arguments[0])&&(t=arguments[0],n++);n<r;n++){var o=arguments[n];!function(n){for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t&&"[object Object]"===Object.prototype.toString.call(n[r])?e[r]=i(!0,e[r],n[r]):e[r]=n[r])}(o)}return e}t.a=i},function(e,t,n){var i=n(8)(n(6),n(9),null,null);e.exports=i.exports},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(2),r=n(3),o=n.n(r),u=n(1),c=n(0),s=n.n(c);t.default={install:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.name,c=void 0===r?"viewer":r,a=t.debug,f=void 0!==a&&a,d=t.defaultOptions;s.a.setDefaults(d),e.component(c,n.i(i.a)(o.a,{name:c})),e.use(u.a,{name:c,debug:f})},setDefaults:function(e){s.a.setDefaults(e)}}},function(e,t,n){"use strict";function i(e,t,n,i){function r(){function r(){u=Number(new Date),n.apply(s,f)}function c(){o=void 0}var s=this,a=Number(new Date)-u,f=arguments;i&&!o&&r(),o&&clearTimeout(o),void 0===i&&a>e?r():!0!==t&&(o=setTimeout(i?c:r,void 0===i?e-a:e))}var o,u=0;return"boolean"!=typeof t&&(i=n,n=t,t=void 0),r}function r(e,t,n){return void 0===n?i(e,t,!1):i(e,n,!1!==t)}n.d(t,"a",function(){return r})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(0),r=n.n(i);t.default={props:{images:{type:Array},trigger:{},options:{type:Object}},data:function(){return{}},computed:{},methods:{createViewer:function(){this.$viewer&&this.$viewer.destroy(),this.$viewer=new r.a(this.$el,this.options),this.$emit("inited",this.$viewer)}},watch:{images:function(){var e=this;this.$nextTick(function(){e.createViewer()})},trigger:{handler:function(){var e=this;this.$nextTick(function(){e.createViewer()})},deep:!0},options:{handler:function(){var e=this;this.$nextTick(function(){e.createViewer()})},deep:!0}},mounted:function(){this.createViewer()},destroyed:function(){this.$viewer&&this.$viewer.destroy()}}},function(e,t){var n,i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(e){"object"===("undefined"==typeof window?"undefined":i(window))&&(n=window)}e.exports=n},function(e,t){e.exports=function(e,t,n,i){var r,o=e=e||{},u=typeof e.default;"object"!==u&&"function"!==u||(r=e,o=e.default);var c="function"==typeof o?o.options:o;if(t&&(c.render=t.render,c.staticRenderFns=t.staticRenderFns),n&&(c._scopeId=n),i){var s=Object.create(c.computed||null);Object.keys(i).forEach(function(e){var t=i[e];s[e]=function(){return t}}),c.computed=s}return{esModule:r,exports:o,options:c}}},function(e,t){e.exports={render:function(){var e=this,t=e.$createElement;return(e._self._c||t)("div",[e._t("default",null,{images:e.images,options:e.options})],2)},staticRenderFns:[]}}])}); |
{ | ||
"name": "v-viewer", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"description": "Image viewer component for vue, supports rotation, scale, zoom and so on, based on viewer.js", | ||
@@ -5,0 +5,0 @@ "main": "dist/v-viewer.js", |
@@ -6,3 +6,3 @@ # v-viewer | ||
## [Live demo](https://mirari.github.io/v-viewer/) | ||
## [Live demo](http://mirari.github.io/v-viewer/) | ||
@@ -13,3 +13,3 @@ ## Quick Example | ||
## [中文文档](https://mirari.cc/2017/08/27/Vue%E5%9B%BE%E7%89%87%E6%B5%8F%E8%A7%88%E7%BB%84%E4%BB%B6v-viewer%EF%BC%8C%E6%94%AF%E6%8C%81%E6%97%8B%E8%BD%AC%E3%80%81%E7%BC%A9%E6%94%BE%E3%80%81%E7%BF%BB%E8%BD%AC%E7%AD%89%E6%93%8D%E4%BD%9C/) | ||
## [中文文档](http://mirari.cc/2017/08/27/Vue%E5%9B%BE%E7%89%87%E6%B5%8F%E8%A7%88%E7%BB%84%E4%BB%B6v-viewer%EF%BC%8C%E6%94%AF%E6%8C%81%E6%97%8B%E8%BD%AC%E3%80%81%E7%BC%A9%E6%94%BE%E3%80%81%E7%BF%BB%E8%BD%AC%E7%AD%89%E6%93%8D%E4%BD%9C/) | ||
@@ -16,0 +16,0 @@ ## Migration from 0.x |
@@ -5,13 +5,13 @@ import Viewer from 'viewerjs' | ||
const install = (Vue, {name = 'viewer', debug = false}) => { | ||
function createViewer (el, binding) { | ||
// 使用去抖避免不必要的大量突发重建 | ||
const createViewer = debounce(50, (el, options) => { | ||
// nextTick执行,否则可能漏掉未渲染完的子元素 | ||
Vue.nextTick(() => { | ||
destroyViewer(el) | ||
const options = binding.value | ||
el[`$${name}`] = new Viewer(el, options) | ||
log('viewer created') | ||
}) | ||
} | ||
}) | ||
function createObserver (el, binding, debouncedCreateViewer) { | ||
function createObserver (el, binding) { | ||
destroyObserver(el) | ||
@@ -22,3 +22,3 @@ const MutationObserver = global.MutationObserver || global.WebKitMutationObserver || global.MozMutationObserver | ||
log('viewer mutation:' + mutation.type) | ||
debouncedCreateViewer(el, binding) | ||
createViewer(el, binding.value) | ||
}) | ||
@@ -55,6 +55,13 @@ }) | ||
Vue.directive('viewer', { | ||
bind (el, binding) { | ||
bind (el, binding, vnode) { | ||
log('viewer bind') | ||
const debouncedCreateViewer = debounce(50, createViewer) | ||
debouncedCreateViewer(el, binding) | ||
createViewer(el, binding.value) | ||
// 创建watch监听options变化 | ||
el['$viewerUnwatch'] = vnode.context.$watch(binding.expression, function (newVal, oldVal) { | ||
this.$nextTick(() => { | ||
createViewer(el, newVal) | ||
}) | ||
}, { | ||
deep: true | ||
}) | ||
@@ -64,3 +71,3 @@ // 是否监听变化 | ||
// 增加dom变化监听 | ||
createObserver(el, binding, debouncedCreateViewer) | ||
createObserver(el, binding) | ||
} | ||
@@ -74,2 +81,3 @@ }, | ||
destroyViewer(el) | ||
el['$viewerUnwatch'] && el['$viewerUnwatch']() | ||
} | ||
@@ -76,0 +84,0 @@ }) |
@@ -0,0 +0,0 @@ import {extend} from './utils' |
@@ -0,0 +0,0 @@ // 实现jquery对象继承,支持深拷贝 |
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
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
547
255217