MCPcopy
hub / github.com/Splidejs/splide / parseTransform

Function parseTransform

src/js/test/utils/utils.ts:130–146  ·  view source on GitHub ↗
( elm: HTMLElement )

Source from the content-addressed store, hash-verified

128 * @return An object with left and top offsets.
129 */
130export function parseTransform( elm: HTMLElement ): { left: number, top: number } {
131 const position = { left: 0, top: 0 };
132
133 if ( elm && elm.style.transform ) {
134 const { transform } = elm.style;
135
136 if ( transform.includes( 'translateX' ) ) {
137 position.left = parseFloat( transform.replace( /translateX\(|\)/g, '' ) ) || 0;
138 }
139
140 if ( transform.includes( 'translateY' ) ) {
141 position.top = parseFloat( transform.replace( /translateY\(|\)/g, '' ) ) || 0;
142 }
143 }
144
145 return position;
146}
147
148/**
149 * Fires any native event manually.

Callers 2

initFunction · 0.85
setSlidesRectFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…