function getTransformValues(element) {
const style = window.getComputedStyle(element);
const matrix =
style.transform || style.webkitTransform || style.mozTransform;
const matrixType = matrix.includes("3d") ? "3d" : "2d";
const matrixValues = matrix.match(/matrix.*\((.+)\)/)[1].split(", ");
// 2d matrices have 6 values
if (matrixType === "2d") {
return {
x: Number(matrixValues[4]),
y: Number(matrixValues[5])
};
}
// 3d matrices have 16 values
if (matrixType === "3d") {
return {
x: Number(matrixValues[12]),
y: Number(matrixValues[13]),
z: Number(matrixValues[14]),
};
}
}
}
getTransformValues(твойЭлемент); // { x: 0, y: 0, z: 0 }
"2" + "6" === "26"
var sum = Number(num1) + Number(num2);
window.addEventListener('resize', resizeHandlerSlider);
clientWidth
при вызове хэндлера и дестроишь свой слайдер.const slider = document.querySelector('#slider');
let { clientWidth } = document.body;
let yourSlider;
const sliderInit = () => {
yourSlider = new Swiper(slider, {...})
}
const resizeHandlerSlider = () => {
if (clientWidth !== document.body.clientWidth) {
clientWidth = document.body.clientWidth;
if (yourSlider) {
yourSlider.destroy();
}
sliderInit();
}
}
let num = 2; num % 2 == 0
- у вас цикл доходит только до 2for (let num = 1; num <= 10; num++) {
if (num % 2 === 0) {
console.log(num);
}
};
table td:nth-child(-n+2) {
/**/
}
$('.item').on('click', function() {
$('.active').removeClass('active');
$(this).addClass('active');
var index = $(this).index('.item');
var block = $('.block');
function transferBlock(i) {
block.insertAfter($('.item').eq(i));
}
switch((index + 1) % 3) {
case (0):
transferBlock(index);
break
case(1):
transferBlock(index + 2);
break
case(2):
transferBlock(index + 1);
break;
}
});