MCPcopy Create free account
hub / github.com/codrops/GridItemHoverEffect / constructor

Method constructor

js/card.js:20–46  ·  view source on GitHub ↗

* Constructor: Initializes the properties with the actual DOM elements. * @param {HTMLElement} DOM_el - The main container of the box.

(DOM_el)

Source from the content-addressed store, hash-verified

18 * @param {HTMLElement} DOM_el - The main container of the box.
19 */
20 constructor(DOM_el) {
21 // Associate the provided element with the main container
22 this.DOM.el = DOM_el;
23 // Fetch various child elements
24 this.DOM.number = this.DOM.el.querySelector('.card__box-number');
25 this.DOM.tags = this.DOM.el.querySelector('.card__box-tags');
26 this.DOM.category = this.DOM.el.querySelector('.card__box-category');
27
28 // Prepare the number and category elements for splitting using Splitting.js
29 if ( this.DOM.number ) {
30 this.DOM.number.dataset.splitting = '';
31 }
32 if ( this.DOM.category ) {
33 this.DOM.category.dataset.splitting = '';
34 }
35
36 // Use Splitting.js to split the text content into individual characters for animation/effects.
37 Splitting();
38
39 // Store references to the individual characters after the split.
40 if (this.DOM.number) {
41 this.DOM.numberChars = this.DOM.number.querySelectorAll('.char');
42 }
43 if (this.DOM.category) {
44 this.DOM.categoryChars = this.DOM.category.querySelectorAll('.char');
45 }
46 }
47
48}
49

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected