UNPKG

vue-light-popup

Version:
2 lines 6.26 kB
(function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t(require("vue")):"function"===typeof define&&define.amd?define([],t):"object"===typeof exports?exports["vue-light-popup"]=t(require("vue")):e["vue-light-popup"]=t(e["Vue"])})("undefined"!==typeof self?self:this,(function(e){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="fb15")}({8875:function(e,t,n){var o,r,i;(function(n,c){r=[],o=c,i="function"===typeof o?o.apply(t,r):o,void 0===i||(e.exports=i)})("undefined"!==typeof self&&self,(function(){function e(){var t=Object.getOwnPropertyDescriptor(document,"currentScript");if(!t&&"currentScript"in document&&document.currentScript)return document.currentScript;if(t&&t.get!==e&&document.currentScript)return document.currentScript;try{throw new Error}catch(p){var n,o,r,i=/.*at [^(]*\((.*):(.+):(.+)\)$/gi,c=/@([^@]*):(\d+):(\d+)\s*$/gi,u=i.exec(p.stack)||c.exec(p.stack),l=u&&u[1]||!1,d=u&&u[2]||!1,a=document.location.href.replace(document.location.hash,""),f=document.getElementsByTagName("script");l===a&&(n=document.documentElement.outerHTML,o=new RegExp("(?:[^\\n]+?\\n){0,"+(d-2)+"}[^<]*<script>([\\d\\D]*?)<\\/script>[\\d\\D]*","i"),r=n.replace(o,"$1").trim());for(var s=0;s<f.length;s++){if("interactive"===f[s].readyState)return f[s];if(f[s].src===l)return f[s];if(l===a&&f[s].innerHTML&&f[s].innerHTML.trim()===r)return f[s]}return null}}return e}))},"8bbf":function(t,n){t.exports=e},fb15:function(e,t,n){"use strict";if(n.r(t),"undefined"!==typeof window){var o=window.document.currentScript,r=n("8875");o=r(),"currentScript"in document||Object.defineProperty(document,"currentScript",{get:r});var i=o&&o.src.match(/(.+\/)[^/]+\.js(\?.*)?$/);i&&(n.p=i[1])}var c=n("8bbf");function u(e,t,n,o,r,i){return Object(c["withDirectives"])((Object(c["openBlock"])(),Object(c["createBlock"])("div",{class:"vue-light-popup",onClick:t[2]||(t[2]=Object(c["withModifiers"])((function(){return e.closePopup&&e.closePopup.apply(e,arguments)}),["stop"])),style:e.rootStyle},[Object(c["createVNode"])("div",{class:"vue-light-popup__content",ref:"scrollContent",style:e.contentStyle},[Object(c["createVNode"])("div",{class:"vue-light-popup__wrapper",onClick:t[1]||(t[1]=Object(c["withModifiers"])((function(){return!1}),["stop"])),style:e.wrapperStyle},[Object(c["renderSlot"])(e.$slots,"default")],4)],4)],4)),[[c["vShow"],e.show]])}function l(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}var d=!1;if("undefined"!==typeof window){var a={get passive(){d=!0}};window.addEventListener("testPassive",null,a),window.removeEventListener("testPassive",null,a)}var f="undefined"!==typeof window&&window.navigator&&window.navigator.platform&&(/iP(ad|hone|od)/.test(window.navigator.platform)||"MacIntel"===window.navigator.platform&&window.navigator.maxTouchPoints>1),s=[],p=!1,v=-1,m=void 0,g=void 0,h=function(e){return s.some((function(t){return!(!t.options.allowTouchMove||!t.options.allowTouchMove(e))}))},y=function(e){var t=e||window.event;return!!h(t.target)||(t.touches.length>1||(t.preventDefault&&t.preventDefault(),!1))},b=function(e){if(void 0===g){var t=!!e&&!0===e.reserveScrollBarGap,n=window.innerWidth-document.documentElement.clientWidth;t&&n>0&&(g=document.body.style.paddingRight,document.body.style.paddingRight=n+"px")}void 0===m&&(m=document.body.style.overflow,document.body.style.overflow="hidden")},w=function(){void 0!==g&&(document.body.style.paddingRight=g,g=void 0),void 0!==m&&(document.body.style.overflow=m,m=void 0)},S=function(e){return!!e&&e.scrollHeight-e.scrollTop<=e.clientHeight},j=function(e,t){var n=e.targetTouches[0].clientY-v;return!h(e.target)&&(t&&0===t.scrollTop&&n>0||S(t)&&n<0?y(e):(e.stopPropagation(),!0))},O=function(e,t){if(e){if(!s.some((function(t){return t.targetElement===e}))){var n={targetElement:e,options:t||{}};s=[].concat(l(s),[n]),f?(e.ontouchstart=function(e){1===e.targetTouches.length&&(v=e.targetTouches[0].clientY)},e.ontouchmove=function(t){1===t.targetTouches.length&&j(t,e)},p||(document.addEventListener("touchmove",y,d?{passive:!1}:void 0),p=!0)):b(t)}}else console.error("disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.")},x=function(e){e?(s=s.filter((function(t){return t.targetElement!==e})),f?(e.ontouchstart=null,e.ontouchmove=null,p&&0===s.length&&(document.removeEventListener("touchmove",y,d?{passive:!1}:void 0),p=!1)):s.length||w()):console.error("enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.")},P=Object(c["defineComponent"])({name:"VueLightPopup",emits:["close"],setup:function(e,t){var n=t.emit,o=Object(c["ref"])(!1),r=Object(c["ref"])();return Object(c["onMounted"])((function(){O(r.value,{reserveScrollBarGap:!0}),Object(c["nextTick"])((function(){o.value=!0}))})),Object(c["onBeforeUnmount"])((function(){x(r.value)})),{show:o,scrollContent:r,closePopup:function(){n("close")},rootStyle:{position:"fixed",left:"0",top:"0",width:"100%",height:"100vh",background:"rgba(0, 0, 0, .5)",display:"flex",alignItems:"center",zIndex:"1000"},contentStyle:{width:"100%",maxHeight:"100%",overflow:"auto","-webkit-overflow-scrolling":"touch"},wrapperStyle:{maxWidth:"100%",margin:"auto"}}}});P.render=u;var T=P;t["default"]=T}})["default"]})); //# sourceMappingURL=vue-light-popup.umd.min.js.map