UNPKG

2.38 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, '__esModule', { value: true });
4
5const index = require('./index-a0a08b2a.js');
6const ionicGlobal = require('./ionic-global-06f21c1a.js');
7const gestureController = require('./gesture-controller-29adda71.js');
8
9const backdropIosCss = ":host{left:0;right:0;top:0;bottom:0;display:block;position:absolute;-webkit-transform:translateZ(0);transform:translateZ(0);contain:strict;cursor:pointer;opacity:0.01;-ms-touch-action:none;touch-action:none;z-index:2}:host(.backdrop-hide){background:transparent}:host(.backdrop-no-tappable){cursor:auto}:host{background-color:var(--ion-backdrop-color, #000)}";
10
11const backdropMdCss = ":host{left:0;right:0;top:0;bottom:0;display:block;position:absolute;-webkit-transform:translateZ(0);transform:translateZ(0);contain:strict;cursor:pointer;opacity:0.01;-ms-touch-action:none;touch-action:none;z-index:2}:host(.backdrop-hide){background:transparent}:host(.backdrop-no-tappable){cursor:auto}:host{background-color:var(--ion-backdrop-color, #000)}";
12
13const Backdrop = class {
14 constructor(hostRef) {
15 index.registerInstance(this, hostRef);
16 this.ionBackdropTap = index.createEvent(this, "ionBackdropTap", 7);
17 this.blocker = gestureController.GESTURE_CONTROLLER.createBlocker({
18 disableScroll: true
19 });
20 /**
21 * If `true`, the backdrop will be visible.
22 */
23 this.visible = true;
24 /**
25 * If `true`, the backdrop will can be clicked and will emit the `ionBackdropTap` event.
26 */
27 this.tappable = true;
28 /**
29 * If `true`, the backdrop will stop propagation on tap.
30 */
31 this.stopPropagation = true;
32 }
33 connectedCallback() {
34 if (this.stopPropagation) {
35 this.blocker.block();
36 }
37 }
38 disconnectedCallback() {
39 this.blocker.unblock();
40 }
41 onMouseDown(ev) {
42 this.emitTap(ev);
43 }
44 emitTap(ev) {
45 if (this.stopPropagation) {
46 ev.preventDefault();
47 ev.stopPropagation();
48 }
49 if (this.tappable) {
50 this.ionBackdropTap.emit();
51 }
52 }
53 render() {
54 const mode = ionicGlobal.getIonMode(this);
55 return (index.h(index.Host, { tabindex: "-1", "aria-hidden": "true", class: {
56 [mode]: true,
57 'backdrop-hide': !this.visible,
58 'backdrop-no-tappable': !this.tappable,
59 } }));
60 }
61};
62Backdrop.style = {
63 ios: backdropIosCss,
64 md: backdropMdCss
65};
66
67exports.ion_backdrop = Backdrop;