Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Improve ticker by adding ranking & sort in add() method #149

Merged
merged 3 commits into from
Dec 28, 2024

Conversation

willybrauner
Copy link
Owner

@willybrauner willybrauner commented Dec 28, 2024

Use the initial Interpol ticker instance for all raf callback of the application.
A new second param rank: number is added to add() method. It allows to choose in each order, the callback handker need to be executed. In this exemple, this one is second position, because Interpol ranking is 0

import { InterpolOptions } from "@wbe/interpol"

const tickHandler = (t) => console.log(t)
const rank = 1
InterpolOptions.ticker.add(tickHandler, rank)
// ...
InterpolOptions.ticker.remove(tick)

Using a new ticker instance for all the application:

import { Ticker, InterpolOptions } from "@wbe/interpol"

// disable the default Interpol ticker 
InterpolOptions.disable()

// create a new ticker instance
const ticker = new Ticker()

// Add manually the raf method to the callback list of the new ticker
const interpolTick = (t) => {
  InterpolOptions.ticker.raf(e)
}
ticker.add(interpolTick, 0)

// Add a new callback to this same ticker instance on rank '1'
const scrollerTick = (t) => {
  // ....
}
ticker.add(scrollerTick, 1)

Copy link

changeset-bot bot commented Dec 28, 2024

🦋 Changeset detected

Latest commit: 989ec3c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@wbe/interpol Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@willybrauner
Copy link
Owner Author

willybrauner commented Dec 28, 2024

size-limit report 📦

Path Size
@wbe/interpol 2.82 KB (+1.23% 🔺)

Copy link

codesandbox-ci bot commented Dec 28, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 989ec3c:

Sandbox Source
interpol-basic Configuration
interpol-colors Configuration
interpol-dom-ondrag Configuration
interpol-ease Configuration
interpol-graphic Configuration
interpol-menu Configuration
interpol-object-el Configuration
interpol-particles Configuration
interpol-timeline Configuration
interpol-offsets Configuration

@willybrauner willybrauner self-assigned this Dec 28, 2024
@willybrauner willybrauner force-pushed the improve-ticker branch 3 times, most recently from 2e6a59a to 405f17f Compare December 28, 2024 16:23
@willybrauner willybrauner merged commit dc0f568 into main Dec 28, 2024
3 checks passed
@willybrauner willybrauner deleted the improve-ticker branch December 28, 2024 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant