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 = { isUnbounded: undefined }; }
|
38 | var ripple = new MDCRipple(root);
|
39 |
|
40 | if (opts.isUnbounded !== undefined) {
|
41 | ripple.unbounded = opts.isUnbounded;
|
42 | }
|
43 | return ripple;
|
44 | };
|
45 | MDCRipple.createAdapter = function (instance) {
|
46 | return {
|
47 | addClass: function (className) { return instance.root.classList.add(className); },
|
48 | browserSupportsCssVars: function () { return util.supportsCssVariables(window); },
|
49 | computeBoundingRect: function () { return instance.root.getBoundingClientRect(); },
|
50 | containsEventTarget: function (target) { return instance.root.contains(target); },
|
51 | deregisterDocumentInteractionHandler: function (evtType, handler) {
|
52 | return document.documentElement.removeEventListener(evtType, handler, applyPassive());
|
53 | },
|
54 | deregisterInteractionHandler: function (evtType, handler) {
|
55 | return instance.root
|
56 | .removeEventListener(evtType, handler, applyPassive());
|
57 | },
|
58 | deregisterResizeHandler: function (handler) {
|
59 | return window.removeEventListener('resize', handler);
|
60 | },
|
61 | getWindowPageOffset: function () {
|
62 | return ({ x: window.pageXOffset, y: window.pageYOffset });
|
63 | },
|
64 | isSurfaceActive: function () { return matches(instance.root, ':active'); },
|
65 | isSurfaceDisabled: function () { return Boolean(instance.disabled); },
|
66 | isUnbounded: function () { return Boolean(instance.unbounded); },
|
67 | registerDocumentInteractionHandler: function (evtType, handler) {
|
68 | return document.documentElement.addEventListener(evtType, handler, applyPassive());
|
69 | },
|
70 | registerInteractionHandler: function (evtType, handler) {
|
71 | return instance.root
|
72 | .addEventListener(evtType, handler, applyPassive());
|
73 | },
|
74 | registerResizeHandler: function (handler) {
|
75 | return window.addEventListener('resize', handler);
|
76 | },
|
77 | removeClass: function (className) { return instance.root.classList.remove(className); },
|
78 | updateCssVariable: function (varName, value) {
|
79 | return instance.root.style.setProperty(varName, value);
|
80 | },
|
81 | };
|
82 | };
|
83 | Object.defineProperty(MDCRipple.prototype, "unbounded", {
|
84 | get: function () {
|
85 | return Boolean(this.unbounded_);
|
86 | },
|
87 | set: function (unbounded) {
|
88 | this.unbounded_ = Boolean(unbounded);
|
89 | this.setUnbounded_();
|
90 | },
|
91 | enumerable: false,
|
92 | configurable: true
|
93 | });
|
94 | MDCRipple.prototype.activate = function () {
|
95 | this.foundation.activate();
|
96 | };
|
97 | MDCRipple.prototype.deactivate = function () {
|
98 | this.foundation.deactivate();
|
99 | };
|
100 | MDCRipple.prototype.layout = function () {
|
101 | this.foundation.layout();
|
102 | };
|
103 | MDCRipple.prototype.getDefaultFoundation = function () {
|
104 | return new MDCRippleFoundation(MDCRipple.createAdapter(this));
|
105 | };
|
106 | MDCRipple.prototype.initialSyncWithDOM = function () {
|
107 | var root = this.root;
|
108 | this.unbounded = 'mdcRippleIsUnbounded' in root.dataset;
|
109 | };
|
110 | |
111 |
|
112 |
|
113 |
|
114 |
|
115 |
|
116 | MDCRipple.prototype.setUnbounded_ = function () {
|
117 | this.foundation.setUnbounded(Boolean(this.unbounded_));
|
118 | };
|
119 | return MDCRipple;
|
120 | }(MDCComponent));
|
121 | export { MDCRipple };
|
122 |
|
\ | No newline at end of file |