@materializecss/materialize 2.0.3-alpha → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/README.md +1 -1
  2. package/dist/css/materialize.css +345 -236
  3. package/dist/css/materialize.min.css +2 -2
  4. package/dist/js/materialize.js +518 -1979
  5. package/dist/js/materialize.min.js +2 -2
  6. package/dist/js/materialize.min.js.map +1 -1
  7. package/dist/src/buttons.d.ts.map +1 -1
  8. package/dist/src/cards.d.ts.map +1 -1
  9. package/dist/src/collapsible.d.ts +1 -0
  10. package/dist/src/collapsible.d.ts.map +1 -1
  11. package/dist/src/dropdown.d.ts.map +1 -1
  12. package/dist/src/global.d.ts.map +1 -1
  13. package/dist/src/materialbox.d.ts +14 -10
  14. package/dist/src/materialbox.d.ts.map +1 -1
  15. package/dist/src/modal.d.ts.map +1 -1
  16. package/dist/src/range.d.ts.map +1 -1
  17. package/dist/src/scrollspy.d.ts.map +1 -1
  18. package/dist/src/sidenav.d.ts +25 -25
  19. package/dist/src/sidenav.d.ts.map +1 -1
  20. package/dist/src/slider.d.ts +12 -12
  21. package/dist/src/slider.d.ts.map +1 -1
  22. package/dist/src/tabs.d.ts +1 -1
  23. package/dist/src/tabs.d.ts.map +1 -1
  24. package/dist/src/toasts.d.ts +7 -2
  25. package/dist/src/toasts.d.ts.map +1 -1
  26. package/dist/src/tooltip.d.ts +8 -2
  27. package/dist/src/tooltip.d.ts.map +1 -1
  28. package/package.json +14 -13
  29. package/sass/components/_buttons.scss +158 -73
  30. package/sass/components/_chips.scss +75 -28
  31. package/sass/components/_collapsible.scss +14 -2
  32. package/sass/components/_global.scss +6 -94
  33. package/sass/components/_materialbox.scss +2 -2
  34. package/sass/components/_modal.scss +0 -1
  35. package/sass/components/_preloader.scss +85 -0
  36. package/sass/components/_tooltip.scss +18 -8
  37. package/sass/components/_variables.scss +5 -4
  38. package/sass/components/forms/_range.scss +1 -1
  39. package/sass/components/forms/_switches.scss +44 -14
  40. package/Gruntfile.js +0 -480
  41. package/src/autocomplete.ts +0 -553
  42. package/src/bounding.ts +0 -6
  43. package/src/buttons.ts +0 -260
  44. package/src/cards.ts +0 -53
  45. package/src/carousel.ts +0 -676
  46. package/src/characterCounter.ts +0 -117
  47. package/src/chips.ts +0 -439
  48. package/src/collapsible.ts +0 -249
  49. package/src/component.ts +0 -120
  50. package/src/datepicker.ts +0 -1076
  51. package/src/dropdown.ts +0 -644
  52. package/src/edges.ts +0 -6
  53. package/src/forms.ts +0 -132
  54. package/src/global.ts +0 -114
  55. package/src/index.ts +0 -26
  56. package/src/materialbox.ts +0 -404
  57. package/src/modal.ts +0 -341
  58. package/src/parallax.ts +0 -149
  59. package/src/pushpin.ts +0 -165
  60. package/src/range.ts +0 -198
  61. package/src/scrollspy.ts +0 -263
  62. package/src/select.ts +0 -484
  63. package/src/sidenav.ts +0 -543
  64. package/src/slider.ts +0 -474
  65. package/src/tabs.ts +0 -347
  66. package/src/tapTarget.ts +0 -273
  67. package/src/timepicker.ts +0 -832
  68. package/src/toasts.ts +0 -290
  69. package/src/tooltip.ts +0 -346
  70. package/src/utils.ts +0 -271
  71. package/src/waves.ts +0 -70
package/src/tabs.ts DELETED
@@ -1,347 +0,0 @@
1
- import anim from "animejs";
2
-
3
- import { Carousel } from "./carousel";
4
- import { Component, BaseOptions, InitElements, MElement } from "./component";
5
-
6
- export interface TabsOptions extends BaseOptions {
7
- /**
8
- * Transition duration in milliseconds.
9
- * @default 300
10
- */
11
- duration: number;
12
- /**
13
- * Callback for when a new tab content is shown.
14
- * @default null
15
- */
16
- onShow: (newContent: Element) => void;
17
- /**
18
- * Set to true to enable swipeable tabs.
19
- * This also uses the responsiveThreshold option.
20
- * @default false
21
- */
22
- swipeable: boolean;
23
- /**
24
- * The maximum width of the screen, in pixels,
25
- * where the swipeable functionality initializes.
26
- * @default infinity
27
- */
28
- responsiveThreshold: number;
29
- };
30
-
31
- let _defaults: TabsOptions = {
32
- duration: 300,
33
- onShow: null,
34
- swipeable: false,
35
- responsiveThreshold: Infinity // breakpoint for swipeable
36
- };
37
-
38
- export class Tabs extends Component<TabsOptions> {
39
- _tabLinks: NodeListOf<HTMLAnchorElement>;
40
- _index: number;
41
- _indicator: any;
42
- _tabWidth: number;
43
- _tabsWidth: number;
44
- _tabsCarousel: any;
45
- _activeTabLink: any;
46
- _content: any;
47
-
48
- constructor(el: HTMLElement, options: Partial<TabsOptions>) {
49
- super(el, options, Tabs);
50
- (this.el as any).M_Tabs = this;
51
-
52
- this.options = {
53
- ...Tabs.defaults,
54
- ...options
55
- };
56
-
57
- this._tabLinks = this.el.querySelectorAll('li.tab > a');
58
- this._index = 0;
59
- this._setupActiveTabLink();
60
- if (this.options.swipeable) {
61
- this._setupSwipeableTabs();
62
- } else {
63
- this._setupNormalTabs();
64
- }
65
- // Setup tabs indicator after content to ensure accurate widths
66
- this._setTabsAndTabWidth();
67
- this._createIndicator();
68
- this._setupEventHandlers();
69
- }
70
-
71
- static get defaults(): TabsOptions {
72
- return _defaults;
73
- }
74
-
75
- /**
76
- * Initializes instance of Tabs.
77
- * @param el HTML element.
78
- * @param options Component options.
79
- */
80
- static init(el: HTMLElement, options?: Partial<TabsOptions>): Tabs;
81
- /**
82
- * Initializes instances of Tabs.
83
- * @param els HTML elements.
84
- * @param options Component options.
85
- */
86
- static init(els: InitElements<MElement>, options?: Partial<TabsOptions>): Tabs[];
87
- /**
88
- * Initializes instances of Tabs.
89
- * @param els HTML elements.
90
- * @param options Component options.
91
- */
92
- static init(els: HTMLElement | InitElements<MElement>, options: Partial<TabsOptions> = {}): Tabs | Tabs[] {
93
- return super.init(els, options, Tabs);
94
- }
95
-
96
- static getInstance(el: HTMLElement): Tabs {
97
- return (el as any).M_Tabs;
98
- }
99
-
100
- destroy() {
101
- this._removeEventHandlers();
102
- this._indicator.parentNode.removeChild(this._indicator);
103
- if (this.options.swipeable) {
104
- this._teardownSwipeableTabs();
105
- }
106
- else {
107
- this._teardownNormalTabs();
108
- }
109
- (this.el as any).M_Tabs = undefined;
110
- }
111
-
112
- /**
113
- * The index of tab that is currently shown.
114
- */
115
- get index(){ return this._index; }
116
-
117
- _setupEventHandlers() {
118
- window.addEventListener('resize', this._handleWindowResize);
119
- this.el.addEventListener('click', this._handleTabClick);
120
- }
121
-
122
- _removeEventHandlers() {
123
- window.removeEventListener('resize', this._handleWindowResize);
124
- this.el.removeEventListener('click', this._handleTabClick);
125
- }
126
-
127
- _handleWindowResize = () => {
128
- this._setTabsAndTabWidth();
129
- if (this._tabWidth !== 0 && this._tabsWidth !== 0) {
130
- this._indicator.style.left = this._calcLeftPos(this._activeTabLink)+'px';
131
- this._indicator.style.right = this._calcRightPos(this._activeTabLink)+'px';
132
- }
133
- }
134
-
135
- _handleTabClick = (e: MouseEvent) => {
136
- const tabLink = e.target as HTMLAnchorElement;
137
- const tab = tabLink.parentElement;
138
- // Handle click on tab link only
139
- if (!tabLink || !tab.classList.contains('tab')) return;
140
- // is disabled?
141
- if (tab.classList.contains('disabled')) {
142
- e.preventDefault();
143
- return;
144
- }
145
- // Act as regular link if target attribute is specified.
146
- if (tabLink.hasAttribute('target')) return;
147
- // Make the old tab inactive.
148
- this._activeTabLink.classList.remove('active');
149
- const _oldContent = this._content;
150
- // Update the variables with the new link and content
151
-
152
- this._activeTabLink = tabLink;
153
- if (tabLink.hash)
154
- this._content = document.querySelector(tabLink.hash);
155
- this._tabLinks = this.el.querySelectorAll('li.tab > a');
156
- // Make the tab active
157
- this._activeTabLink.classList.add('active');
158
- const prevIndex = this._index;
159
- this._index = Math.max(Array.from(this._tabLinks).indexOf(tabLink), 0);
160
-
161
- // Swap content
162
- if (this.options.swipeable) {
163
- if (this._tabsCarousel) {
164
- this._tabsCarousel.set(this._index, () => {
165
- if (typeof this.options.onShow === 'function')
166
- this.options.onShow.call(this, this._content);
167
- });
168
- }
169
- } else {
170
- if (this._content) {
171
- this._content.style.display = 'block';
172
- this._content.classList.add('active');
173
- if (typeof this.options.onShow === 'function')
174
- this.options.onShow.call(this, this._content);
175
- if (_oldContent && _oldContent !== this._content) {
176
- _oldContent.style.display = 'none';
177
- _oldContent.classList.remove('active');
178
- }
179
- }
180
- }
181
- // Update widths after content is swapped (scrollbar bugfix)
182
- this._setTabsAndTabWidth();
183
- this._animateIndicator(prevIndex);
184
- e.preventDefault();
185
- }
186
-
187
- _createIndicator() {
188
- const indicator = document.createElement('li');
189
- indicator.classList.add('indicator');
190
- this.el.appendChild(indicator);
191
- this._indicator = indicator;
192
- this._indicator.style.left = this._calcLeftPos(this._activeTabLink)+'px';
193
- this._indicator.style.right = this._calcRightPos(this._activeTabLink)+'px';
194
- }
195
-
196
- _setupActiveTabLink() {
197
- // If the location.hash matches one of the links, use that as the active tab.
198
- this._activeTabLink = Array.from(this._tabLinks).find((a: HTMLAnchorElement) => a.getAttribute('href') === location.hash);
199
- // If no match is found, use the first link or any with class 'active' as the initial active tab.
200
- if (!this._activeTabLink) {
201
- this._activeTabLink = this.el.querySelector('li.tab a.active');
202
- }
203
- if (this._activeTabLink.length === 0) {
204
- this._activeTabLink = this.el.querySelector('li.tab a');
205
- }
206
- Array.from(this._tabLinks).forEach((a: HTMLAnchorElement) => a.classList.remove('active'));
207
- this._activeTabLink.classList.add('active');
208
-
209
- this._index = Math.max(Array.from(this._tabLinks).indexOf(this._activeTabLink), 0);
210
- if (this._activeTabLink && this._activeTabLink.hash) {
211
- this._content = document.querySelector(this._activeTabLink.hash);
212
- this._content.classList.add('active');
213
- }
214
- }
215
-
216
- _setupSwipeableTabs() {
217
- // Change swipeable according to responsive threshold
218
- if (window.innerWidth > this.options.responsiveThreshold)
219
- this.options.swipeable = false;
220
-
221
- const tabsContent = [];
222
- this._tabLinks.forEach(a => {
223
- if (a.hash) {
224
- const currContent = document.querySelector(a.hash);
225
- currContent.classList.add('carousel-item');
226
- tabsContent.push(currContent);
227
- }
228
- });
229
-
230
- // Create Carousel-Wrapper around Tab-Contents
231
- const tabsWrapper = document.createElement('div');
232
- tabsWrapper.classList.add('tabs-content', 'carousel', 'carousel-slider');
233
-
234
- // Wrap around
235
- tabsContent[0].parentElement.insertBefore(tabsWrapper, tabsContent[0]);
236
- tabsContent.forEach(tabContent => {
237
- tabsWrapper.appendChild(tabContent);
238
- tabContent.style.display = '';
239
- });
240
-
241
- // Keep active tab index to set initial carousel slide
242
- const tab = this._activeTabLink.parentElement;
243
- const activeTabIndex = Array.from(tab.parentNode.children).indexOf(tab);
244
-
245
- this._tabsCarousel = Carousel.init(tabsWrapper, {
246
- fullWidth: true,
247
- noWrap: true,
248
- onCycleTo: (item) => {
249
- const prevIndex = this._index;
250
- this._index = Array.from(item.parentNode.children).indexOf(item);
251
- this._activeTabLink.classList.remove('active');
252
- this._activeTabLink = Array.from(this._tabLinks)[this._index];
253
- this._activeTabLink.classList.add('active');
254
- this._animateIndicator(prevIndex);
255
- if (typeof this.options.onShow === 'function')
256
- this.options.onShow.call(this, this._content);
257
- }
258
- });
259
- // Set initial carousel slide to active tab
260
- this._tabsCarousel.set(activeTabIndex);
261
- }
262
-
263
- _teardownSwipeableTabs() {
264
- const tabsWrapper = this._tabsCarousel.el;
265
- this._tabsCarousel.destroy();
266
- // Unwrap
267
- tabsWrapper.after(tabsWrapper.children);
268
- tabsWrapper.remove();
269
- }
270
-
271
- _setupNormalTabs() {
272
- // Hide Tabs Content
273
- Array.from(this._tabLinks).forEach((a) => {
274
- if (a === this._activeTabLink) return;
275
- if ((<HTMLAnchorElement>a).hash) {
276
- const currContent = document.querySelector((<HTMLAnchorElement>a).hash);
277
- if (currContent) (<HTMLElement>currContent).style.display = 'none';
278
- }
279
- });
280
- }
281
-
282
- _teardownNormalTabs() {
283
- // show Tabs Content
284
- this._tabLinks.forEach((a) => {
285
- if (a.hash) {
286
- const currContent = document.querySelector(a.hash) as HTMLElement;
287
- if (currContent) currContent.style.display = '';
288
- }
289
- });
290
- }
291
-
292
- _setTabsAndTabWidth() {
293
- this._tabsWidth = this.el.getBoundingClientRect().width;
294
- this._tabWidth = Math.max(this._tabsWidth, this.el.scrollWidth) / this._tabLinks.length;
295
- }
296
-
297
- _calcRightPos(el) {
298
- return Math.ceil(this._tabsWidth - el.offsetLeft - el.getBoundingClientRect().width);
299
- }
300
-
301
- _calcLeftPos(el) {
302
- return Math.floor(el.offsetLeft);
303
- }
304
-
305
- /**
306
- * Recalculate tab indicator position. This is useful when
307
- * the indicator position is not correct.
308
- */
309
- updateTabIndicator() {
310
- this._setTabsAndTabWidth();
311
- this._animateIndicator(this._index);
312
- }
313
-
314
- _animateIndicator(prevIndex) {
315
- let leftDelay = 0, rightDelay = 0;
316
-
317
- if (this._index - prevIndex >= 0)
318
- leftDelay = 90;
319
- else
320
- rightDelay = 90;
321
-
322
- const animOptions = {
323
- targets: this._indicator,
324
- left: {
325
- value: this._calcLeftPos(this._activeTabLink),
326
- delay: leftDelay
327
- },
328
- right: {
329
- value: this._calcRightPos(this._activeTabLink),
330
- delay: rightDelay
331
- },
332
- duration: this.options.duration,
333
- easing: 'easeOutQuad'
334
- };
335
- anim.remove(this._indicator);
336
- anim(animOptions);
337
- }
338
-
339
- /**
340
- * Show tab content that corresponds to the tab with the id.
341
- * @param tabId The id of the tab that you want to switch to.
342
- */
343
- select(tabId: string) {
344
- const tab = Array.from(this._tabLinks).find((a: HTMLAnchorElement) => a.getAttribute('href') === '#'+tabId);
345
- if (tab) (<HTMLAnchorElement>tab).click();
346
- }
347
- }
package/src/tapTarget.ts DELETED
@@ -1,273 +0,0 @@
1
- import { Utils } from "./utils";
2
- import { Component, BaseOptions, InitElements, MElement, Openable } from "./component";
3
-
4
- export interface TapTargetOptions extends BaseOptions {
5
- /**
6
- * Callback function called when Tap Target is opened.
7
- * @default null
8
- */
9
- onOpen: (origin: HTMLElement) => void;
10
- /**
11
- * Callback function called when Tap Target is closed.
12
- * @default null
13
- */
14
- onClose: (origin: HTMLElement) => void;
15
- };
16
-
17
- let _defaults: TapTargetOptions = {
18
- onOpen: null,
19
- onClose: null
20
- };
21
-
22
- export class TapTarget extends Component<TapTargetOptions> implements Openable {
23
- /**
24
- * If the tap target is open.
25
- */
26
- isOpen: boolean;
27
-
28
- private wrapper: HTMLElement;
29
- private _origin: HTMLElement;
30
- private originEl: HTMLElement;
31
- private waveEl: HTMLElement & Element & Node;
32
- private contentEl: HTMLElement;
33
-
34
- constructor(el: HTMLElement, options: Partial<TapTargetOptions>) {
35
- super(el, options, TapTarget);
36
- (this.el as any).M_TapTarget = this;
37
-
38
- this.options = {
39
- ...TapTarget.defaults,
40
- ...options
41
- };
42
-
43
- this.isOpen = false;
44
- // setup
45
- this._origin = document.querySelector(`#${el.dataset.target}`);
46
- this._setup();
47
- this._calculatePositioning();
48
- this._setupEventHandlers();
49
- }
50
-
51
- static get defaults(): TapTargetOptions {
52
- return _defaults;
53
- }
54
-
55
- /**
56
- * Initializes instance of TapTarget.
57
- * @param el HTML element.
58
- * @param options Component options.
59
- */
60
- static init(el: HTMLElement, options?: Partial<TapTargetOptions>): TapTarget;
61
- /**
62
- * Initializes instances of TapTarget.
63
- * @param els HTML elements.
64
- * @param options Component options.
65
- */
66
- static init(els: InitElements<MElement>, options?: Partial<TapTargetOptions>): TapTarget[];
67
- /**
68
- * Initializes instances of TapTarget.
69
- * @param els HTML elements.
70
- * @param options Component options.
71
- */
72
- static init(els: HTMLElement | InitElements<MElement>, options: Partial<TapTargetOptions> = {}): TapTarget | TapTarget[] {
73
- return super.init(els, options, TapTarget);
74
- }
75
-
76
- static getInstance(el: HTMLElement): TapTarget {
77
- return (el as any).M_TapTarget;
78
- }
79
-
80
- destroy() {
81
- this._removeEventHandlers();
82
- (this.el as any).TapTarget = undefined;
83
- }
84
-
85
- _setupEventHandlers() {
86
- this.el.addEventListener('click', this._handleTargetClick);
87
- this.originEl.addEventListener('click', this._handleOriginClick);
88
- // Resize
89
- window.addEventListener('resize', this._handleThrottledResize);
90
- }
91
-
92
- _removeEventHandlers() {
93
- this.el.removeEventListener('click', this._handleTargetClick);
94
- this.originEl.removeEventListener('click', this._handleOriginClick);
95
- window.removeEventListener('resize', this._handleThrottledResize);
96
- }
97
-
98
- _handleThrottledResize: () => void = Utils.throttle(function(){ this._handleResize(); }, 200).bind(this);
99
-
100
- _handleTargetClick = () => {
101
- this.open();
102
- }
103
-
104
- _handleOriginClick = () => {
105
- this.close();
106
- }
107
-
108
- _handleResize = () => {
109
- this._calculatePositioning();
110
- }
111
-
112
- _handleDocumentClick = (e: MouseEvent | TouchEvent) => {
113
- if (!(e.target as HTMLElement).closest('.tap-target-wrapper')) {
114
- this.close();
115
- e.preventDefault();
116
- e.stopPropagation();
117
- }
118
- }
119
-
120
- _setup() {
121
- // Creating tap target
122
- this.wrapper = this.el.parentElement;
123
- this.waveEl = this.wrapper.querySelector('.tap-target-wave');
124
- this.originEl = this.wrapper.querySelector('.tap-target-origin');
125
- this.contentEl = this.el.querySelector('.tap-target-content');
126
- // Creating wrapper
127
- if (!this.wrapper.classList.contains('.tap-target-wrapper')) {
128
- this.wrapper = document.createElement('div');
129
- this.wrapper.classList.add('tap-target-wrapper');
130
- this.el.before(this.wrapper);
131
- this.wrapper.append(this.el);
132
- }
133
- // Creating content
134
- if (!this.contentEl) {
135
- this.contentEl = document.createElement('div');
136
- this.contentEl.classList.add('tap-target-content');
137
- this.el.append(this.contentEl);
138
- }
139
- // Creating foreground wave
140
- if (!this.waveEl) {
141
- this.waveEl = document.createElement('div');
142
- this.waveEl.classList.add('tap-target-wave');
143
- // Creating origin
144
- if (!this.originEl) {
145
- this.originEl = <HTMLElement>this._origin.cloneNode(true); // .clone(true, true);
146
- this.originEl.classList.add('tap-target-origin');
147
- this.originEl.removeAttribute('id');
148
- this.originEl.removeAttribute('style');
149
- this.waveEl.append(this.originEl);
150
- }
151
- this.wrapper.append(this.waveEl);
152
- }
153
- }
154
-
155
- private _offset(el: HTMLElement) {
156
- const box = el.getBoundingClientRect();
157
- const docElem = document.documentElement;
158
- return {
159
- top: box.top + window.pageYOffset - docElem.clientTop,
160
- left: box.left + window.pageXOffset - docElem.clientLeft
161
- };
162
- }
163
-
164
- _calculatePositioning() {
165
- // Element or parent is fixed position?
166
- let isFixed = getComputedStyle(this._origin).position === 'fixed';
167
- if (!isFixed) {
168
-
169
- let currentElem: any = this._origin;
170
- const parents = [];
171
- while ((currentElem = currentElem.parentNode) && currentElem !== document)
172
- parents.push(currentElem);
173
-
174
- for (let i = 0; i < parents.length; i++) {
175
- isFixed = getComputedStyle(parents[i]).position === 'fixed';
176
- if (isFixed) break;
177
- }
178
- }
179
- // Calculating origin
180
- const originWidth = this._origin.offsetWidth;
181
- const originHeight = this._origin.offsetHeight;
182
- const originTop = isFixed ? this._offset(this._origin).top - Utils.getDocumentScrollTop() : this._offset(this._origin).top;
183
- const originLeft = isFixed ? this._offset(this._origin).left - Utils.getDocumentScrollLeft() : this._offset(this._origin).left;
184
-
185
- // Calculating screen
186
- const windowWidth = window.innerWidth;
187
- const windowHeight = window.innerHeight;
188
- const scrollBarWidth = windowWidth - document.documentElement.clientWidth;
189
- const centerX = windowWidth / 2;
190
- const centerY = windowHeight / 2;
191
- const isLeft = originLeft <= centerX;
192
- const isRight = originLeft > centerX;
193
- const isTop = originTop <= centerY;
194
- const isBottom = originTop > centerY;
195
- const isCenterX = originLeft >= windowWidth * 0.25 && originLeft <= windowWidth * 0.75;
196
-
197
- // Calculating tap target
198
- const tapTargetWidth = this.el.offsetWidth;
199
- const tapTargetHeight = this.el.offsetHeight;
200
- const tapTargetTop = originTop + originHeight / 2 - tapTargetHeight / 2;
201
- const tapTargetLeft = originLeft + originWidth / 2 - tapTargetWidth / 2;
202
- const tapTargetPosition = isFixed ? 'fixed' : 'absolute';
203
-
204
- // Calculating content
205
- const tapTargetTextWidth = isCenterX ? tapTargetWidth : tapTargetWidth / 2 + originWidth;
206
- const tapTargetTextHeight = tapTargetHeight / 2;
207
- const tapTargetTextTop = isTop ? tapTargetHeight / 2 : 0;
208
- const tapTargetTextBottom = 0;
209
- const tapTargetTextLeft = isLeft && !isCenterX ? tapTargetWidth / 2 - originWidth : 0;
210
- const tapTargetTextRight = 0;
211
- const tapTargetTextPadding = originWidth;
212
- const tapTargetTextAlign = isBottom ? 'bottom' : 'top';
213
-
214
- // Calculating wave
215
- const tapTargetWaveWidth = originWidth > originHeight ? originWidth * 2 : originWidth * 2;
216
- const tapTargetWaveHeight = tapTargetWaveWidth;
217
- const tapTargetWaveTop = tapTargetHeight / 2 - tapTargetWaveHeight / 2;
218
- const tapTargetWaveLeft = tapTargetWidth / 2 - tapTargetWaveWidth / 2;
219
-
220
- // Setting tap target
221
- this.wrapper.style.top = isTop ? tapTargetTop + 'px' : '';
222
- this.wrapper.style.right = isRight ? windowWidth - tapTargetLeft - tapTargetWidth - scrollBarWidth + 'px' : '';
223
- this.wrapper.style.bottom = isBottom ? windowHeight - tapTargetTop - tapTargetHeight + 'px' : '';
224
- this.wrapper.style.left = isLeft ? tapTargetLeft + 'px' : '';
225
- this.wrapper.style.position = tapTargetPosition;
226
-
227
- // Setting content
228
- this.contentEl.style.width = tapTargetTextWidth + 'px';
229
- this.contentEl.style.height = tapTargetTextHeight + 'px';
230
- this.contentEl.style.top = tapTargetTextTop + 'px';
231
- this.contentEl.style.right = tapTargetTextRight + 'px';
232
- this.contentEl.style.bottom = tapTargetTextBottom + 'px';
233
- this.contentEl.style.left = tapTargetTextLeft + 'px';
234
- this.contentEl.style.padding = tapTargetTextPadding + 'px';
235
- this.contentEl.style.verticalAlign = tapTargetTextAlign;
236
-
237
- // Setting wave
238
- this.waveEl.style.top = tapTargetWaveTop+'px';
239
- this.waveEl.style.left = tapTargetWaveLeft+'px';
240
- this.waveEl.style.width = tapTargetWaveWidth+'px';
241
- this.waveEl.style.height = tapTargetWaveHeight+'px';
242
- }
243
-
244
- /**
245
- * Open Tap Target.
246
- */
247
- open = () => {
248
- if (this.isOpen) return;
249
- // onOpen callback
250
- if (typeof this.options.onOpen === 'function') {
251
- this.options.onOpen.call(this, this._origin);
252
- }
253
- this.isOpen = true;
254
- this.wrapper.classList.add('open');
255
- document.body.addEventListener('click', this._handleDocumentClick, true);
256
- document.body.addEventListener('touchend', this._handleDocumentClick);
257
- };
258
-
259
- /**
260
- * Close Tap Target.
261
- */
262
- close = () => {
263
- if (!this.isOpen) return;
264
- // onClose callback
265
- if (typeof this.options.onClose === 'function') {
266
- this.options.onClose.call(this, this._origin);
267
- }
268
- this.isOpen = false;
269
- this.wrapper.classList.remove('open');
270
- document.body.removeEventListener('click', this._handleDocumentClick, true);
271
- document.body.removeEventListener('touchend', this._handleDocumentClick);
272
- };
273
- }