Socket
Socket
Sign inDemoInstall

universal-transition

Package Overview
Dependencies
5
Maintainers
5
Versions
96
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    universal-transition

A universal transition API.


Version published
Weekly downloads
271
decreased by-55.06%
Maintainers
5
Install size
121 kB
Created
Weekly downloads
 

Readme

Source

universal-transition npm

Used to create transition animation.

Supported

browser weex miniApp wechatMiniprogram bytedanceMicroApp

Install

$ npm install universal-transition --save

Usage

import transition from 'universal-transition';

transition(document.querySelector('#box'), {
  transform: 'translate(10px, 20px) scale(1.5, 1.5) rotate(90deg)',
  opacity: '0.5'
}, {
  timingFunction: 'ease',
  delay: 0,
  duration: 1000
}, function() {
  console.log('animation end');
});

Methods

transition(domNode, styles, options, callback)

Supported

browser weex miniApp wechatMiniprogram icon_miniapp_bytedance

Arguments
PropertyTypeDescriptionRequiredDefaultSupported
domNodeDOMNode Specified element,mini app does not support,see below for details[mini app instructions]yes-browser weex
stylesobject See below for detailsyes-
optionsObject options,See below for detailsno-
callbackfunction Triggered after the animation is complete,mini app does not supportno-browser weex

The properties listed below are supported for each environment, and the properties not listed are not guaranteed for each environment.

styles supported attributes and situation description:

PropertyTypeDescriptionDefault
styles.backgroundColorcolorbackground color-
styles.heightlengthLength value-
styles.widthlengthLength value-
styles.opacitynumberOpacity 0-1-
styles.transformstringtransform type,see below for details-

styles.transform supported attributes:

PropertyTypeDescriptionDefault
translate、translateX、translateY`numberpercentage`Specify where the element is moved to
rotate、rotateX、rotateYangleSpecifies the angle at which the element is deflected0
scale、scaleX、scaleYnumberSpecify multiples of zoomed in and out elements1

options:

PropertyTypeDescriptionDefault
options.timingFunctionstringAnimation effect,valid values are:"linear","ease","ease-in","ease-in-out","ease-out"(Unlisted values, there may be compatibility issues)ease
options.delaynumberAnimation delay time0
options.durationnumberAnimation duration0
Return

Mini app return export(),other cases return undefined

Mini app instructions:

Because the mini app can't provide DOMNode, and use animation way is different. So the mini app needs to get the animation content by the export() method and then manually bind to the element.

Usage

<view animation="{{transitionInfo}}"></view>
Page({
  data: {
    transitionInfo: null,
  },
  onShow(){
    const transitionInfo = transition(null, {
      transform: 'translate(10px, 20px) scale(1.5, 1.5) rotate(90deg)',
      opacity: '0.5'
    }, {
      timingFunction: 'ease',
      delay: 0,
      duration: 1000
    });

    this.setData({
      transitionInfo: transitionInfo.export()
    });
  }
})

Keywords

FAQs

Last updated on 19 May 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc