短视频软件开发,实现搜索栏逐渐过渡动画

简介: 短视频软件开发,实现搜索栏逐渐过渡动画

短视频软件开发,实现搜索栏逐渐过渡动画相关的代码

import React, {Component} from 'react';
import {
    Animated,
    Easing,
    View,
    StyleSheet,
    TouchableOpacity,
    TextInput
} from 'react-native';
 
var Dimenions = require('Dimensions');
var Width = Dimenions.get('window').width;
 
export default class Ours extends Component {
    constructor() {
        super();
        this.animatedValue = new Animated.Value(0);
        this.state = {
            hidden: true,
            currentAlpha: 0,
            inputText: '',
            placeholder: '',
            opacity: 1,
        }
    }
 
    Animate() {
        this.state.currentAlpha = this.state.currentAlpha == 0 ? 1 : 0;//判断动画运动起止状态
        this.setState({
            opacity: 1
        });
        // this.animatedValue.setValue(0);
        Animated.timing(
            this.animatedValue,
            {
                toValue: this.state.currentAlpha,
                duration: 300,
                easing: Easing.linear
            }
        ).start();
        if (this.state.currentAlpha == 0) {
            this.refs.textInput.blur();
            this.setState({
                inputText: '',
            });
        }
    }
 
    //获取焦点
    _Focus() {
        this.refs.textInput.focus();
    }
 
    //提示文字消失
    _Opacity(text) {
        this.setState({
            inputText: text,
            opacity: 0
        });
    }
 
    render() {
        const ViewWidth = this.animatedValue.interpolate({
            inputRange: [0, 1],
            outputRange: [Width * 0.9, Width * 0.8]
        });
        const Opacity = this.animatedValue.interpolate({
            inputRange: [0, 1],
            outputRange: [0, 1]
        });
        const marginLeft = this.animatedValue.interpolate({
            inputRange: [0, 1],
            outputRange: [Width * 0.3, Width * 0.1]
        });
        return (
            <View style={styles.container}>
                <View style={styles.search}>
                    <TouchableOpacity onPress={this.Animate.bind(this)} style={styles.image}>
                        <Animated.Text style={{
                            opacity: Opacity
                        }}>取消</Animated.Text>
                    </TouchableOpacity>
                    <Animated.View
                        style={{
                            height: 35,
                            width: ViewWidth,
                            backgroundColor: '#efefef',
                            position: 'absolute',
                            top: 0,
                            borderRadius: 10,
                            left: 10
                        }}
                    />
                    <TextInput style={styles.inputs}
                               onFocus={this.Animate.bind(this)}
                               underlineColorAndroid='transparent'
                               // placeholder= "请输入搜索关键字"
                               ref="textInput"
                               onChangeText={this._Opacity.bind(this)}
                               value={this.state.inputText}
                    />
                    <TouchableOpacity style={styles.ProText} onPress={this._Focus.bind(this)}>
                        <Animated.Text style={{
                            left: marginLeft,
                            opacity: this.state.opacity
                        }}>
                            请输入搜索关键字
                        </Animated.Text>
                    </TouchableOpacity>
                </View>
            </View>
        );
    }
 
}
const styles = StyleSheet.create({
    container: {
        flex: 1,
        position: 'relative',
        top: 10
    },
    search: {
        height: 35,
        width: Width,
        position: 'relative',
        top: 0,
    },
    ProText: {
        width: Width * 0.8,
        position: 'absolute',
        top: 6,
        left: 0,
    },
    image: {
        width: Width * 0.1,
        height: Width * 0.1,
        position: 'absolute',
        top: 10,
        right: Width * 0.035,
    },
    inputs: {
        width: Width * 0.7,
        height: 30,
        borderWidth: 1,
        paddingLeft: 5,
        borderColor: '#efefef',
        borderRadius: 4,
        position: 'absolute',
        left: Width * 0.05,
        top: 4
    },
 
});

以上就是短视频软件开发,实现搜索栏逐渐过渡动画相关的代码, 更多内容欢迎关注之后的文章

目录
相关文章
|
16天前
|
UED
Axure高保真原型设计:移动端多选图片上传
本文介绍了如何在Axure中利用中继器实现移动端应用的多选图片上传功能,适用于如微信、微博等社交平台。文章详细描述了主页面、相册页面和大图页面的制作步骤,并展示了如何通过中继器和交互设置实现图片的选择、上传及删除等功能。此教程有助于提升用户体验和应用功能性。
|
2月前
|
前端开发 UED
触屏新体验:CSS动画让移动端底部导航活起来!
触屏新体验:CSS动画让移动端底部导航活起来!
|
2月前
|
开发工具 开发者
如何用 CocosCreator 对接抖音小游戏的侧边栏复访
最近小游戏的软著下来了,用 CocosCreator 做的游戏也完成了 1.0 版本。而当我打包成抖音小游戏进行提交时,还没到初审就给拒了,因为还有一个机审,机器检测到代码中没有接入 “侧边栏复访功能”。这个我还真不知道,那只能去官方看文档了,位置是小游戏开发文档 -> 指南 -> 开放能力 -> 侧边栏能力。
35 2
|
2月前
|
开发者 编解码
界面适应奥秘:从自适应布局到图片管理,Xamarin响应式设计全解析
【8月更文挑战第31天】在 Xamarin 的世界里,构建灵活且适应性强的界面是每位开发者的必修课。本文将带您探索 Xamarin 的响应式设计技巧,包括自适应布局、设备服务协商和高效图片管理,帮助您的应用在各种设备上表现出色。通过 Grid 和 StackLayout 实现弹性空间分配,利用 Device 类检测设备类型以加载最优布局,以及使用 Image 控件自动选择合适图片资源,让您轻松应对不同屏幕尺寸的挑战。掌握这些技巧,让您的应用在多变的市场中持续领先。
26 0
|
2月前
|
前端开发
官网导航更智能:CSS动画下划线,让每一次点击都充满期待!
官网导航更智能:CSS动画下划线,让每一次点击都充满期待!
|
2月前
|
前端开发 UED
设计新潮流:CSS动画毛玻璃按钮,展开效果引人入胜!
设计新潮流:CSS动画毛玻璃按钮,展开效果引人入胜!
|
5月前
短视频 TXUGCRecord工具如何全屏显示
短视频 TXUGCRecord工具如何全屏显示
34 0
|
5月前
|
小程序
【经验分享】使用swiper组件制作文字上下滚动播报效果
【经验分享】使用swiper组件制作文字上下滚动播报效果
229 6
|
10月前
|
前端开发
移动端开发——京东首页制作(流式布局)
移动端开发——京东首页制作(流式布局)
flutter实现底部弹出框以及特色功能
今天项目中要实现底部弹出框并且实现圆角功能,先来预览一下 可以看出实现的公告有 底部圆角,以及朋友圈,微信转发等 实现逻辑我直接代码列出
560 0
flutter实现底部弹出框以及特色功能
下一篇
无影云桌面