Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

universal-transition

Package Overview
Dependencies
Maintainers
5
Versions
96
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

universal-transition

A universal transition API.

  • 1.0.1-beta.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
673
increased by3.86%
Maintainers
5
Weekly downloads
 
Created
Source

universal-transition npm

Used to create transition animation.

Supported

browser weex miniApp

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

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

Package last updated on 04 Nov 2019

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc