question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Wrongly visible on the left / race condition in scrollbarYRight detection

See original GitHub issue

Hi, after a long journey with simplebar and OverlayScrollbars I’ve finally settled on perfect-scrollbar for a larger project, as that was the only one not messing with the container’s styling. It is kind of perfect, really.

One bug I have is that it mistakenly thinks that the scrollbar should be on the left.

What is happening is that scrollbarYRight detection needs to wait a bit, otherwise it gets detected as missing / isNaN / isScrollbarYUsingRight = false.

Problematic part: https://github.com/utatti/perfect-scrollbar/blob/54103fab66ae255ef73aeea57e095385e03c6c01/src/index.js#L119

If I enter:

console.log(railYStyle.right)   -> ''

window.setTimeout(() => {
  console.log(railYStyle.right)  -> '0px'
}, 0)

The first line will output '' while the timeout one will return 0px. Also, 0px is something that should be taken care of, as it’s not an integer.

I’ve seen other issues about left side visibility, I believe they were running into the exact same issue. https://github.com/utatti/perfect-scrollbar/issues/784

I cannot make a fiddle out of it, as in simple example the race condition doesn’t happen.

Ugly workaround:

.ps__rail-y {
  left: auto !important;
}

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:12
  • Comments:11

github_iconTop GitHub Comments

3reactions
andrey-hohlovcommented, Jul 3, 2018

The same problem with Vue directive. Looks like Vue.nextTick() helps.

import Vue from 'vue';
import PS from 'perfect-scrollbar';

const cache = new WeakMap();

export default {
  bind(el, binding) {
    if (typeof window === 'undefined') return;

    const defaults = {
      wheelPropagation: true,
      suppressScrollX: true,
    };

    Vue.nextTick(() => {
      const ps = new PS(el, Object.assign(defaults, binding.value));
      cache.set(el, ps);
    });
  },
  update(el) {
    const ps = cache.get(el);
    if (ps) {
      ps.update();
    }
  },
  componentUpdated(el) {
    const ps = cache.get(el);
    if (ps) {
      ps.update();
    }
  },
  unbind(el) {
    const ps = cache.get(el);
    cache.delete(el);
    if (ps) {
      ps.destroy();
    }
  },
};

1reaction
hakimiocommented, Sep 13, 2022

@handhikadj Try the following CSS fix:

/* Fix for perfect scrollbar appearing on left instead of normal right position */
.ps__rail-y {
    right: 0 !important;
    left: unset !important;
}
.ps__rail-x {
    top: unset !important;
    bottom: 0 !important;
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

perfect-scrollbar - Bountysource
Wrongly visible on the left / race condition in scrollbarYRight detection $ 0 ... is that it mistakenly thinks that the scrollbar should...
Read more >
Race conditions and deadlocks - Visual Basic - Microsoft Learn
A race condition occurs when two threads access a shared variable at the same time. The first thread reads the variable, and the...
Read more >
Catch that glitch: Finding race conditions
Serious problems arise if the output of one thread affects another thread's execution in a way that causes unexpected or incorrect results. But ......
Read more >
Detecting Race Conditions in Large Programs
The race condition checker rccjava statically identifies po- tential races in concurrent ... To identify incorrect annotations, the Houdini algorithm in-.
Read more >
Why Are Race Conditions So Difficult to Detect?
This is referred to as a static detection. Unfortunately, statically detecting race conditions in programs using multiple semaphores is NP-hard (Netzer and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found