2.6.0 • Published 1 month ago

byc-animations v2.6.0

Weekly downloads
-
License
-
Repository
-
Last release
1 month ago

On scroll animation utilities, elements entering viewport + parallax effects. This library uses GSAP and Scrolltrigger.

Visit our demo page

CDN links

DescriptionURL
CSShttps://unpkg.com/byc-animations/bundled/byc-animations.min.css
JShttps://unpkg.com/byc-animations/bundled/byc-animations.min.js
<script>
	let animations
    animations = new BycAnimations();
</script>

Package manager (NPM)

npm install byc-animations

Getting Started

Javacript

import BycAnimations from 'byc-animations';

const animation = new BycAnimations();

Instance settings

OptionTypeDefaultDescription
animateStartstringtop 70%First value represents the part of the trigger which will initiate the animation once it meets the second value. The second value represents a location in the viewport.
animateEndstring''First value represents the part of the trigger which will trigger the animation once it meets the second value. The second value represents a location in the viewport.
animateMarkersboolean, objectfalseEnable visual markers for animate-content during development to see exactly where the start/end/trigger points are. Customization options abound, like markers: {startColor: "green", endColor: "red", fontSize: "12px"}
inViewClassstringin-viewHTML class to apply on an element once its in the viewport.
outViewClassstringout-viewHTML class to apply on an element once its outside the viewport.
parallaxStartstringtop bottomFirst value represents the part of the trigger which will initiate the animation once it meets the second value. The second value represents a location in the viewport.
parallaxEndstring''First value represents the part of the trigger which will trigger the animation once it meets the second value. The second value represents a location in the viewport.
parallaxMarkersboolean, objectfalseEnable visual markers for parallax during development to see exactly where the start/end/trigger points are. Customization options abound, like markers: {startColor: "green", endColor: "red", fontSize: "12px"}
parallaxScrubboolean, numbertrue Boolean: if true, links the animation's progress directly to the ScrollTrigger's progress. Number: The amount of time (in seconds) that the playhead should take to "catch up", so scrub: 0.5 would cause the animation's playhead to take 0.5 seconds to catch up with the scrollbar's position. It's great for smoothing things out.
smoothScrollbooleantrueSet to false to disable lenis smooth scrolling.
scrollDirectionstringverticalScroll direction: vertical or horizontal
scrollGestureDirectionstringverticalYour gesture direction on your trackpad/magic mouse or your touch devices. vertical, horizontal or both
scrollDurationnumber1.2The duration of scroll animation (in seconds).
scrollEasingfunctionMath.min(1, 1.001 - Math.pow(2, -10 * t))The easing function to use for the scroll animation, our default is custom but you can pick one from Easings.net.
scrollInfinitebooleanfalseEnable infinite scrolling.
scrollTouchMultipliernumber2Multiply touch action to scroll faster than finger movement.
scrollWheelMultipliernumber1Multiply wheel action to scroll faster than wheel movement.
scrollWrapperHTMLElement, WindowwindowThe element that will be used as the scroll container.

Styles

SASS

Import the SASS file

@import "byc-animations/dist/byc-animations";

You can override the following variables (need to be done before importing the BYC-animation SASS files):

VariableDefaultDescription
$animate-easingease-in-outDefault transition easing value
$animate-delay0sDefault delay value
$animate-duration0.35sDefault transition duration value
$animate-opacity-duration0.35sDefault opacity duration value
$animate-opacity-start0Default opacity start value
$animate-opacity-end1Default opacity end value
$animate-border-radius0Default border-radius value on reveal pseudo-elements
$animate-background-color#FFFFFFDefault background-color value of reveal animation
$animate-foreground-color#F4F4F4Default foreground-color value of reveal animation
$animate-reveal-delay0.35sDefault reveal delay value
$animate-reveal-duration0.4sDefault reveal duration value
$animate-slide-duration0.65sDefault slide duration value
$animate-slide-offset50pxDefault slide offset value
$animate-zoom-start.5Default zoom start value
$animate-zoom-endnoneDefault zoom end value

CSS

VariableDefaultDescription
--#{$prefix}-animate-easingease-in-outDefault transition easing value
--#{$prefix}-animate-delay0sDefault delay value
--#{$prefix}-animate-duration0.35sDefault transition duration value
--#{$prefix}-animate-opacity-duration0.35sDefault opacity duration value
--#{$prefix}-animate-opacity-start0Default opacity start value
--#{$prefix}-animate-opacity-end1Default opacity end value
--#{$prefix}-animate-border-radius0Default border-radius value on reveal pseudo-elements
--#{$prefix}-animate-background-color#FFFFFFDefault background-color value of reveal animation
--#{$prefix}-animate-foreground-color#F4F4F4Default foreground-color value of reveal animation
--#{$prefix}-animate-reveal-delay0.35sDefault reveal delay value
--#{$prefix}-animate-reveal-duration0.4sDefault reveal duration value
--#{$prefix}-animate-slide-duration0.65sDefault slide duration value
--#{$prefix}-animate-slide-offset50pxDefault slide offset value
--#{$prefix}-animate-zoom-start.5Default zoom start value
--#{$prefix}-animate-zoom-endnoneDefault zoom end value

Markup

<div data-animate="fade">Lorem ipsum</div>
<p data-animate="slide" data-animate-delay=".15">Dolor sit amet consecatur</p>

Element attributes for animate-content function

