Button appears and disappears sporadically while browsing in Safari

I created a slider using SCSS, JavaScript, and HTML. You can view the demo at this link: https://jsfiddle.net/rr7g6a1b/

let mySlider = {
  initializeSlider: function (options) {
    let slider = options.container;
    let slides = slider.querySelectorAll('.slide');
    let initialSlide = slider.querySelector('.slide[data-index="0"]');
    let initialButton = slider.querySelector('.pagination-button[data-index="0"]');
    initialSlide.classList.add('active');
    initialButton.classList.add('active');
    let sliderControlButton = slider.querySelector('.control-slider-button');
    if (options.autoplay === true) {
      sliderControlButton.classList.add('stop');
    } else {
      sliderControlButton.classList.add('play');
    }
    sliderControlButton.addEventListener('click', function () {
      mySlider.switchAutoplay(options);
    });
    for (let i = 0; i < slides.length; i++) {
      let button = slider.querySelector('.pagination-button[data-index="' + i + '"]');
      button.addEventListener('click', function () {
        mySlider.goToSlide(options, i);
        mySlider.stopAutoplay(options);
      });
    }
    if (options.autoplay === true) {
      options.autoplayer = window.setTimeout(function () {
        mySlider.goToNext(options);
      }, options.duration);
    }
  },
  switchAutoplay: function (options) {
    let sliderControlButton = options.container.querySelector('.control-slider-button');
    if (options.autoplay === true) {
      mySlider.stopAutoplay(options);
        sliderControlButton.classList.add('play');
        sliderControlButton.classList.remove('stop');
    } else {
      mySlider.startAutoplay(options);
        sliderControlButton.classList.remove('play');
        sliderControlButton.classList.add('stop');
    }
  },
  goToSlide: function (options, target) {
    let slider = options.container;
    let targetSlide = slider.querySelector('.slide[data-index="' + target + '"]');
    if (!targetSlide.classList.contains('active')) {
      let activeSlide = slider.querySelector('.slide.active');
      let activeButton = slider.querySelector('.pagination-button.active');
      let activeNum = activeSlide.dataset.index;
      let targetNum = parseInt(target);
      let go = false;
      let direction = 'left';
      if (targetNum < activeNum) {
        direction = 'right';
      }

      let targetButton = slider.querySelector('.pagination-button[data-index="' + target + '"]');
      activeButton.classList.remove('active');
      targetButton.classList.add('active');

      let moveTarget = function (direction) {
        let correct = direction;
        let opposite = (direction === 'left') ? 'right' : 'left';
        correct = 'hide-' + direction;
        opposite = 'hide-' + opposite;
        targetSlide.classList.add('transitioning');
        window.setTimeout(function () {
          targetSlide.classList.remove(correct);
          targetSlide.classList.add(opposite);
        }, 100);
        window.setTimeout(function () {
          targetSlide.classList.remove('transitioning');
        }, 150);
      };
      let moveActive = function (direction) {
        activeSlide.classList.remove('active');
        direction = 'hide-' + direction;
        activeSlide.classList.add(direction);
      };

      moveTarget(direction);
      window.setTimeout(function () {
        moveActive(direction);
        targetSlide.classList.remove('hide-left');
        targetSlide.classList.remove('hide-right');
        targetSlide.classList.add('active');
      }, 200);
    }
  },
  goToNext: function (options) {
    if (options.autoplay === true) {
      let slider = options.container;
      let currentSlide = slider.querySelector('.slide.active');
      let currentSlideIndex = currentSlide.dataset.index;
      let lastSlide = slider.querySelectorAll('.slide').length - 1;
      let nextSlide = 0;
      if (currentSlideIndex != lastSlide) {
        nextSlide = parseInt(currentSlideIndex) + 1;
      }
      mySlider.goToSlide(options, nextSlide);
      options.autoplayer = window.setTimeout(function () {
        mySlider.goToNext(options);
      }, options.duration);
    }
  },
  stopAutoplay: function (options) {
    options.autoplay = false;
    window.clearTimeout(options.autoplayer);
  },
  startAutoplay: function (options) {
    options.autoplay = true;
    options.autoplayer = window.setTimeout(function () {
      mySlider.goToNext(options);
    }, options.duration);
  }
};

let mainSlider = document.getElementById('main-slider');
let mainSliderOptions = {
  container: mainSlider,
  autoplay: false,
  duration: 6000
}
mySlider.initializeSlider(mainSliderOptions);

The pagination buttons are functioning well in Chrome, although in Safari, they sometimes flicker or get clipped after you click on them. Is there a solution or workaround to resolve this flickering issue? I'm unsure of what might be causing it.

Answer №1

Solution to fix flickering buttons in -webkit- browsers: Implement the following CSS workaround.

-webkit-perspective: 1000;
-webkit-backface-visibility: hidden;
-webkit-transform: translate3d(0,0,0);

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Integrate worldwide sass into Angular 4 using webpack

I'm facing an issue with my Angular 4 project that uses webpack with HMR. Just to note, I am integrating it with ASP Core 2 using the angular template. My goal is to create a global/main SCSS file that will be applied to all components. I want this S ...

