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

touchslider

v2.1.3

Published

slider init

Downloads

15

Readme

TouchSlider

pageSwitch.js 的区别
pageSwitch.js 适用场景为全屏切换,即一切一屏,并且在此基础上实现了超过一百种切换效果。而 TouchSlider.js 则侧重于在滑动效果下,不仅支持全屏切换,还支持不固定尺寸的幻灯切换。
具体使用请参看各组件所提供的示例。

Tips: v2 版为重构版,提高了代码质量,也优化了性能。参数格式有所调整,如果是由旧版本更新,则注意修改调用的参数。

无法滑动?

最新版本的 chrome 的实现了 pointer 事件,pageSwitch 会优先使用 pointer 事件,但是会和系统触摸滚动冲突。 解决该问题,可以通过对滚动容器设置 touch-action 样式来 fix。

.my-slider-container {
    touch-action: pan-y; //横向滚动时 or
    touch-action: pan-x; //纵向滑动时
}

安装

npm install touchslider

如何使用

// 如果使用webpack或者requirejs或者browserify等构建工具,可以这样:
var TouchSlider = require('touchslider');

// 也可以直接在下载本文件,直接在页面中引入

var ts = new TouchSlider('container id', {
    duration: 600, //int 页面过渡时间
    direction: 1, //int 页面切换方向,0横向,1纵向
    start: 0, //int 默认显示页面
    align: 'center', //string 对齐方式,left(top) center(middle) right(bottom)
    mouse: true, //bool 是否启用鼠标拖拽
    mousewheel: false, //bool 是否启用鼠标滚轮切换
    arrowkey: false, //bool 是否启用键盘方向切换
    fullsize: true, //bool 是否全屏幻灯(false为自由尺寸幻灯)
    autoplay: true, //bool 是否自动播放幻灯
    interval: int //bool 幻灯播放时间间隔
});

//调用方法
ts.prev(); //上一张
ts.next(); //下一张
ts.slide(n); //第n张

ts.play(); //播放幻灯
ts.pause(); //暂停幻灯

ts.prepend(DOM_NODE); //前增页面
ts.append(DOM_NODE); //后增页面
ts.insertBefore(DOM_NODE, index); //在index前添加
ts.insertAfter(DOM_NODE, index); //在index后添加
ts.remove(index); //删除第index页面
ts.isStatic(); //是否静止状态

ts.destroy(); //销毁TouchSlider效果对象

/* 事件绑定
 * event可选值:
 *
 * before 页面切换前
 * after 页面切换后
 * dragStart 开始拖拽
 * dragMove 拖拽中
 * dragEnd 结束拖拽
 */
ts.on(event, callback);

兼容性

兼容全平台,包括 IE6+

demo 地址

请点击http://github.boy.im/touchslider/index.html