diff --git a/dist/sharect.js b/dist/sharect.js index 0b7cf18..dbdd007 100644 --- a/dist/sharect.js +++ b/dist/sharect.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Sharect=t():e.Sharect=t()}(window,function(){return function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";function o(e,t){document.getElementById("sharect-style").innerHTML=".sharect svg{fill:".concat(e,";width:").concat(t,"px;height:").concat(t,"px;}")}function r(){return!!window.getSelection().toString()}function i(e){var t=(window.getSelection().baseNode||window.getSelection().anchorNode).parentNode;return e.some(function(e){return function(e,t){if(Element.prototype.closest)return e.closest(t);Element.prototype.matches||(Element.prototype.matches=Element.prototype.matchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.oMatchesSelector||Element.prototype.webkitMatchesSelector);var n=e;do{if(n.matches(t))return n;n=n.parentNode}while(null!==n&&n.nodeType===Node.ELEMENT_NODE);return null}(t,e)})}function c(e){var t=e.iconSize,n=e.buttonMargin,o=e.arrowSize,r=e.icons,i=window.getSelection().getRangeAt(0).getBoundingClientRect(),c=t+n,u=window.pageXOffset||document.documentElement.scrollTop||document.body.scrollTop;return{top:i.top+u-c-o,left:i.left+(i.width-c*r.length)/2}}n.r(t);var u=function(e){return"line-height:0;transition:all .2s ease-in-out;background:"+e+";"},l=function(e){return"position:fixed;bottom:calc(50% - 64px);left:0;width:"+e+"px;border-top-right-radius:5px;border-bottom-right-radius:5px;"},a=function(e,t){return"position:absolute;border-radius:3px;top:"+e+"px;left:"+t+"px;"},s=function(e){var t=e.arrowSize;return"position:absolute;border-left:"+t+"px solid transparent;border-right:"+t+"px solid transparent;border-top:"+t+"px solid "+e.backgroundColor+";bottom:-"+(t-1)+"px;left:"+(e.buttonSize*e.icons.length/2-t)+"px;width:0;height:0;"};function f(e){var t=e.top,n=e.left,o=e.iconSize,r=e.mobileIconSize,i=e.buttonMargin,c=e.backgroundColor,f=e.icons,p=e.arrowSize,d=e.isMobile,b=document.createElement("div"),m=o+i;if(b.className="sharect",b.style.cssText=u(c),d?(m=r+i,b.style.cssText+=l(m)):b.style.cssText+=a(t,n),b.appendChild(f.icons),!d){var h=function(e){var t=document.createElement("div");return t.style.cssText=s(e),t}({arrowSize:p,backgroundColor:c,buttonSize:m,icons:f});b.appendChild(h)}return b}function p(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function d(e){var t=c(e),n=function(e){for(var t=1;t'},facebook:{isActive:!0,url:"https://www.facebook.com/sharer/sharer.php?u=PAGE_URL"e=TEXT_SELECTION",icon:''}},t={},n=["body"],r=[],i="#333",c="#fff",u=5,l=14,a=24,s=50;return{config:function(t){return void 0!==t.twitter&&(e.twitter.isActive=t.twitter),void 0!==t.facebook&&(e.facebook.isActive=t.facebook),t.twitterUsername&&(e.twitter.username=t.twitterUsername),t.backgroundColor&&(i=t.backgroundColor),t.iconColor&&(c=t.iconColor),t.selectableElements&&(n=t.selectableElements),this},appendCustomShareButtons:function(e){return r=e,this},init:function(){var f,p,d,b={backgroundColor:i,iconColor:c,arrowSize:u,buttonMargin:l,iconSize:a,mobileIconSize:s,selectableElements:n,networks:e,customShareButtons:r};return f=x({},b),p=f.iconColor,(d=document.createElement("style")).id="sharect-style",d.innerHTML=".sharect svg{fill:".concat(p,";}"),document.body.appendChild(d),t=function(e){var t=e.networks,n=e.customShareButtons,o=document.createElement("div"),r=0;for(var i in t)if(t[i]&&t[i].isActive){var c=t[i],u=c.icon,l=c.url,a=c.username;o.appendChild(E(u,l,a)),r++}return n.length>0&&n.forEach(function(e){o.appendChild(E(e.icon,e.url)),r++}),{icons:o,length:r}}(x({},b)),function(e){window.addEventListener("mouseup",function(){return w(e)},!1),void 0!==window.onpointerup?window.addEventListener("pointerup",function(t){return y(t,e)},!1):void 0!==window.orientation&&(h=!0,o(e))}(x({},b,{icons:t})),this}}}()}]).default}); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Sharect=t():e.Sharect=t()}(window,function(){return function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";function o(e,t){document.getElementById("sharect-style").innerHTML=".sharect svg{fill:".concat(e,";width:").concat(t,"px;height:").concat(t,"px;}")}function r(){return!!window.getSelection().toString()}function i(e){var t=(window.getSelection().baseNode||window.getSelection().anchorNode).parentNode;return e.some(function(e){return function(e,t){if(Element.prototype.closest)return e.closest(t);Element.prototype.matches||(Element.prototype.matches=Element.prototype.matchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.oMatchesSelector||Element.prototype.webkitMatchesSelector);var n=e;do{if(n.matches(t))return n;n=n.parentNode}while(null!==n&&n.nodeType===Node.ELEMENT_NODE);return null}(t,e)})}function c(e){var t=e.iconSize,n=e.buttonMargin,o=e.arrowSize,r=e.icons,i=window.getSelection().getRangeAt(0).getBoundingClientRect(),c=t+n,u=window.pageXOffset||document.documentElement.scrollTop||document.body.scrollTop;return{top:i.top+u-c-o,left:i.left+(i.width-c*r.length)/2}}n.r(t);var u=function(e){return"line-height:0;transition:all .2s ease-in-out;background:"+e+";"},l=function(e){return"position:fixed;bottom:calc(50% - 64px);left:0;width:"+e+"px;border-top-right-radius:5px;border-bottom-right-radius:5px;"},a=function(e,t){return"position:absolute;border-radius:3px;top:"+e+"px;left:"+t+"px;"},s=function(e){var t=e.arrowSize;return"position:absolute;border-left:"+t+"px solid transparent;border-right:"+t+"px solid transparent;border-top:"+t+"px solid "+e.backgroundColor+";bottom:-"+(t-1)+"px;left:"+(e.buttonSize*e.icons.length/2-t)+"px;width:0;height:0;"};function f(e){var t=e.top,n=e.left,o=e.iconSize,r=e.mobileIconSize,i=e.buttonMargin,c=e.backgroundColor,f=e.icons,p=e.arrowSize,d=e.isMobile,b=document.createElement("div"),m=o+i;if(b.className="sharect",b.style.cssText=u(c),d?(m=r+i,b.style.cssText+=l(m)):b.style.cssText+=a(t,n),b.appendChild(f.icons),!d){var h=function(e){var t=document.createElement("div");return t.style.cssText=s(e),t}({arrowSize:p,backgroundColor:c,buttonSize:m,icons:f});b.appendChild(h)}return b}function p(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function d(e){var t=c(e),n=function(e){for(var t=1;t'},facebook:{isActive:!0,url:"https://www.facebook.com/sharer/sharer.php?u=PAGE_URL"e=TEXT_SELECTION",icon:''}},t={},n=["body"],r=[],i="#333",c="#fff",u=5,l=14,a=24,s=50;return{config:function(t){return void 0!==t.twitter&&(e.twitter.isActive=t.twitter),void 0!==t.facebook&&(e.facebook.isActive=t.facebook),t.twitterUsername&&(e.twitter.username=t.twitterUsername),t.backgroundColor&&(i=t.backgroundColor),t.iconColor&&(c=t.iconColor),t.selectableElements&&(n=t.selectableElements),this},appendCustomShareButtons:function(e){return r=e,this},init:function(){var f,p,d,b={backgroundColor:i,iconColor:c,arrowSize:u,buttonMargin:l,iconSize:a,mobileIconSize:s,selectableElements:n,networks:e,customShareButtons:r};return f=x({},b),p=f.iconColor,(d=document.createElement("style")).id="sharect-style",d.innerHTML=".sharect svg{fill:".concat(p,";}"),document.body.appendChild(d),t=function(e){var t=e.networks,n=e.customShareButtons,o=document.createElement("div"),r=0;for(var i in t)if(t[i]&&t[i].isActive){var c=t[i],u=c.icon,l=c.url,a=c.username;o.appendChild(E(u,l,a)),r++}return n.length>0&&n.forEach(function(e){o.appendChild(E(e.icon,e.url)),r++}),{icons:o,length:r}}(x({},b)),function(e){window.addEventListener("mouseup",function(){return w(e)},!1),void 0!==window.onpointerup?window.addEventListener("pointerup",function(t){return y(t,e)},!1):void 0!==window.orientation&&(h=!0,o(e))}(x({},b,{icons:t})),this}}}()}]).default}); \ No newline at end of file diff --git a/src/helpers/attachEvents.js b/src/helpers/attachEvents.js index b60afa2..721d20d 100644 --- a/src/helpers/attachEvents.js +++ b/src/helpers/attachEvents.js @@ -14,7 +14,7 @@ function handleMouseUp(props) { moveTooltip({ ...props, isMobile }) return } else { - document.querySelector('.sharect').remove() + document.body.removeChild(document.querySelector('.sharect')) } } if (hasSelection() && isSelectableElement(props.selectableElements)) {