Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

254
Vistas
How to get Smooth-Scrollbar offset values?

Since I have use smooth-scrollbar in my react.js project, it gives an amazing smoothy results in scrolling but the issue I'm facing smooth-scrollbar restricted my all previous Scroll Events.

I noticed that after adding smooth-scrollbar, it makes a custom div named **"scroll-content"** which has 100vh height, 100vw width and it contains our whole project components as a root element, That's why **Window.ScrollY or onScroll** function can't work in this situation, beacuse in this case window has fixed size and it isn't moving anywhere. Only the components inside smooth-scrollbar div are moving up/down.

So I'm trying to get the scrollbar div's transform values. Because this div has an attribute named **"transform: translate3d(0px,0px,0px)"** by deafult, and it change it self after scrolling.

Please help me guys to get this attribute values.

Here is my App.js which simply importing some components.
import React from 'react';
import { Switch, Route } from 'react-router-dom';
import Home from './Home';
import CommingSoon from './CommingSoon';
import Navbar from './components/Navbar';
import Scroll from './components/SmoothScrollbar';

const App = () => {
  
  return (
    <>
      <Scroll />
      <Navbar/>
      <Switch>
        <Route exact path="/comming-soon" component={CommingSoon}/>
        <Route exact path="/" component={Home}/>
      </Switch>
    </>
  );
};

export default App;

And Here is my SmoothScrollbar.js for setting up Scrolling.

import { useEffect } from 'react';
import Scrollbar from 'smooth-scrollbar';
import OverscrollPlugin from 'smooth-scrollbar/plugins/overscroll'

var options = {
    damping: 0.05,
    plugins: {
        overscroll: {...overscrolloptions}
    }
}

var overscrolloptions = {
    enable: true,
    damping: 0.1,
    effect: "bounce",
    maxOverscroll: 150
}

const Scroll = () => {
    useEffect(() => {
        Scrollbar.use(OverscrollPlugin);
        Scrollbar.init(document.body, options);
    }, [])
    return null;
}

export default Scroll;
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You can get offset values in the following way:

 Scrollbar.getAll()[0].addListener(function (status){
    var offset = status.offset;
    // offset.y
 });
about 4 years ago · Juan Pablo Isaza Denunciar

0

I found how to get some offset value

var Scrollbar = window.Scrollbar;

var mainscrollbarOptions = {
    'dumping': 0.08
}

const scrollbar = Scrollbar.init(document.querySelector('#my-scrollbar-container'), mainscrollbarOptions);

scrollbar.addListener(({ offset }) => {
    
    console.log( offset.y ); // offset y position
    console.log( document.querySelector('#my-element').getBoundingClientRect().top ); // my element distance from top
    
});
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda