createStyleSheet简单介绍

本文介绍了一个非W3C标准的方法createStyleSheet,该方法允许开发者为IE浏览器创建样式表,参数包括样式表的URL及在styleSheets集合中的索引位置。

简单介绍一下createStyleSheet

 

/*
@param sURL  可选 
@param iIndex 可选 在styleSheets集合里的索引,默认是最后
*/
document.createStyleSheet(sURL,iIndex)
 

非W3C标准,只支持IE.

 

这是我的代码 import React, { PureComponent } from 'react'; import { View, Text, Animated, ImageStyle, StyleProp } from 'react-native'; import { StyleSheet } from 'react-native'; import { createStyleSheet, EmFastImage, getCurrentTheme, rpx } from '@emcd/react-native-treasure-box'; export interface PageBannerFrame1Props { active?: boolean; } interface PageBannerFrame1State {} /** * 组件名称 */ export class PageBannerFrame1 extends PureComponent<PageBannerFrame1Props, PageBannerFrame1State> { animate1 = new Animated.Value(0); animate11 = new Animated.Value(0); animate12 = new Animated.Value(0); animate13 = new Animated.Value(0); animate14 = new Animated.Value(0); constructor(props: PageBannerFrame1Props) { super(props); this.state = {}; } componentDidMount(): void { if (this.props.active) { this.startAnimate(); } } componentDidUpdate( prevProps: Readonly<PageBannerFrame1Props>, prevState: Readonly<PageBannerFrame1State>, snapshot?: any ): void { if (this.props.active && !prevProps.active) { this.resetAnimate(); this.startAnimate(); } } resetAnimate = () => { this.animate1.setValue(0); this.animate11.setValue(0); this.animate12.setValue(0); this.animate13.setValue(0); this.animate14.setValue(0); }; startAnimate = () => { Animated.parallel([ Animated.timing(this.animate1, { toValue: 1, delay: 200, duration: 300, useNativeDriver: false, }), Animated.timing(this.animate11, { toValue: 1, delay: 400, duration: 400, useNativeDriver: true, }), Animated.timing(this.animate12, { toValue: 1, delay: 600, duration: 400, useNativeDriver: true, }), Animated.timing(this.animate13, { toValue: 1, delay: 800, duration: 400, useNativeDriver: true, }), Animated.timing(this.animate14, { toValue: 1, delay: 1000, duration: 400, useNativeDriver: true, }), ]).start(); }; render(): React.ReactNode { const styles = getStyles(); const style1: Animated.WithAnimatedValue<StyleProp<ImageStyle>> = { opacity: this.animate1.interpolate({ inputRange: [0, 1], outputRange: [0, 1], }), transform: [ { scaleX: this.animate1.interpolate({ inputRange: [0, 1], outputRange: [0.5, 1], }), }, { scaleY: this.animate1.interpolate({ inputRange: [0, 1], outputRange: [0.5, 1], }), }, ], }; const style11: Animated.WithAnimatedValue<StyleProp<ImageStyle>> = { opacity: this.animate11.interpolate({ inputRange: [0, 1], outputRange: [0, 1], }), }; const style12: Animated.WithAnimatedValue<StyleProp<ImageStyle>> = { opacity: this.animate12.interpolate({ inputRange: [0, 1], outputRange: [0, 1], }), transform: [ { translateY: this.animate12.interpolate({ inputRange: [0, 1], outputRange: [rpx(50), rpx(0)], }), }, { scaleX: this.animate12.interpolate({ inputRange: [0, 1], outputRange: [0.9, 1], }), }, { scaleY: this.animate12.interpolate({ inputRange: [0, 1], outputRange: [0.9, 1], }), }, ], }; const style13: Animated.WithAnimatedValue<StyleProp<ImageStyle>> = { opacity: this.animate13.interpolate({ inputRange: [0, 1], outputRange: [0, 1], }), transform: [ { translateY: this.animate13.interpolate({ inputRange: [0, 1], outputRange: [rpx(50), rpx(0)], }), }, { scaleX: this.animate13.interpolate({ inputRange: [0, 1], outputRange: [0.9, 1], }), }, { scaleY: this.animate13.interpolate({ inputRange: [0, 1], outputRange: [0.9, 1], }), }, ], }; const style14: Animated.WithAnimatedValue<StyleProp<ImageStyle>> = { opacity: this.animate14.interpolate({ inputRange: [0, 1], outputRange: [0, 1], }), transform: [ { translateY: this.animate14.interpolate({ inputRange: [0, 1], outputRange: [rpx(50), rpx(0)], }), }, { scaleX: this.animate14.interpolate({ inputRange: [0, 1], outputRange: [0.9, 1], }), }, { scaleY: this.animate14.interpolate({ inputRange: [0, 1], outputRange: [0.9, 1], }), }, ], }; return ( <View style={[ styles.box, { opacity: this.props.active ? 1 : 0, }, ]} > <Animated.Image fadeDuration={0} source={require('./images/frames/1.png')} style={[styles.main, style1]} /> <Animated.Image fadeDuration={0} source={require('./images/frames/1.1.png')} style={[styles.icon1, style11]} /> <Animated.Image fadeDuration={0} source={require('./images/frames/1.2.png')} style={[styles.icon2, style12]} /> <Animated.Image fadeDuration={0} source={require('./images/frames/1.3.png')} style={[styles.icon3, style13]} /> <Animated.Image fadeDuration={0} source={require('./images/frames/1.4.png')} style={[styles.icon4, style14]} /> </View> ); } } export const getStyles = () => { const theme = getCurrentTheme(); return createStyleSheet({ box: { width: 700, height: 520, justifyContent: 'flex-end', }, main: { width: 328, height: 441, alignSelf: 'center', }, icon1: { position: 'absolute', left: 0, bottom: 130, width: 163, height: 130, }, icon2: { position: 'absolute', left: 120, top: 80, width: 118, height: 179, }, icon3: { position: 'absolute', left: 360, top: 20, width: 120, height: 160, }, icon4: { position: 'absolute', right: 75, top: 120, width: 119, height: 182, }, }); };
最新发布
11-06
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值