Utilizing Angular 2+ with the [innerHTML] property to incorporate HTML with added style attributes

I am currently utilizing Angular 2+ [innerHTML] input for inserting HTML formatting that includes style tags. Within my template, the code looks like this: <span [innerHTML]="someVar"></span> In the component file, I have defined: someVar = ...

Master the art of horizontal scrolling in React-Chartsjs-2

I recently created a bar chart using react.js and I need to find a way to enable horizontal scrolling on the x-axis as the number of values increases. The chart below displays daily search values inputted by users. With over 100 days worth of data already, ...

Why are my menu and title shifting as I adjust the page size?

I'm having trouble finalizing my menu and headings. Whenever I resize the browser window, they shift to the right instead of staying centered as I want them to. I would really appreciate any help with this. Below is the HTML and CSS code. var slide ...

The onbeforeunload event should not be triggered when the page is refreshed using a clicked button

Incorporated into my webpage is a sign-up form. I would like it to function in a way that if the user accidentally refreshes, closes the tab, or shuts down the browser after entering information, a specific message will appear. <input type="text" place ...

In Nodejs, there is a way to determine the size of a document stored

I have a question: How can I determine the size of a cursor, in terms of kilobytes (KB), without actually fetching it? I've come across various sources, such as this post on Stack Overflow, but I don't want to retrieve the query result just to f ...

The process of transforming four columns into two columns and two rows

I am aiming to create a layout that displays 4 columns on desktop and then breaks down into 2 columns and 2 rows on smaller screens. https://i.stack.imgur.com/GZ4nQ.png https://i.stack.imgur.com/5ZCrQ.png Any suggestions on how I can achieve this layout ...

Effortless login authentication using Disqus through Google or Facebook tokens

I have set up my website to allow users to authenticate through Google and Facebook using passport, which uses the OAuth 2.0 API. Additionally, I am utilizing Disqus to manage the comments system on my site. However, I am running into a problem where user ...

Looking to rearrange the layout of jqgrid

I need to reposition the jqgrid away from its default top left position. I have attempted some adjustments but they are not working as expected. Below is the code snippet for your review and suggestions: Here is the HTML code snippet: <div> &l ...

What is the best way to implement a subquery using EXISTS in Knex?

I'm currently facing challenges while constructing a query using knex, specifically when it comes to incorporating the 'WHERE' clause with the condition EXISTS (SELECT * FROM caregiver_patient WHERE patient_id IN (0,1)). Below is the origin ...

Generating random indexes for the Answer button to render

How can we ensure that the correct button within the Question component is not always rendered first among the mapped incorrect buttons for each question? Is there a way to randomize the positions of both correct and incorrect answers when displaying them, ...

Is there a way to extract information from an HttpClient Rest Api through interpolation?

I am currently facing an issue with a component in my project. The component is responsible for fetching data from a REST API using the HttpClient, and the data retrieval seems to be working fine as I can see the data being logged in the Console. However, ...

Out-of-sync movement in animated characters

Looking for some assistance with my page coding. I have a scenario where two stars are moving around a button, simulating an animation by incrementing the CSS properties top and left. Initially, everything appears fine and they move synchronously. However, ...

Clever ways to refresh the current page before navigating to a new link using ajax and jQuery

Here's a different perspective <a href="{{$cart_items->contains('id',$productItem->id) ? route('IndexCart'): route('AddToCart')}}" class="item_add" id="{{$productItem->id}}"><p class="number item_price ...

Animate div visibility with CSS transitions and Javascript

I'm currently working on incorporating an animation into a div that I am toggling between showing and hiding with a button click. While I have the desired animation, I am unsure of how to trigger it using JavaScript when the button is clicked. Can any ...

"Improve your Angular ngrx workflow by utilizing the sandbox pattern to steer clear of

Currently, I'm trying to determine whether my implementation of the ngrx and sandbox pattern is effective. Here's the issue I'm facing: getFiles(userId: number, companyId: number) { this.fileService.getFiles(userId, companyId).subscribe(re ...

Using the <ins> element to push content into a separate div lower on the webpage

My text inside the <p> element is being pushed down by the presence of the <ins> tag. Removing the <ins> tag from the DOM using developer tools results in my text returning to its expected position. main { max-width: 1000px; ma ...

Res.render() is failing to display content

I'm facing an issue with my express route where it's not rendering a jade template properly. If I provide the wrong jade template string, I get the usual error indicating that the file couldn't be found to render in the browser. However, wh ...

Is it possible to create a "private" variable by utilizing prototype in JavaScript?

In my JavaScript code, I am trying to have a unique private variable for each "instance," but it seems that both instances end up using the same private variable. func = function(myName) { this.name = myName secret = myName func.prototype.tel ...

Press the toggle switch button to easily switch between two distinct stylesheets

With a looming exam at university, my web design professor has tasked us with creating a website. The unique challenge is to implement a style change by seamlessly switching between two different CSS stylesheets. My idea is to start with a black and white ...