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

hcg-swipe

v1.0.2

Published

``` npm install hcg-swipe --save yarn add hcg-swipe --save ```

Downloads

1

Readme

HSwipe

安装方式:

npm install hcg-swipe --save
yarn add hcg-swipe --save

使用方法:

vue-cli脚手架工具中

<template>
	<div class="h-swipe-container" ref="swipe">
		<ul class="h-swipe-wrapper">
			<li class="h-swipe-slide" v-for="item in swipeList" :key="item">
				{{item}}
			</li>
		</ul>
		<div class="h-swipe-pagination"></div>
	</div>
</template>

<script>
	import HSwipe from 'hcg-swipe';

	export default {
		name: "Swipe",
		data() {
            return {
                swipeList: [1,2,3,4,5]
            }
        },
		mounted() {
			this.swipe = new HSwipe({
				el: this.$refs['swipe'],
				pagination: true
			});
		},
		updated() {
			this.$nextTick(() => {
				this.swipe.refresh();
			});
		},
		beforeDestroy() {
			this.swipe = this.swipe.off();
		}
	}
</script>

<style>
	* {
		margin: 0;
		padding: 0;
		list-style:none;
	}
	.h-swipe-slide {
		height: 350px;
		background: #eee;
		text-align: center;
		line-height: 350px;
		font-size: 50px;
		border: 1px solid #fff;
		box-sizing: border-box;
	}
</style>

在html文件中

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport"
	      content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<title>Document</title>
	<style>
		* {
			margin: 0;
			padding: 0;
			list-style:none;
		}
		.h-swipe-slide {
			height: 350px;
			background: #eee;
			text-align: center;
			line-height: 350px;
			font-size: 50px;
			border: 1px solid #fff;
			box-sizing: border-box;
		}
	</style>
	<script src="hcg-swipe/HSwipe.min.js"></script>
</head>
<body>
	<div class="h-swipe-container">
		<ul class="h-swipe-wrapper">
			<li class="h-swipe-slide">1</li>
			<li class="h-swipe-slide">2</li>
			<li class="h-swipe-slide">3</li>
			<li class="h-swipe-slide">4</li>
			<li class="h-swipe-slide">5</li>
		</ul>
		<div class="h-swipe-pagination"></div>
	</div>
</body>
<script>
	let swipe = new HSwipe({
		el: '.h-swipe-container',
		pagination: true,
		transitionEnd(index) {
			console.log(index)
		}
	});
</script>
</html>

配置参数

/**
 * @param {HTMLElement|String} option.el 轮播图外层容器,默认为 h-swipe-container
 * @param {HTMLElement|String} option.wrapper 自定义轮播图wrapper容器选择器,默认为 h-swipe-wrapper
 * @param {HTMLElement|String} option.slide 自定义轮播图slide容器选择器,默认为 h-swipe-slide
 * @param {Number} option.activeIndex 自定义轮播图初始显示的图像,默认为 0
 * @param {Number} option.duration  自定义动画消耗时间,默认800毫秒
 * @param {Number} option.interval  自定义每帧停留时间,默认2000毫秒
 * @param {Object|Boolean} option.pagination 选择配置分页器,传入true则使用默认选项
 * @param {String} option.pagination.el 分页器选择器,默认el为 .h-swipe-pagination
 * @param {String} option.pagination.tagName  分页器生成的标签,默认生成span标签
 * @param {String} option.pagination.pageName  分页器的使用类名,默认使用 h-swipe-page-btn
 * @param {String} option.pagination.activeClass 分页器激活使用的类名,默认激活使用active类名
 * @param {Function} option.transitionEnd 每次动画执行完成之后的回调函数,第一个参数为当前激活的索引
 * */

可以使用的方法:

swipe.refresh(); // 实例上的方法,刷新结构,并重新开始轮播
swipe.off(); // 实例上的方法,关闭swipe
swipe = swipe.off(); // 彻底清除swipe实例