Untitled

 avatar
unknown
plain_text
5 months ago
3.5 kB
4
Indexable
customizedFunction(info, carousel) {
  // Detect small devices (e.g., iPhones) - assuming small devices have a max-width of 768px
  const isSmallDevice = window.matchMedia("(max-width: 768px)").matches;

  if (isSmallDevice) {
    let scrollPosition = window.scrollY; // Store the current scroll position

    var currentSlideIndex = info.index;
    var currentSlideDOM = info.slideItems[currentSlideIndex];
    var imageElement = currentSlideDOM.querySelector('img'); // Check if image is present in the active slide

    var leftContentDiv = document.querySelector('.bx-quote-block-left__content');

    if (!imageElement) {
      // If no image is present, hide the left content and maintain scroll position
      leftContentDiv.classList.add('bx_quote_block_leftContent_hide');
      setTimeout(() => {
        window.scrollTo({ top: scrollPosition, behavior: 'smooth' }); // Scroll to the stored position
      }, 100); // Add slight delay for transition
    } else {
      // If image is present, ensure left content is displayed
      leftContentDiv.classList.remove('bx_quote_block_leftContent_hide');
      setTimeout(() => {
        window.scrollTo({ top: scrollPosition, behavior: 'smooth' });
      }, 100); // Scroll to the stored position after the transition
    }
  }

  // Other existing logic for customizedFunction
  var specificParentClass = 'bx-quote-block__outer';
  var hasSpecificParent = currentSlideDOM.closest(`.${specificParentClass}`);
  
  var existingClass = 'bx-quote-block__inner'; 
  var newClass = 'bx-quote-block__inner_2'; 
  
  if (imageElement) {
    hasSpecificParent.classList.replace(newClass, existingClass);
  } else {
    hasSpecificParent.classList.replace(existingClass, newClass);
  }
}

customizedContentFunction(info, contentCarousel) {
  // Detect small devices (e.g., iPhones)
  const isSmallDevice = window.matchMedia("(max-width: 768px)").matches;

  if (isSmallDevice) {
    let scrollPosition = window.scrollY; // Store the current scroll position

    var currentSlideIndex = info.index;
    var currentSlideDOM = info.slideItems[currentSlideIndex];
    var imageElement = currentSlideDOM.querySelector('img'); // Check if image is present in the active slide

    var leftContentDiv = document.querySelector('.bx-quote-block-left__content');

    if (!imageElement) {
      // If no image is present, hide the left content and maintain scroll position
      leftContentDiv.classList.add('bx_quote_block_leftContent_hide');
      setTimeout(() => {
        window.scrollTo({ top: scrollPosition, behavior: 'smooth' }); // Scroll to the stored position
      }, 100); // Add slight delay for transition
    } else {
      // If image is present, ensure left content is displayed
      leftContentDiv.classList.remove('bx_quote_block_leftContent_hide');
      setTimeout(() => {
        window.scrollTo({ top: scrollPosition, behavior: 'smooth' });
      }, 100); // Scroll to the stored position after the transition
    }
  }

  // Other existing logic for customizedContentFunction
  var specificParentClass = 'bx-quote-block__inner';
  var hasSpecificParent = currentSlideDOM.closest(`.${specificParentClass}`);
  
  var existingClass1 = 'bx-quote-block-inner_content__inner'; 
  var newClass1 = 'bx_quote-block-inner--fullwidth';
  
  if (hasSpecificParent) {
    // Logic for content
  } else {
    currentSlideDOM.querySelector('.bx-quote-block__test').classList.replace(existingClass1, newClass1);
  }
}
Editor is loading...
Leave a Comment