New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

custom-swipe

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

custom-swipe

HTML webcomponents version swipe feature components

latest
Source
npmnpm
Version
0.0.2
Version published
Maintainers
1
Created
Source

swipe_logo

custom-swipe

Custom-Swipe: A Lightweight and Headless Frontend Library

Custom-Swipe is a versatile solution designed for seamless user interactions in web applications. Whether you're building a responsive web app or enhancing the user experience on various devices, Custom-Swipe offers a range of swipe features. It serves as both a basic component for easy integration and a powerful headless hook for developers seeking granular control.

Key Features

  • Lightweight: Minimize your bundle size with our lightweight library.
  • Responsive: Ensure smooth interactions across various devices and screen sizes.
  • Customizable: Tailor swipe behavior to suit your application's specific needs.
  • Headless Hook: For developers who prefer a programmatic approach, our headless hook provides extensive control over swipe events.

Explore the possibilities with Custom-Swipe and elevate your frontend development experience. demo

Install

1.yarn

yarn add custom-swipe

2.npm

npm install custom-swipe

Use Example

  • Use Component
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
  </head>
  <body>
    <h1>swipe</h1>
    <custom-swipe
      direction="column"
      swipecss=".swipe-container{height: 200px; background: blue;} .item {width: 100%;
  height: 200px;
  background-color: aqua;
  border: red 1px solid;} "
      paramname="index"
      isHistory="false"
    >
      <p class="item">1</p>
      <p class="item">2</p>
      <p class="item">3</p>
    </custom-swipe>
  </body>
  <script type="module">
    import {
      useSwipe,
      defineSwipe,
    } from 'https://cdn.jsdelivr.net/npm/custom-swipe@0.0.1/+esm';
    defineSwipe();
    const swipe = document.querySelector('custom-swipe');
    swipe.addEventListener('swipecb', (e) => {
      console.log(e.detail);
    });
  </script>
</html>

  • Use Hook
import { useSwipe } from 'custom-swipe';

const swipeWrap = document.querySelector('.swipe-wrap');
const { events, resize, init } = useSwipe(wrap, {
  isHistory: false,
  paramName: 'index',
  direction: 'row',
  historyCallback: (state) => console.log(state),
});
window.addEventListener('resize', resize, {
  passive: true,
});
for (const [key, value] of Object.entries(events)) {
  wrap.addEventListener(key, value, { passive: true });
}
setTimeout(init, 0);

PROPS

  • custom-swipe(component)
    • children: HTMLElement swipe items.
    • config?: ConfigProps swipe option config.
      • isHistory?: boolean history change or push(default: false)(true ? push : replace).
      • paramName?: string querystring key name(default: index).
      • direction?: row | column use vertical swipe option.(default: row).
    • swipecb: CustomEvents type 'swipecb' swipe end to cb user custom event. detail is swipe state.
  • useSwipe(hook)
    • dom: HTMLElement events target.
    • config?: ConfigProps swipe option config.
      • isHistory?: boolean history change or push(default: false)(true ? push : replace).
      • paramName?: string querystring key name(default: index).
      • historyCallback?: (state: SwipeStateProps) => void swipeEnd event custom callback props swipe state.
      • direction?: row | column use vertical swipe option.(default: row)
  • useSwipe(hook) return
    • swipeEvents: UseSwipeEvents<T>; React Swipe Event handlers.
    • handleSlide: (flag: 'L' | 'R') => void; use Slide handler.
    • changeIndex: (index: number) => void; use goto index handler.
    • resize: VoidFunctionswipe resize events handler.
    • init: VoidFunction swipe init events handler.

Features

  • swipe
  • Infinite swipe(scroll)

LICENSE

MIT

Keywords

webcomponents

FAQs

Package last updated on 09 Feb 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