Git Product home page Git Product logo

parallax's Introduction

Overview

sticky-headers

iphoneXR

svgtracing

This module makes it easy to create advanced scroll interactions. There are two ways of using the module:

  • Non-coding: just drag and drop components, you'll be able to control the speed, opacity, rotation, scale etc. of a layer when scrolling.
  • Code overrides: a lot more control and flexibility (see below)!

Check out some quick demos:

Demo File:

Getting started

  • Non-coding:

    1. Drop a ParallaxScroll and connect with the entire scroll content. The usage is exactly the same as the standard Scroll component.
    2. Drop a few ParallaxLayer and connect them with respective content
    3. Tweak the parameters of a ParallaxLayer in the properties panel
    4. Profit!
  • Code overrides:

    1. Drop a ParallaxScroll and connect with the entire scroll content. The usage is exactly the same as the standard Scroll component.
    2. Add an override to any Frames in the scroll content (details below). Yes, it doesn't have to be ParallaxLayer!
    3. Profit!

Code overrides

A simple example: make an item sticky

sticky

import { useSticky, useScroll } from "@framer/lintonye.parallax/code"

export function Sticky100400(): Override {
  // scrollY here is a MotionValue
  const { scrollY } = useScroll()
  // y is a MotionValue too
  const y = useSticky(scrollY, [100, 400])
  // This is short for { y: y }, where the first "y" is the property key, the second "y"
  // is the variable name.
  return { y }
};

You may see an error in Framer's code editor. This is a known bug of Framer. The override still works. Or you can edit the file with an external editor.

import-error

Make an item sticky and then fades away

sticky and fade

import { useSticky, useScroll } from "@framer/lintonye.parallax/code"
import { Override, useTransform } from "framer"

export function Sticky100400(): Override {
  // scrollY here is a MotionValue
  const { scrollY } = useScroll()
  // y is a MotionValue too
  const y = useSticky(scrollY, [100, 400])
  const opacity = useTransform(scrollY, [400, 500], [1, 0])
  // short for { y: y, opacity: opacity }
  return { y, opacity }
};

Move an item move at a different speed

speed

import { useSpeed, useScroll } from "@framer/lintonye.parallax/code"

export function Speed0(): Override {
  const { scrollY } = useScroll()
  const y = useSpeed(scrollY, [0, 1000], 0)
  return { y }
};

export function Speed05(): Override {
  const { scrollY } = useScroll()
  const y = useSpeed(scrollY, [0, 1000], 0.5)
  return { y }
};

export function SpeedMinus1(): Override {
  const { scrollY } = useScroll()
  const y = useSpeed(scrollY, [0, 1000], -1)
  return { y }
};
...

Trigger an animation when scrolling into a range

trigger

import { useTrigger, useScroll } from "@framer/lintonye.parallax/code"
import { useAnimation } from "framer"
export const TriggerAnimation: Override = props => {
  const animate = useAnimation()
  const { scrollY } = useScroll()
  useTrigger(scrollY, [600, 650], direction => {
    animate.start({ rotate: direction > 0 ? 0 : 180 })
  })
  return {
    animate
  }
}

useSticky and other hooks

Check out the documentation here.

Contact

Change Log

  • 12/10/2019 (v1.52)
    • Fix BgColor of ParallaxLayer
    • Allow negative scroll range and values
    • Allow decimal for scale values
  • 10/08/2019
    • Add new hooks: useTrackScrollX, useTrackScrollY
  • 10/04/2019
    • Update to support the latest Framer library (1.1.3)! Yay!
    • You can now control the speed, rotation, scale and opacity of a layer WITHOUT CODE!
    • React Hook based API for more advanced control
  • 02/21/2019
    • Hide internal components
  • 02/03/2019
    • Add support for using object as op, instead of just an array
    • Fixed: onMove op function is always called when a data item is updated inside the function body
    • Now we can return true to ask the next onMove op function to run. If the return value is falsy (e.g. no return value is specified), the function will be only called once per scroll direction.
  • 01/29/2019
    • Fix id conflict issue. Now, as long as the ids are unique within a single scrollOverrides call, things should be fine.
  • 01/26/2019
    • Add support for horizontal scroll. Note: you'll get an error when the scroll direction is "both".
    • Add speed, sticky and snap functions, which work on both horizontal and vertical directions.
  • 01/23/2019
    • Fix issue in speed and sticky that causes layer to jump locations when crossing ranges
  • 01/17/2019
    • Add snapY function
  • 01/16/2019
    • Add support for advanced scroll interactions
  • 01/10/2019
    • Add override functions for sticky scrolls (Doc pending)
  • 10/09/2018
    • Support controlling positions with math expressions
  • 10/08/2018
    • Better performance - (dev note: no more cloning of children)
  • 10/07/2018
    • Better scrolling performance
    • We can now independently configure speed X and Y of a layer.
    • Pin in scroll direction
  • 10/02/2018 - Support horizontal scroll
  • 09/18/2018 - Use Scroll component instead of the hacky div

parallax's People

Contributors

lintonye avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

parallax's Issues

More example of Sin formula or equivalent

Thanks for this awesome plugin.

However its hard to setup "INPUT" formula or any other values for animation, if you could provide few more examples in documentation for those would be very helpful.

Cannot find module "@framer/lintonye.parallax/code/Parallax"

This is throwing an error when using the component in a fresh project.

import {
    scrollOverrides,
    modulate,
    speed,
    sticky,
} from "@framer/lintonye.parallax/code/Parallax"

Cannot find module "@framer/lintonye.parallax/code/Parallax"

I also downloaded the example project and see the same issue.

I'm using Framer X library version 1.0.17

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.