Scroll To

A handy api to handle calls to window.scrollTo .


Element with id
Element with class name
import { scrollTo } from "@dija/tohama-shared";
import { TButton, TCard, TDivider } from "@dija/tohama-components";
import { defineComponent } from "vue";

export default defineComponent({
  setup() {
    return () => (
      <>
        <TButton
          onClick={() =>
            scrollTo({
              class: document.getElementsByClassName("my-element"),
            })
          }
        >
          Scroll to Element with class name
        </TButton>

        <TDivider my />

        <TCard class="my-element text-center py-35" design="flat" px>
          Element with class name
        </TCard>
      </>
    );
  },
});