Skip to content

Commit

Permalink
Remove deltaTime from Fade and AutoScroll.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidjerleke committed Nov 17, 2024
1 parent afdf97a commit 76d3efd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,14 @@ function AutoScroll(userOptions: AutoScrollOptionsType = {}): AutoScrollType {
let rawLocationPrevious = 0
let hasSettled = false

function seek(timeStep: number): ScrollBodyType {
const fixedDeltaTimeSeconds = timeStep / 1000
function seek(): ScrollBodyType {
let directionDiff = 0

previousLocation.set(location)

bodyVelocity = directionSign * options.speed * 55
bodyVelocity = directionSign * options.speed
rawLocation += bodyVelocity
location.add(bodyVelocity * fixedDeltaTimeSeconds)
location.add(bodyVelocity)
target.set(location)

directionDiff = rawLocation - rawLocationPrevious
Expand Down
4 changes: 1 addition & 3 deletions packages/embla-carousel-fade/src/components/Fade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ function Fade(userOptions: FadeOptionsType = {}): FadeType {
const fullOpacity = 1
const noOpacity = 0
const fadeFriction = 0.68
const timeStep = 1000 / 60

let emblaApi: EmblaCarouselType
let opacities: number[] = []
Expand Down Expand Up @@ -218,9 +217,8 @@ function Fade(userOptions: FadeOptionsType = {}): FadeType {

function fade(emblaApi: EmblaCarouselType): void {
const { dragHandler, scrollBody } = emblaApi.internalEngine()
const fixedDeltaTimeSeconds = timeStep / 1000
const pointerDown = dragHandler.pointerDown()
const velocity = scrollBody.velocity() * fixedDeltaTimeSeconds
const velocity = scrollBody.velocity()
const duration = scrollBody.duration()
const fadeIndex = getFadeIndex()
const noFadeIndex = !isNumber(fadeIndex)
Expand Down

0 comments on commit 76d3efd

Please sign in to comment.