1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | import { __extends } from "tslib";
|
24 | import { MDCComponent } from '@material/base/component';
|
25 | import { applyPassive } from '@material/dom/events';
|
26 | import { matches } from '@material/dom/ponyfill';
|
27 | import { MDCRippleFoundation } from './foundation';
|
28 | import * as util from './util';
|
29 | var MDCRipple = (function (_super) {
|
30 | __extends(MDCRipple, _super);
|
31 | function MDCRipple() {
|
32 | var _this = _super !== null && _super.apply(this, arguments) || this;
|
33 | _this.disabled = false;
|
34 | return _this;
|
35 | }
|
36 | MDCRipple.attachTo = function (root, opts) {
|
37 | if (opts === void 0) { opts = {
|
38 | isUnbounded: undefined
|
39 | }; }
|
40 | var ripple = new MDCRipple(root);
|
41 |
|
42 | if (opts.isUnbounded !== undefined) {
|
43 | ripple.unbounded = opts.isUnbounded;
|
44 | }
|
45 | return ripple;
|
46 | };
|
47 | MDCRipple.createAdapter = function (instance) {
|
48 | return {
|
49 | addClass: function (className) { return instance.root.classList.add(className); },
|
50 | browserSupportsCssVars: function () { return util.supportsCssVariables(window); },
|
51 | computeBoundingRect: function () { return instance.root.getBoundingClientRect(); },
|
52 | containsEventTarget: function (target) { return instance.root.contains(target); },
|
53 | deregisterDocumentInteractionHandler: function (evtType, handler) {
|
54 | return document.documentElement.removeEventListener(evtType, handler, applyPassive());
|
55 | },
|
56 | deregisterInteractionHandler: function (evtType, handler) {
|
57 | return instance.root
|
58 | .removeEventListener(evtType, handler, applyPassive());
|
59 | },
|
60 | deregisterResizeHandler: function (handler) {
|
61 | return window.removeEventListener('resize', handler);
|
62 | },
|
63 | getWindowPageOffset: function () {
|
64 | return ({ x: window.pageXOffset, y: window.pageYOffset });
|
65 | },
|
66 | isSurfaceActive: function () { return matches(instance.root, ':active'); },
|
67 | isSurfaceDisabled: function () { return Boolean(instance.disabled); },
|
68 | isUnbounded: function () { return Boolean(instance.unbounded); },
|
69 | registerDocumentInteractionHandler: function (evtType, handler) {
|
70 | return document.documentElement.addEventListener(evtType, handler, applyPassive());
|
71 | },
|
72 | registerInteractionHandler: function (evtType, handler) {
|
73 | return instance.root
|
74 | .addEventListener(evtType, handler, applyPassive());
|
75 | },
|
76 | registerResizeHandler: function (handler) {
|
77 | return window.addEventListener('resize', handler);
|
78 | },
|
79 | removeClass: function (className) { return instance.root.classList.remove(className); },
|
80 | updateCssVariable: function (varName, value) {
|
81 | return instance.root.style.setProperty(varName, value);
|
82 | },
|
83 | };
|
84 | };
|
85 | Object.defineProperty(MDCRipple.prototype, "unbounded", {
|
86 | get: function () {
|
87 | return Boolean(this.isUnbounded);
|
88 | },
|
89 | set: function (unbounded) {
|
90 | this.isUnbounded = Boolean(unbounded);
|
91 | this.setUnbounded();
|
92 | },
|
93 | enumerable: false,
|
94 | configurable: true
|
95 | });
|
96 | MDCRipple.prototype.activate = function () {
|
97 | this.foundation.activate();
|
98 | };
|
99 | MDCRipple.prototype.deactivate = function () {
|
100 | this.foundation.deactivate();
|
101 | };
|
102 | MDCRipple.prototype.layout = function () {
|
103 | this.foundation.layout();
|
104 | };
|
105 | MDCRipple.prototype.getDefaultFoundation = function () {
|
106 | return new MDCRippleFoundation(MDCRipple.createAdapter(this));
|
107 | };
|
108 | MDCRipple.prototype.initialSyncWithDOM = function () {
|
109 | var root = this.root;
|
110 | this.isUnbounded = 'mdcRippleIsUnbounded' in root.dataset;
|
111 | };
|
112 | |
113 |
|
114 |
|
115 |
|
116 |
|
117 |
|
118 | MDCRipple.prototype.setUnbounded = function () {
|
119 | this.foundation.setUnbounded(Boolean(this.isUnbounded));
|
120 | };
|
121 | return MDCRipple;
|
122 | }(MDCComponent));
|
123 | export { MDCRipple };
|
124 |
|
\ | No newline at end of file |