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

Method constructor

js/interactive-tilt.js:45–59  ·  view source on GitHub ↗

* Constructor for the InteractiveTilt class. * @param {Element} DOM_el - The .content element to be animated * @param {Object} options - Custom options for the effect

(DOM_el, options)

Source from the content-addressed store, hash-verified

43 * @param {Object} options - Custom options for the effect
44 */
45 constructor(DOM_el, options) {
46 // Assign DOM elements to the DOM object
47 this.DOM.el = DOM_el;
48 this.DOM.wrapEl = this.DOM.el.querySelector('.content__img-wrap');
49 // Merge the default options with any user-provided options
50 this.options = Object.assign(this.defaults, options);
51
52 // If a perspective value is provided, apply it to the main element
53 if (this.options.perspective) {
54 this.DOM.el.style.perspective = `${this.options.perspective}px`;
55 }
56
57 // Start the rendering loop for the animation
58 requestAnimationFrame(() => this.render());
59 }
60
61 /**
62 * Animation loop that applies the tilt effect based on the cursor position.

Callers

nothing calls this directly

Calls 1

renderMethod · 0.95

Tested by

no test coverage detected