Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
css
body { background-color: #42AB40; overflow: hidden; text-align:center; display: flex; align-items: center; justify-content: center; } body, html { height: 100%; width: 100%; margin: 0; padding: 0; } svg { width: 800px; height: 600px; visibility: hidden; overflow:visible; position:fixed; } input{ position:fixed; border:none; outline:none; height:34px; line-height:normal; font-size:25px; width:210px; font-family:'Quicksand', sans-serif; font-weight:700; color:#FBEFF9; background:transparent; text-align:left; } .disabled{ pointer-events:none; } #searchGroup, .close, #search, .hit{ -webkit-tap-highlight-color:transparent; }
JavaScript
var App = /** @class */ (function () { function App() { var _this = this; this.select = function (e) { return document.querySelector(e); }; this.selectAll = function (e) { return document.querySelectorAll(e); }; this.mainTl = new TimelineMax({ paused: true }); this.search = this.select('#search'); this.magnifier = this.select('#magnifier'); this.searchGroup = this.select('#searchGroup'); this.close = this.select('.close'); this.wholeSearch = this.select('.wholeSearch'); this.hit = this.select('#hit'); this.fieldWidth = 301; this.searchWidth = 210; this.seX = -260; this.fieldX = -260; this.growInc = 15; this.magStartX = -200; this.magEndX = -258; this.searchGroupX = 100; this.wholeSearchX = 400; this.searchX = 74; this.minChars = 15; this.maxChars = 26; this.charCount = 1; this.clearField = function (e) { if (_this.search.value == "") { _this.doOutro(); } else { //this.search.value = ""; TweenMax.to(_this.search, 0.2, { value: '', onComplete: _this.resetFieldWidth, ease: Linear.easeNone }); _this.search.focus(); } }; this.doOutro = function (e) { _this.hit.classList.remove('disabled'); _this.searchGroup.classList.remove('disabled'); var outroTl = new TimelineMax({ onComplete: function () { _this.search.value = ""; _this.mainTl.pause(0); } }).timeScale(1); outroTl.to([_this.magnifier, _this.close, _this.search], 0.2, { autoAlpha: 0, ease: Sine.easeIn }) .to('#se', 1, { x: 0, ease: Expo.easeInOut }, '-=0.2') .to('#field', 1, { attr: { width: 41 }, x: 0, ease: Expo.easeInOut }, '-=1') .to(_this.search, 1, { width: _this.searchWidth, x: _this.searchX, ease: Expo.easeInOut }, '-=1') .to(_this.wholeSearch, 1, { attr: { x: 300 }, ease: Expo.easeInOut }, '-=1'); }; this.onKeyDown = function (e) { _this.charCount = _this.search.value.length + 1; if (_this.charCount >= _this.minChars) { var diffChars = _this.charCount - _this.minChars; TweenMax.to('#se', 0.2, { x: _this.seX - (diffChars * _this.growInc) }); TweenMax.to('#field', 0.2, { attr: { width: _this.fieldWidth + (diffChars * _this.growInc) }, x: _this.fieldX - (diffChars * _this.growInc) }); TweenMax.to(_this.search, 0.2, { x: _this.searchX + (diffChars * (_this.growInc / 2)), width: _this.searchWidth + (diffChars * _this.growInc) }); TweenMax.to(_this.magnifier, 0.2, { x: _this.magEndX - (diffChars * _this.growInc) }); TweenMax.to(_this.wholeSearch, 0.2, { attr: { x: _this.wholeSearchX + (diffChars * (_this.growInc / 2)) } }); TweenMax.to(_this.close, 0.2, { x: (diffChars * (_this.growInc / 2)) }); } if (_this.search.value != "") { //this.hit.classList.add('disabled'); //this.searchGroup.classList.add('disabled'); } }; this.resetFieldWidth = function () { var tl = new TimelineMax(); tl.to('#se', 1, { x: _this.seX, ease: Expo.easeInOut }) .to('#field', 1, { attr: { width: _this.fieldWidth }, x: _this.fieldX, ease: Expo.easeInOut }, 0) .to(_this.search, 1, { x: _this.searchX, width: _this.searchWidth, ease: Expo.easeInOut }, 0) .to(_this.magnifier, 1, { x: _this.magEndX, ease: Expo.easeInOut }, 0) .to(_this.wholeSearch, 1, { attr: { x: _this.wholeSearchX }, ease: Expo.easeInOut }, 0) .to(_this.close, 1, { x: 0, ease: Expo.easeInOut }, 0); }; this.clickSearch = function (e) { console.log("clickSearch"); if (_this.mainTl.time() == 0) { _this.mainTl.play(0); } else { _this.doOutro(); } }; this.closeSearch = function (e) { _this.doOutro(); }; TweenMax.globalTimeScale(2); var tl = new TimelineMax(); TweenMax.set(this.search, { x: this.searchX, y: 12, xPercent: -50, yPercent: 0 }); TweenMax.set(this.close, { x: 0, y: 0 }); //this.mainTl.add(tl); this.mainTl.to('#se', 1, { x: this.seX, ease: Expo.easeInOut }) .to('#field', 1, { attr: { width: this.fieldWidth }, x: this.fieldX, ease: Expo.easeInOut }, '-=1') .to(this.wholeSearch, 1, { attr: { x: this.wholeSearchX }, ease: Expo.easeInOut }, '-=1') .fromTo(this.magnifier, 1, { autoAlpha: 0, scale: 0, //rotation:-90, transformOrigin: '0% 45%', x: this.magStartX }, { autoAlpha: 0.38, rotation: 0, scale: 1, transformOrigin: '0% 45%', x: this.magEndX, ease: Expo.easeInOut }, '-=0.95') .fromTo(this.close, 1, { autoAlpha: 0, scale: 0, //rotation:-90, transformOrigin: '50% 50%', svgOrigin: '511 300', x: 0 }, { autoAlpha: 0.5, rotation: 0, scale: 1, transformOrigin: '50% 50%', svgOrigin: '511 300', x: 0, ease: Expo.easeInOut }, '-=1') .from(this.search, 0.5, { autoAlpha: 0 }, '-=0.5') .addPause('+=0', function () { this.search.focus(); }, [], this); this.close.addEventListener('click', this.clearField); this.searchGroup.addEventListener('click', this.clickSearch); this.searchGroup.addEventListener('touchstart', this.clickSearch); this.search.addEventListener('keydown', this.onKeyDown); } return App; }()); TweenMax.set('svg', { visibility: 'visible' }); var app = new App();
粒子
时间
文字
hover
canvas
3d
游戏
音乐
火焰
水波
轮播图
鼠标跟随
动画
css
加载动画
导航
菜单
按钮
滑块
tab
弹出层
统计图
svg
×
Close
在线代码下载提示
开通在线代码永久免费下载,需支付20jQ币
开通后,在线代码模块中所有代码可终身免费下!
您已开通在线代码永久免费下载,关闭提示框后,点下载代码可直接下载!
您已经开通过在线代码永久免费下载
对不起,您的jQ币不足!可通过发布资源 或
直接充值获取jQ币
取消
开通下载
<!doctype html> <html> <head> <meta charset="utf-8"> <title>动画搜索-jq22.com</title> <script src="https://www.jq22.com/jquery/jquery-1.10.2.js"></script> <style>
</style> </head> <body>
<script>
</script>
</body> </html>
2012-2021 jQuery插件库版权所有
jquery插件
|
jq22工具库
|
网页技术
|
广告合作
|
在线反馈
|
版权声明
沪ICP备13043785号-1
浙公网安备 33041102000314号