diff --git a/Loading/index.js b/Loading/index.js index 780de8a..4e1cb53 100644 --- a/Loading/index.js +++ b/Loading/index.js @@ -6,6 +6,7 @@ const containerStyle = { alignItems: 'center', background: 'white', color: 'black', + height: '-webkit-fill-available' } class LoadingContainer extends Component { diff --git a/README.md b/README.md index 6765175..40cac19 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,14 @@ -### watermark-enhancer +## watermark-enhancer +> Add watermark to your react components in a more elegent way. + +![](https://img.shields.io/npm/l/watermark-enhancer) +![](https://img.shields.io/npm/dt/watermark-enhancer) +![](https://img.shields.io/bundlephobia/minzip/watermark-enhancer?label=package%20size) + ![case](https://cdn.fatdoge.cn/watermark-enhancer-user.png)![case](https://cdn.fatdoge.cn/watermark-enhancer-view.png) > 移步[详细文档](https://fatdoge.github.io/watermark-enhancer) + 1.安装 ``` npm i watermark-enhancer -d diff --git a/WaterMark/index.js b/WaterMark/index.js index 834c6de..c432de6 100644 --- a/WaterMark/index.js +++ b/WaterMark/index.js @@ -42,7 +42,6 @@ const watermark = ({ const base64Url = canvas.toDataURL(); const __wm = document.querySelector('.__wm'); - const watermarkDiv = __wm || document.createElement("div"); const styleStr = ` position:absolute; @@ -67,6 +66,7 @@ const watermark = ({ if (MutationObserver) { let mo = new MutationObserver(function () { const __wm = document.querySelector('.__wm'); + console.log(__wm) // 只在__wm元素变动才重新调用 __canvasWM if ((__wm && __wm.getAttribute('style') !== styleStr) || !__wm) { // 避免一直触发 diff --git a/dist/index.js b/dist/index.js index 4b12c0f..c268a3d 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1 +1 @@ -module.exports=function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=1)}([function(t,e){t.exports=require("react")},function(t,e,n){"use strict";n.r(e);var r=n(0),o=n.n(r),i=function t(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.container,r=void 0===n?document.body:n,o=e.width,i=void 0===o?"300px":o,c=e.height,u=void 0===c?"200px":c,a=e.textAlign,f=void 0===a?"left":a,l=e.textBaseline,s=void 0===l?"bottom":l,p=e.font,y=void 0===p?"20px Microsoft Yahei":p,b=e.fillStyle,d=void 0===b?"rgba(184, 184, 184, 0.4)":b,v=e.content,m=void 0===v?"loading":v,h=e.rotate,O=void 0===h?"24":h,g=e.zIndex,w=void 0===g?1e3:g,j=arguments.length,S=new Array(j>1?j-1:0),P=1;P=0||(o[n]=t[n]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(o[n]=t[n])}return o}function m(t){for(var e=1;e0&&void 0!==arguments[0]?arguments[0]:{content:content,asyncContent:asyncContent},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{content:content};return function(n){return function(c){function u(e){var n;return w(this,u),(n=P(this,_(u).call(this,e))).state={options:t,content:""},n.waterMark=o.a.createRef(),n}return x(u,r.Component),S(u,[{key:"componentDidMount",value:(a=g(regeneratorRuntime.mark(function e(){var n,r,o;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(n=this.state.options,"function"!=typeof(r=t.asyncContent)){e.next=9;break}return e.next=5,r();case 5:return o=e.sent,this.setState({content:o}),i(m({},n,{content:o,container:this.waterMark.current})),e.abrupt("return");case 9:i(m({},n,{container:this.waterMark.current}));case 10:case"end":return e.stop()}},e,this)})),function(){return a.apply(this,arguments)})},{key:"render",value:function(){var r=this.state.content,i=t.asyncContent,c=e.content,u=v(e,["content"]);return o.a.createElement("div",{ref:this.waterMark},i&&!r?o.a.createElement(b,{loadingStyle:u,loadingContent:c}):o.a.createElement(n,this.props))}}]),u;var a}()}}}]); \ No newline at end of file +module.exports=function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=1)}([function(t,e){t.exports=require("react")},function(t,e,n){"use strict";n.r(e);var r=n(0),o=n.n(r),i=function t(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.container,r=void 0===n?document.body:n,o=e.width,i=void 0===o?"300px":o,c=e.height,u=void 0===c?"200px":c,a=e.textAlign,l=void 0===a?"left":a,f=e.textBaseline,s=void 0===f?"bottom":f,p=e.font,y=void 0===p?"20px Microsoft Yahei":p,b=e.fillStyle,d=void 0===b?"rgba(184, 184, 184, 0.4)":b,v=e.content,h=void 0===v?"loading":v,m=e.rotate,g=void 0===m?"24":m,O=e.zIndex,w=void 0===O?1e3:O,j=arguments.length,S=new Array(j>1?j-1:0),P=1;P=0||(o[n]=t[n]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(o[n]=t[n])}return o}function h(t){for(var e=1;e0&&void 0!==arguments[0]?arguments[0]:{content:content,asyncContent:asyncContent},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{content:content};return function(n){return function(c){function u(e){var n;return w(this,u),(n=P(this,_(u).call(this,e))).state={options:t,content:""},n.waterMark=o.a.createRef(),n}return x(u,r.Component),S(u,[{key:"componentDidMount",value:(a=O(regeneratorRuntime.mark(function e(){var n,r,o;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(n=this.state.options,"function"!=typeof(r=t.asyncContent)){e.next=9;break}return e.next=5,r();case 5:return o=e.sent,this.setState({content:o}),i(h({},n,{content:o,container:this.waterMark.current})),e.abrupt("return");case 9:i(h({},n,{container:this.waterMark.current}));case 10:case"end":return e.stop()}},e,this)})),function(){return a.apply(this,arguments)})},{key:"render",value:function(){var r=this.state.content,i=t.asyncContent,c=e.content,u=v(e,["content"]);return o.a.createElement("div",{ref:this.waterMark,id:+new Date},i&&!r?o.a.createElement(b,{loadingStyle:u,loadingContent:c}):o.a.createElement(n,this.props))}}]),u;var a}()}}}]); \ No newline at end of file