some-react-components / react-scrollchor

A React component for scroll to `#hash` links with smooth animations
ISC License
149 stars 24 forks source link

Global setup for custom animation #35

Closed kspacja closed 5 years ago

kspacja commented 6 years ago

I would have animate always with offset an. Can setup custom animation globally?

bySabi commented 6 years ago

global setup is not implemented right now, PR are welcome.

But can be archive easily with your own React component, for Example. (Caution!!, not tested myself)

./my-scrollchor.jsx

import React, { Component } from "react";
import Scrollchor from "react-scrollchor";

const OFFSET = 100 // global offset 

export function MyScrollchor(props) {
  const { children, ...props } = props;
  return <Scrollchor {...props} animate={{offset: OFFSET}}>{children}</Scrollchor>
}

and ... my-page.jsx

import MyScrollchor from "./my-scrollchor" as Scrollchor;
...
bySabi commented 6 years ago

I will put in the TODO list, create Wiki with some common patterns:

Common Patterns

bySabi commented 5 years ago

PR welcome