Socket
Book a DemoInstallSign in
Socket

@flipify/core

Package Overview
Dependencies
Maintainers
0
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@flipify/core

Flipify is a Type-Safe, Customizable, Concise, and Intuitive Declarative Flip Animation Library.

latest
npmnpm
Version
0.0.6
Version published
Maintainers
0
Created
Source

Flipify

NPM Version NPM Unpacked Size NPM License NPM Downloads NPM Last Update NPM Type Definitions

Flipify is a TypeScript library for declarative Flip animations.

Features

  • Declarative Trigger-Based Animations

    Flipify allows for concise and clear implementation of Flip animations declaratively. Users can create animations with a single trigger function.

  • Strong Type Safety with TypeScript

    Flipify offers detailed and intuitive type definitions, making it reliable and predictable.

  • Flexible Style Customization

    Flipify enables detailed control over style properties to meet diverse requirements while remaining easy to use with default values.

  • Responsive Design Support

    Flipify works seamlessly across various screen sizes.

Installation

npm install @flipify/core
pnpm add @flipify/core
yarn add @flipify/core

Usages

JavaScript

<div id="flip-container"></div>
import { initialize } from '@flipify/core';

document.addEventListener('DOMContentLoaded', () => {
  const container = document.querySelector('div.flip-container');

  console.log(container);

  container.style.width = '100vw';
  container.style.height = '100vh';

  let currentNumber = 97;
  const { trigger } = initialize(container, currentNumber, { useDigit: true });

  const interval = setInterval(() => {
    currentNumber += 1;

    if (trigger) {
      trigger(currentNumber);
    }
  }, 1000);

  window.addEventListener('unload', () => {
    clearInterval(interval);
  });
});

React

import { initialize } from '@flipify/core';
import React, { useEffect, useRef, useState } from 'react';

export const Flip: React.FC = () => {
  const containerRef = useRef<HTMLDivElement>(null);
  const triggerRef = useRef<((value: number) => void) | null>(null);
  const [currentNumber, setCurrentNumber] = useState(0);

  useEffect(() => {
    const container = containerRef.current;

    if (!container) return;

    const { trigger } = initialize(container, currentNumber, { useDigit: true });

    triggerRef.current = trigger;
  }, []);

  useEffect(() => {
    const interval = setInterval(() => {
      setCurrentNumber((prev) => prev + 1);

      if (triggerRef.current) {
        triggerRef.current(currentNumber);
      }
    }, 1000);

    return () => clearInterval(interval);
  }, [currentNumber]);

  return <div ref={containerRef} style={{ height: '50vh' }} />;
};

Options

OptionTypeDescriptionDefaultRemarks
useDigitbooleanToggle digit changefalsetrue, false
animation.durationTDurationAnimation duration500In ms, e.g., 1000, 500
style.card.widthTDimensionWidth of the card300pxCan also use number, e.g., 100px, 20%, 10rem, 100
style.card.heightTDimensionHeight of the card400pxCan also use number, e.g., 200px, 20%, 10rem, 200
style.card.fontSizeTDimensionFont size of the card200pxCan also use number, e.g., 20px, 3rem, 18
style.card.borderRadiusTDimensionBorder radius of card10pxCan also use number, e.g., 10px, 50%, 5
style.centerLine.heightTDimensionHeight of the center line10pxCan also use number, e.g., 2px, 1rem, 5
style.centerLine.backgroundColorTColorBackground color of center line#DDDDDD50E.g., #000000, rgba(0, 0, 0, 0.2)
style.number.colorTColorColor of the number#FFFFFFE.g., white, #ff5722, rgb(0, 0, 0)
style.number.backgroundColorTColorBackground color of number#000000E.g., black, #eeeeee, rgb(255, 255, 255)

Licenses

MIT License

Copyright (c) 2024 HyoungMin.

Keywords

Flip

FAQs

Package last updated on 26 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.