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

vue-swipeable

v1.1.1

Published

Vue-swipeable is a Vue directive that serves multiple purposes on mobile devices (uses touch events): * Swiping away a component (e.g: disposing a notification) * Partially swiping a component in order to reveal an action underneath * Pulling a component

Downloads

185

Readme

vue-swipeable

Vue-swipeable is a Vue directive that serves multiple purposes on mobile devices (uses touch events):

  • Swiping away a component (e.g: disposing a notification)
  • Partially swiping a component in order to reveal an action underneath
  • Pulling a component in order to trigger a particular action (e.g: pull to refresh) (note: this directive does not break your normal scrolling behaviour)

The combination of the first two will give you a behaviour similar to the one you have with Android notifications (swipe partially to reveal some actions or swipe up to a certain threshold to remove the notification). The third option allows you implement, for example, a "pull to refresh" behaviour.

Installation

npm i vue-swipeable or yarn add vue-swipeable

Demo

Link(source) - Test on a mobile device or in chrome's mobile mode. The directive relies on Touch events, you can't test it on desktop without switching to mobile mode.

Example 1

Simple button with almost the same options as the ones you can find in the configuration section.

Example 2

Example of a button that you can drag to the left or to the right to reveal some kind of action underneath.

Example 3:

A sorta replica of how the mobile notifications work:

  • If you drag to one side by less than 50% of its size you are able to see specific actions underneath
  • If you grad to one side by more than 50% of its size the element goes to the side and disappears

Example 4 (the whole page):

You can drag to the bottom to toggle a refresh action (you can try to set an height greater than your viewport on the body in order to test your scrolling behaviour, you will see that the directive won't break the expected behaviour: it will ignore any touch event if you are not at the top of the page).

Configuration

In your main.ts/main.js file

import { Swipeable } from 'vue-swipeable';
Vue.directive('swipeable', Swipeable);

Then in your desired .vue file:

<template>
 <some-element-or-component v-swipeable="directiveOptions">
 </some-element-or-component>
</template>
<script>
//...
data(): {
  directiveOptions: {
    type: 'horizontal',
    swipeOut: true,
    swipeOutBy: '200px',
    swipeOutThreshold: '50px',
  }
}
//...
</script>

Options

| Option | Description | Allowed values | Default | | ----- | ----- | ----- | ----- | | threshold | Minimum amount of pixels of movement before a swipe is registered | Number (pixels) | 5 | | backTime | Time in seconds taken by the element while returnint to its default position | Number (seconds) | .5 | | swipeTime | Time in seconds taken by element while moving to its swipedOut position | Number (seconds) | .5 | | type | Axix of the swipe | String ('horizontal' or 'vertical') | 'horizontal' | | allowedDirection | The direction to which the swipe should be limited on its axis | String ( 'top', 'bottom', 'left', 'right' or null) | null | | swipeOut | SwipeOut | Boolean | false | | swipeOutBy | How much should the element be swiped out | String ( 5, '5px' or '50%') | '50%' | | swipeOutThreshold | Pixels of movement required to trigger the swipe out logic | String ( 5, '5px' or '50%') | '25%' | | swipeAway | Can the element be completely swiped away | Boolean | false | | swipeAwayBy | How much should the element be swiped away | String ( 5, '5px' or '50%') | '1000%' | | swipeAwayThreshold | Pixels of movement required to trigger the swipe away logic | String ( 5, '5px' or '50%') | '55%' | | max | The max amount of pixel to component can be moved around on its axis (used only if swipeOut and swipeAway are false) | String ( 5, '5px', '50%' or null) | null | | debug | Should the directive print information related to its internal logic | Boolean | false |

Additional Notes

In case of the "allowed value" String ( 5, '5px' or '50%') 5 or '5px' will be automatically interpreted as 5 pixels while '50%' will be interpreted as 50% of the size (width or height depending on type) of the element on which the directives is used on. So in case of a type = 'horizontal' on a button that is 100px wide, a value of '50%' will be interpreted as '50px'.

Events

| Event | Description | Data | | ----- | ----- | ----- | | 'swiped' | Triggered when the user has released the element after a movement greater than the swipeAwayThreshold | {direction: 'top'} ('top', 'bottom', 'left' or 'right') | | 'swiped-away' | Triggered when the user has released the element after a movement greater than the swipeOutThreshold | {direction: 'top'} ('top', 'bottom', 'left' or 'right') |

Known stuff | Issues | Notes

  • Proper validation on the parameters is missing
  • At the moment the directive avoids any disruption only on vertical scrolling

Contacts

[email protected]