npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue3-swipe-actions

v0.0.1

Published

iOS style swipe actions for Vue3

Downloads

140

Readme

vue3-swipe-actions

**iOS style swipe actions for Vue 3

Thanks List:

1、https://github.com/eCollect/vue-swipe-actions

2、https://github.com/suslik90/vue3-swipe-actions

Installation

npm install --save vue3-swipe-actions
import { SwipeList, SwipeOut } from 'vue3-swipe-actions';

export default {
  components: {
    SwipeOut,
    SwipeList
  }
};

Basic Usage

Import Styles

import 'vue3-swipe-actions/dist/index.css';

SwipeList

SwipeList component is just a helper for listing multiple SwipeOuts.

Props

| Prop | Data Type | Required | Default | Description | | ------------------- | --------- | -------- | ---------------- | ------------------------------------------------------------ | | items | Array | * | | An array with your data | | item-key | String | | id | Your key for :key when list is v-for-ed, if not found array index will used | | disabled | Boolean | | false | if true items will be disabled, and text selection will be possible (on desktop). adds class swipeout--disabled | | item-disabled | Function | | js () => false | A function that receives the item as parameter and returns true case disabled or false if not | | threshold | Number | | 45 | With that property you can fine tune when actions are considered open | | passive-listeners | Boolean | | false | It defines if the touch events should be registered as passive or not | | revealed | Object | | | An object representing the revealed status of the items, key is the index and the value is either left or right, use it with the .sync modifier |

Events

| Event | Payload | Description | | ---------------- | ------- | ------------------------------------------------------------ | | swipeout:click | item | Emitted on single click/tap on the item | | active | Boolean | Emitted when the user is opening/closing the any of the actions |

Methods

| Method | Params | Description | | -------------- | --------------- | ------------------------------------------------------------ | | revealRight | index (number) | Reveals right actions on given index | | revealLeft | index (number) | Reveals left actions on given index | | closeActions | index (number)? | Closes actions on given index, or all if no index given | | isRevealed | index (number) | Returns the revealed status on a given index, either false for closed, or left or right |

SwipeOut

SwipeOut is the main component, representing a single item with it's actions.

Props

| Prop | Data Type | Required | Default | Description | | ----------- | --------- | -------- | ------- | ------------------------------------------------------------ | | disabled | Boolean | | false | if true items will be disabled, and text selection will be possible (on desktop). adds class swipeout--disabled | | threshold | Number | | 45 | With that property you can fine tune when actions are considered open |

Events

| Event | Payload | Description | | -------- | ------- | ------------------------------------------------------------ | | active | Boolean | Emitted when the user is opening/closing the any of the actions |

<swipe-list
	ref="list"
	class="card"
	:disabled="!enabled"
	:items="mockSwipeList"
	item-key="id"
	@swipeout:click="itemClick"
>
	<template v-slot="{ item, index, revealLeft, revealRight, close }">
		<!-- item is the corresponding object from the array -->
		<!-- index is clearly the index -->
		<!-- revealLeft is method which toggles the left side -->
		<!-- revealRight is method which toggles the right side -->
		<!-- close is method which closes an opened side -->
		<div class="card-content">
			<!-- style content how ever you like -->
			<h2>{{ item.title }}</h2>
			<p>{{ item.description }}</p>
			<span>{{ index }}</span>
		</div>
	</template>
	<!-- left swipe side template and v-slot:left="{ item }" is the item clearly -->
	<!-- remove if you dont wanna have left swipe side  -->
	<template v-slot:left="{ item, close }">
		<div class="swipeout-action red" title="remove" @click="remove(item)">
			<!-- place icon here or what ever you want -->
			<i class="fa fa-trash"></i>
		</div>
		<div class="swipeout-action purple" @click="close">
			<!-- place icon here or what ever you want -->
			<i class="fa fa-close"></i>
		</div>
	</template>
	<!-- right swipe side template and v-slot:right"{ item }" is the item clearly -->
	<!-- remove if you dont wanna have right swipe side  -->
	<template v-slot:right="{ item }">
		<div class="swipeout-action blue">
			<!-- place icon here or what ever you want -->
			<i class="fa fa-heart"></i>
		</div>
		<div class="swipeout-action green">
			<!-- place icon here or what ever you want -->
			<i class="fa fa-heart"></i>
		</div>
	</template>
	<template v-slot:empty>
		<div>
			<!-- change mockSwipeList to an empty array to see this slot in action  -->
			list is empty ( filtered or just empty )
		</div>
	</template>
</swipe-list>
export default {
  components: {
    SwipeOut,
    SwipeList
  },
  data() {
    return {
      enabled: true,
      mockSwipeList: [
        {
          id: 0,
          title: "Some title",
          description: "some description"
        },
        {
          id: 1,
          title: "Some title",
          description: "some description"
        },
        {
          id: 2,
          title: "Some title",
          description: "some description"
        }
      ]
    };
  },
  methods: {
    revealFirstRight() {
      this.$refs.list.revealRight(0);
    },
    revealFirstLeft() {
      this.$refs.list.revealLeft(0);
    },
    closeFirst() {
      this.$refs.list.closeActions(0);
    },
    closeAll() {
      this.$refs.list.closeActions();
    },
    remove(item) {
      this.mockSwipeList = this.mockSwipeList.filter(i => i !== item);
      // console.log(e, 'remove');
    },
    itemClick(e) {
      console.log(e, "item click");
	},
    fbClick(e) {
      console.log(e, "First Button Click");
    },
    sbClick(e) {
      console.log(e, "Second Button Click");
	},
  },
}