Skip to content

Every little fish swimming around is a visitor on this page right now, and one of them is you ( ´ ▽ ` )ノ If they get in the way of reading, feel free to turn them off.

Eject Input input ​

Characters get ejected at the slightest provocation! ─=≡Σ((( つ•̀ω•́)つ

Tech Keywords ​

NameDescription
Input EventsInput elements provide compositionstart, compositionupdate, and compositionend events for handling IME composition
Canvas 2D APIBasic 2D drawing API that efficiently renders graphics too complex for the DOM
JS AnimationJavaScript-driven animation for more complex, precise control; popular libraries include GSAP and anime.js
Physics SimulationSimulates real-world physics such as gravity, collisions, and velocity
Element computedStyleMap()Gets the computed values of CSS properties on an element
Particle SystemSpawns large numbers of small objects, commonly used to simulate smoke, fire, rain, and snow

Usage Examples ​

Basic Usage ​

Deleted text gets ejected (´,,•ω•,,)

View example source code
vue
<template>
  <div class="w-full flex flex-col items-center p-6">
    <input-eject
      v-model="text"
      class="input-eject p-3"
    />
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import InputEject from '../input-eject.vue'

const text = ref('')
</script>

<style scoped lang="sass">
:deep(.input-eject)
  border: 1px solid #ccc
  border-inline: 2px solid #AAA
</style>

Codfish Begone ​

You can also eject unwanted text ( ´థ౪థ)

(Try typing codfish)

View example source code
vue
<template>
  <div class="w-full flex flex-col items-center p-6">
    <input-eject
      v-model="text"
      class="input-eject p-3"
      :sanitize
    />
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import InputEject from '../input-eject.vue'

const text = ref('')

function sanitize(text: string) {
  return text
    .replace(/c(o)+d/gi, '')
    .replace(/fish/gi, '')
    .replaceAll('鱈魚', '')
}
</script>

<style scoped lang="sass">
:deep(.input-eject)
  border: 1px solid #ccc
  border-inline: 2px solid #AAA
</style>

How It Works ​

Uses canvas to draw the ejected text, resulting in excellent performance.

Source Code ​

API ​

Props ​

interface Props {
  modelValue?: string;
  sanitize?: (text: string) => string;
}

Emits ​

interface Emits {
  'update:modelValue': [value: Props['modelValue']];
}

Methods ​

interface Expose {
  /** 手動彈射字元 */
  ejectText: (text: string) => void;
}

v0.93.1