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

swiper-effect

v1.0.0

Published

An javascript animate plugin for swiper

Downloads

4

Readme

Desciption

这是一个swiper的js动画插件,语法参考并类似swiper.animate.jsswiper.animate-twice

Usage

  1. 载入jquery.js或者zepto.jsswiper-effect.js
<script src="jquery.js"></script>
<!-- 或者 -->
<script src="zepto.js"></script>
<!-- 如果使用velocity -->
<script src="velocity.js"></script>
<!-- 载入插件 -->
<script src="swiper-effect.js"></script>
  1. 添加动画元素
    eff是默认的动画类名
    data-eff-indata-eff-out是控制默认的dataset。
    dataset支持的语法是<effect>:<args1>,<args2>,... ,表示触发动画时调用effect($effs, args1, args2),如果没有参数,直接<effect>
    而其中的<args>可以是:
    数组 -> [1, 2, 3]
    字符串 -> asd, 或加上单引号'asd',默认只会去掉第一层的单引号,比如,'132'd'就是字符串123'd 数字 -> 123456
    对象 -> duration=1000;delay=500会被转成{duration: 1000, delay: 5000}
<div class="swiper-slide">
<p class="eff" data-eff-in="velocity:slideDown,duration=1000;delay=500" data-eff-out="velocity:slideUp,duration=1000;delay=500">内容</p>
</div>
  1. 添加effect(就是data-eff-in和data-eff-out)调用的函数
// velocity是<effect>的名字,command和opts都是传入的参数
// $effs表示当前slide中所有的动画元素对象
SwiperEffect.addEffect('velocity', function ($effs, command, opts) {
  // 这是velocity.js的1.5版本写法
  // 在这个例子中是:
  // command -> 进入动画是slideUp,推出动画是slideDown
  // opts -> { duration: 1000, delay: 500 }
  $effs.velocity(command, opts)
})
  1. 初始化时隐藏元素并在需要的时刻开始动画
//Swiper5
var mySwiper = new Swiper ('.swiper-container', {
  on:{
    init: function(){
      swiperEffectCache(this); //缓存swiper.slides
      swiperEffect(this); //初始化完成开始动画
    }, 
    slideChangeTransitionEnd: function(){ 
      // 触发动画即调用data-eff-in和data-eff-out表示的函数
      swiperEffect(this); //每个slide切换结束时也运行当前slide动画
      // swiperEffect默认顺序执行in和out动画
      // 如果需要分别控制in和out动画,需要使用swiperEffectIn和swiperEffectOut
    } 
  }
})
  1. 可以更改dataset的名字和动画类名
SwiperEffect.setEffectClass('.ani') // => 类名改成ani
SwiperEffect.setEffectDataSetName('slide')
// => dataset改为data-slide-in和data-slide-out
  1. 如果有多个Swiper实例,也需要有多个SwiperEffect是实例
var otherSwiperEffect = SwiperEffect.factory()
  1. 移除和获取effects,需要注意改变effects会影响到所有SwiperEffect实例
SwiperEffect.getEffects()
SwiperEffect.removeEffect('velocity')