AttributeTypeDescription
data-animatestring (fade, reveal, slide, zoom)Detect if element is in viewport. Add classes .in-view and .out-view. Applies selected animation (CSS).
data-animate-effectstring (fade, reveal, slide, zoom)Batch method: Detect if targeted elements are in viewport. Add classes .in-view and .out-view. Applies selected animation (CSS).
data-animate-batchstring(Optional) Batch method: Use on wrapper elements and specify which children's class to target. It will apply the desired data-attributes on those.
data-animate-repeatboolean(Optional) Allow to repeat animation every time element enters viewport
data-animate-startstring(Optional) Override default start position. First value represents the part of the trigger which will initiate the animation once it meets the second value. The second value represents a location in the viewport. Ex: top center
data-animate-endstring(Optional) Override default end position. First value represents the part of the trigger which will trigger the animation once it meets the second value. The second value represents a location in the viewport. Ex: center 20%
data-animate-triggerstring(Optional) Override default trigger element. Ex: #page-title
data-animate-easingstring(Optional) Override default easing. Ex: ease-out or cubic-bezier(0.550, 0.055, 0.675, 0.190)
data-animate-delaynumber(Optional) Set transition-delay on element. Value in seconds.
data-animate-durationnumber(Optional) Override default transition duration CSS property. Value in seconds.
data-animate-opacity-durationnumber(Optional) Override default transition duration CSS property of opacity. Value in seconds.
data-animate-opacity-startnumber(Optional) Override default opacity CSS property at the beginning of the animation. Value from 0.0 - 1.0
data-animate-opacity-endnumber(Optional) Override default opacity CSS property at the end of the animation. Value from 0.0 - 1.0
data-animate-border-radiusstring(Optional) Specific to reveal animations, border-radius value in any unit (px, %, rem, em)
data-animate-backgroundstring(Optional) Specific to reveal animations, background-color of the ::before pseudo-element
data-animate-foregroundstring(Optional) Specific to reveal animations, background-color of the ::after pseudo-element
data-animate-reveal-delaynumber(Optional) Specific to reveal animations, delay transition between the background and foreground pseudo-elements. Value in seconds.
data-animate-reveal-durationnumber(Optional) Specific to reveal animations, override default transition duration of background and foreground animations. Value in seconds.
data-animate-slide-durationnumber(Optional) Override default transition duration CSS property of translateY. Value in seconds.
data-animate-slide-offsetstring(Optional) Override default translateY value for "slide" transition. Can be in px or %
data-animate-zoom-startnumber(Optional) Override default scale CSS property at the beginning of the animation. Value is a number or a percentage
data-animate-zoom-endnumber(Optional) Override default scale CSS property at the end of the animation. Value is a number or a percentage

Element attributes for parallax function

AttributeTypeDescription
data-parallax-fromstringDefine the starting values to animate "from". Ex: { "opacity": "1", "translateY": "0" }
data-parallax-tostringDefine the end values to animate "to". Ex: { "opacity": "0.25", "translateY": "-350px" }
data-parallax-startstring(Optional) Override default start position. First value represents the part of the trigger which will initiate the animation once it meets the second value. The second value represents a location in the viewport. Ex: top center
data-parallax-endstring(Optional) Override default end position. First value represents the part of the trigger which will trigger the animation once it meets the second value. The second value represents a location in the viewport. Ex: center 20%
data-parallax-scrubboolean, number(Optional) Boolean: if true, links the animation's progress directly to the ScrollTrigger's progress. Number: The amount of time (in seconds) that the playhead should take to "catch up", so scrub: 0.5 would cause the animation's playhead to take 0.5 seconds to catch up with the scrollbar's position. It's great for smoothing things out.
data-parallax-triggerstring(Optional) Override default trigger element. Ex: #page-title

Instance methods

MethodDescriptionArguments
destroy(animate, scroll)Destroys the scroll events.animate (boolean): Destroy all scroll triggers, true by default.scroll (boolean): Destroy lenis scroll, true by default.
refresh()Recalculates the positioning of all of the ScrollTriggers on the page; this typically happens automatically when the window/scroller resizes but you can force it by calling .refresh()
scrollTo(target, options)Scroll to target.target: goal to reach number: value to scroll in pixelsstring: CSS selector or keyword (top, left, start, bottom, right, end)HTMLElement: DOM element target: goal to reach offset (number): equivalent to scroll-padding-toplerp (number): animation lerp intensityduration (number): animation duration (in seconds)easing (function): animation easingimmediate (boolean): ignore duration, easing and lerplock (boolean): whether or not to prevent the user from scrolling until the target is reachedforce (boolean): reach target even if instance is stoppedonComplete (function): called when the target is reached
start()Resumes the scroll
stop()Pauses the scroll
2.6.0

1 month ago

2.5.2

2 months ago

2.5.0

4 months ago

2.5.1

4 months ago

2.3.0

5 months ago

2.4.0

5 months ago

2.2.1

5 months ago

2.2.0

5 months ago

2.2.3

5 months ago

2.2.2

5 months ago

1.1.2

7 months ago

2.1.0

6 months ago

2.0.0

6 months ago

1.1.1

12 months ago

1.1.0

12 months ago

1.0.2

12 months ago

1.0.1

12 months ago

1.0.0

12 months ago

0.0.13

12 months ago

0.0.12

12 months ago

0.0.11

12 months ago

0.0.10

12 months ago

0.0.9

12 months ago

0.0.8

12 months ago

0.0.7

12 months ago

0.0.5

12 months ago

0.0.4

12 months ago

0.0.3

12 months ago

0.0.2

12 months ago

0.0.1

12 months ago