Skip to content

⬅️ Back to Table of Contents

📄 useTransition/demo

📊 Analysis Summary

Metric Count
🔧 Functions 3
📦 Imports 4
📊 Variables & Constants 2

📚 Table of Contents

🛠️ File Location:

📂 packages/core/useTransition/demo.vue

📦 Imports

Name Source
rand @vueuse/core
TransitionPresets @vueuse/core
useTransition @vueuse/core
shallowRef vue

Variables & Constants

Name Type Kind Value Exported
duration 1500 let/var 1500
greetings string[] let/var [ 'Ahoj', 'Bok', 'Ciao', 'Czesc', 'Hallo', 'Hei', 'Hej', 'Hello', 'Hola', 'Me...

Functions

easeOutElastic(n: number): number

Parameters:

  • n number

Returns: number

Calls:

  • Math.sin
Code
function easeOutElastic(n: number) {
  return n === 0
    ? 0
    : n === 1
      ? 1
      : (2 ** (-10 * n)) * Math.sin((n * 10 - 0.75) * ((2 * Math.PI) / 3)) + 1
}

wordlerp(from: string, target: string, alpha: number): string

Parameters:

  • from string
  • target string
  • alpha number

Returns: string

Calls:

  • from.padEnd
  • target.padEnd
  • from.split
  • arr.join
  • arr[i].charCodeAt
  • target.charCodeAt
  • String.fromCharCode
  • steps.push
  • Math.round
Code
function wordlerp(from: string, target: string, alpha: number) {
  from = from.padEnd(target.length)
  target = target.padEnd(from.length)

  const arr = from.split('')
  const steps = [from]

  while (arr.join('') !== target) {
    for (let i = 0; i < arr.length; i++) {
      const current = arr[i].charCodeAt(0)
      const next = target.charCodeAt(i)

      if (current < next) {
        arr[i] = String.fromCharCode(current + 1)
        break
      }
      else if (current > next) {
        arr[i] = String.fromCharCode(current - 1)
        break
      }
    }
    steps.push(arr.join(''))
  }

  if (alpha <= 0)
    return steps[0]
  if (alpha >= 1)
    return steps[steps.length - 1]
  return steps[Math.round(alpha * (steps.length - 1))]
}

toggle(): void

Returns: void

Calls:

  • rand (from @vueuse/core)
  • greetings.filter
Code
function toggle() {
  baseNumber.value = baseNumber.value === 100 ? 0 : 100
  baseVector.value = [rand(0, 100), rand(0, 100)]
  const arr = greetings.filter(word => word !== baseWord.value)
  baseWord.value = arr[rand(0, arr.length - 1)]
}

Generated by Syntax Scribe