3

[![enter image description here][1]][1]I am using react trading view widget my client requirement is that it should stop scrolling on fixed button press. I have used this approach but its stopped all mouse events

i need just stop scrolling on chart its serious issue please help:

chartPosition is a state that will change on fixed button pressed just remember this

const NewBoard = ({ ticker, theme, selectedTime, chartPosition }) => {
  return (
    <div
      className="custom-range"
      style={
        chartPosition === "Fixed"
          ? { pointerEvents: "none", height: "75%" }
          : { pointerEvents: "initial", height: "75%" }
      }
    >
      <TradingViewWidget
        id="my_view"
        symbol={ticker}
        theme={theme === "LIGHT" ? Themes.LIGTH : Themes.DARK}
        locale="eng"
        interval={selectedTime}
        autosize={true}
        range={`${chartPosition === "Fixed" ? "ytd" : "all"}`}
        // withdateranges={true}
      />
    </div>
  );
};

I want to stop scrolling inside the chart [1]: https://i.stack.imgur.com/6KfTp.png

Noman
  • 594
  • 1
  • 18

1 Answers1

0

You just must set overflow: hidden :

const NewBoard = ({ ticker, theme, selectedTime, chartPosition }) => {
  return (
    <div
      className={"custom-range " + chartPosition ? "disable-scroll" : ""}
      style={{ overflow: chartPosition === "Fixed" ? "hidden" : "initial", height: "75%" }}
    >
      <TradingViewWidget
        id="my_view"
        symbol={ticker}
        theme={theme === "LIGHT" ? Themes.LIGTH : Themes.DARK}
        locale="eng"
        interval={selectedTime}
        autosize={true}
        range={`${chartPosition === "Fixed" ? "ytd" : "all"}`}
        // withdateranges={true}
      />
    </div>
  );
};

and put this style inside a css file that is imported to your page:

.disable-scroll .chart-container { pointer-events: none }
davood Sandoghsaz
  • 674
  • 1
  • 4
  • 13