component.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /**
  2. * @license
  3. * Copyright 2018 Google Inc.
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining a copy
  6. * of this software and associated documentation files (the "Software"), to deal
  7. * in the Software without restriction, including without limitation the rights
  8. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. * copies of the Software, and to permit persons to whom the Software is
  10. * furnished to do so, subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be included in
  13. * all copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. * THE SOFTWARE.
  22. */
  23. import { __extends } from "tslib";
  24. import { MDCComponent } from '@material/base/component';
  25. import { MDCLineRippleFoundation } from './foundation';
  26. /** MDC Line Ripple */
  27. var MDCLineRipple = /** @class */ (function (_super) {
  28. __extends(MDCLineRipple, _super);
  29. function MDCLineRipple() {
  30. return _super !== null && _super.apply(this, arguments) || this;
  31. }
  32. MDCLineRipple.attachTo = function (root) {
  33. return new MDCLineRipple(root);
  34. };
  35. /**
  36. * Activates the line ripple
  37. */
  38. MDCLineRipple.prototype.activate = function () {
  39. this.foundation.activate();
  40. };
  41. /**
  42. * Deactivates the line ripple
  43. */
  44. MDCLineRipple.prototype.deactivate = function () {
  45. this.foundation.deactivate();
  46. };
  47. /**
  48. * Sets the transform origin given a user's click location.
  49. * The `rippleCenter` is the x-coordinate of the middle of the ripple.
  50. */
  51. MDCLineRipple.prototype.setRippleCenter = function (xCoordinate) {
  52. this.foundation.setRippleCenter(xCoordinate);
  53. };
  54. MDCLineRipple.prototype.getDefaultFoundation = function () {
  55. var _this = this;
  56. // DO NOT INLINE this variable. For backward compatibility, foundations take
  57. // a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any
  58. // methods, we need a separate, strongly typed adapter variable.
  59. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  60. var adapter = {
  61. addClass: function (className) {
  62. _this.root.classList.add(className);
  63. },
  64. removeClass: function (className) {
  65. _this.root.classList.remove(className);
  66. },
  67. hasClass: function (className) { return _this.root.classList.contains(className); },
  68. setStyle: function (propertyName, value) {
  69. _this.root.style.setProperty(propertyName, value);
  70. },
  71. registerEventHandler: function (evtType, handler) {
  72. _this.listen(evtType, handler);
  73. },
  74. deregisterEventHandler: function (evtType, handler) {
  75. _this.unlisten(evtType, handler);
  76. },
  77. };
  78. // tslint:enable:object-literal-sort-keys
  79. return new MDCLineRippleFoundation(adapter);
  80. };
  81. return MDCLineRipple;
  82. }(MDCComponent));
  83. export { MDCLineRipple };
  84. //# sourceMappingURL=component.js.map