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 🙏

© 2025 – Pkg Stats / Ryan Hefner

sunny-css-transition-switch

v0.0.1

Published

![npm version](https://img.shields.io/npm/v/sunny-css-transition-switch) ![npm downloads](https://img.shields.io/npm/dm/sunny-css-transition-switch) ![license](https://img.shields.io/npm/l/sunny-css-transition-switch)

Downloads

3

Readme

sunny-css-transition-switch

npm version npm downloads license

结合react-router和react-transition-group,提供一个与路由相关的可以使用页面转场特效的Switch组件。

Installation

使用 npm 安装

npm i sunny-css-transition-switch

使用 yarn 安装

yarn add sunny-css-transition-switch

使用 pnpm 安装

pnpm add sunny-css-transition-switch

Usages

以一个h5页面做转场特效举例

先定义父容器基本布局样式 transition-group.scss

/**
页面转场动效基本样式
要求容器内部的page div元素使用绝对定位布局,形成平滑切换效果
 */
.transition-group {
  height: inherit;
  overflow: hidden;

  > div {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
  }
}

然后定义页面转场特效为淡入淡出 slide-in-out.scss

@mixin slide($pass, $direction, $active: false) {
  opacity: $pass;
  transform: translateX($direction);

  @if $active {
    transition: all 500ms;
  }
}

$show: 1;
$hide: 0;
$right: 100%;
$left: -100%;
$center: 0;
$animating: true;

// 下一页准备从右向左淡入
.forward-enter {
  // 页面右侧原点
  @include slide($show, $right);
}

// 上一页准备从左往右淡入
.back-enter {
  // 页面左侧原点
  @include slide($hide, $left);
}

// 淡入进当前视窗里
.forward-enter-active,
.back-enter-active {
  @include slide($show, $center, $animating);
}

// 当前页准备淡出
.forward-exit,
.back-exit {
  // 中间原点
  @include slide($show, $center);
}

// 进入下一页,当前页向左淡出
.forward-exit-active {
  @include slide($hide, $left, $animating);
}

// 放回上一页,当前页向右淡出
.back-exit-active {
  @include slide($hide, $right, $animating);
}

在路由中使用支持转场特效的Switch组件

import React, { FC } from 'react'
import { HashRouter, Route, Link } from 'react-router-dom'
import { CSSTransitionSwitch } from 'sunny-css-transition-switch'
export const App: FC = () => (
  <HashRouter>
    <CSSTransitionSwitch>
      <Route path="/" exact>
        Home Page
        <ul>
          <li>
            <Link to="/page1">Page 1</Link>
          </li>
          <li>
            <Link to="/page2">Page 2</Link>
          </li>
        </ul>
      </Route>
      <Route path="/page1">
        <button onClick={() => history.back()}>back</button>
        Page 1
      </Route>
      <Route path="/page2">
        <button onClick={() => history.back()}>back</button>
        Page 2
      </Route>
    </CSSTransitionSwitch>
  </HashRouter>
)

更多用例代码见源码目录 examples

Browser Compatibility

浏览器兼容性

Changelog

See CHANGELOG.md