基于jquery和svg实现超炫酷的动画特效


Posted in Javascript onDecember 09, 2014

今天给大家分享一款基于jquery和svg超炫的网页动画。这款动画效果非常炫。下面还有重播、慢速、和反向动画按钮。效果非常漂亮。一起看下效果图:

基于jquery和svg实现超炫酷的动画特效

实现的代码。

html代码:

 <div id="intro">

        <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"

            version="1.1" id="ihtLogo" x="0" y="0" viewbox="0 0 308.8 152.1" xml:space="preserve"

            enable-background="new 0 0 308.8 152.1">

    <style>

        .tomatoLeft, .tomatoRight

        {

            fill: #D74022;

        }

        .bracketLeft, .bracketRight

        {

            fill: #4D4D4F;

        }

        .s2

        {

            fill: none;

            stroke-linecap: round;

            stroke-miterlimit: 10;

            stroke-width: 10;

            stroke: #FFF;

        }

        .tomatoLeaves

        {

            fill: #95D600;

        }

    </style>  

    <polygon points="238.3 152.1 225.6 139.3 283.4 81.5 225.6 23.8 238.3 11 308.8 81.5 " class="bracketRight"/>

    <polygon points="70.5 152.1 0 81.5 70.5 11 83.2 23.8 25.5 81.5 83.2 139.3 " class="bracketLeft"/>

    <g id="tomato">

      <path d="M139.7 17.2C106 18.3 78.6 45.7 77.5 79.4 76.9 98 84.2 114.9 96.3 127l91-91C175.2 23.9 158.3 16.6 139.7 17.2z" class="tomatoLeft"/>

      <path d="M122.3 127c12.1 12.1 29 19.4 47.6 18.8 33.7-1.1 61.1-28.5 62.2-62.2 0.6-18.6-6.7-35.5-18.8-47.6L122.3 127z" class="tomatoRight"/>

      <path d="M128.6 10.9c0-1.5 0-3 0.1-4.5 0.1-1.4 0.8-3.1 0.3-4.5 -0.8-2.5-4.3-2.6-5.5-0.3 -1.8 4.5-2.5 9.2-2.4 14 -6.7 3.2-17 2-24-0.2 5.1 4 11.2 6.7 18 7.5 -6.5 3-12.5 7-17.6 11.9 13.7-9.2 32.4-7.6 44.4 3.7 -1.3-4.6-3.5-8.7-6.4-12.3 7.3-5.2 16.3-7.4 25.1-6.3 -7-2.1-14.2-3-21.5-2.8 3.2-2.1 6-4.7 8.3-7.7 -6.3 3.5-11.4 4.1-18.5 4.4C128.8 13.2 128.7 11.6 128.6 10.9" class="tomatoLeaves"/>

    </g>

  </svg>

        <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"

            version="1.1" id="ihtText" x="0" y="0" viewbox="0 0 148.2 23" enable-background="new 0 0 148.2 23"

            xml:space="preserve">

    <path fill="#D74022" d="M5.3 18.5V19H3.7h-1H1.1v-0.4c0-0.2 0.1-0.4 0.4-0.4 0 0 0.1 0 0.1 0 0.1 0 0.2 0 0.4 0 0.2 0 0.4 0 0.7 0V8.9c-0.2 0-0.4 0-0.5 0 -0.2 0-0.3 0-0.3 0 -0.1 0-0.1 0-0.2 0 0 0-0.1 0-0.1 0 -0.3 0-0.4-0.1-0.4-0.4V8h1.6 1v10.1c0.2 0 0.4 0 0.5 0 0.2 0 0.3 0 0.3 0 0.1 0 0.1 0 0.2 0 0 0 0.1 0 0.1 0C5.2 18.1 5.3 18.3 5.3 18.5zM2.3 4.6C2.3 4.5 2.2 4.4 2.2 4.2c0-0.1 0-0.3 0.1-0.4 0.1-0.1 0.1-0.2 0.2-0.3 0.1-0.1 0.2-0.2 0.3-0.2s0.2-0.1 0.4-0.1c0.1 0 0.3 0 0.4 0.1 0.1 0.1 0.2 0.1 0.3 0.2C4 3.6 4.1 3.7 4.1 3.9 4.2 4 4.2 4.1 4.2 4.2c0 0.1 0 0.3-0.1 0.4C4.1 4.7 4 4.8 3.9 4.9 3.8 5 3.7 5.1 3.6 5.1 3.5 5.2 3.3 5.2 3.2 5.2c-0.1 0-0.3 0-0.4-0.1S2.6 5 2.5 4.9 2.4 4.7 2.3 4.6z"/>

    <path fill="#D74022" d="M14.9 7.6c1.2 0 2.1 0.4 2.8 1.2 0.6 0.8 1 1.8 1 3.1v5.5c0.7 0.1 1.1 0.2 1.3 0.3 0.2 0 0.3 0.2 0.3 0.4V19h-3.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.3-0.9 0.6-1.4 0.8 -0.6 0.2-1.2 0.3-1.9 0.3 -1.4 0-2.8-0.3-3.6-0.6v0 -1.1 -2.1h0.1 0.3 0.9c0.3 0 0.5 0.1 0.5 0.4 0 0.1 0.1 0.4 0.1 1.3 0.6 0.2 1.3 0.2 1.8 0.2 0.3 0 0.6 0 0.8-0.1 0.2-0.1 0.4-0.2 0.6-0.3 0.2-0.1 0.3-0.3 0.3-0.4 0.1-0.2 0.1-0.3 0.1-0.5 0-0.3-0.1-0.5-0.2-0.6 -0.2-0.2-0.4-0.3-0.6-0.4 -0.3-0.1-0.6-0.2-0.9-0.3 -0.3-0.1-0.7-0.2-1-0.3 -0.3-0.1-0.7-0.3-1-0.4 -0.3-0.2-0.6-0.4-0.9-0.6 -0.3-0.2-0.5-0.5-0.6-0.9 -0.2-0.4-0.2-0.8-0.2-1.3 0-0.5 0.1-0.9 0.3-1.3s0.5-0.8 0.8-1.1c0.4-0.3 0.8-0.6 1.3-0.7s1.1-0.3 1.8-0.3c1.1 0 1.7 0.1 3.3 0.6v0 3.2h-0.1 -0.3 -0.9c-0.3 0-0.5-0.1-0.5-0.4 0-0.1-0.1-0.4-0.1-1.2 -0.3-0.1-0.8-0.1-1.3-0.1 -0.5 0-1 0.1-1.3 0.3 -0.3 0.2-0.5 0.5-0.5 0.9 0 0.2 0.1 0.4 0.2 0.6 0.2 0.2 0.4 0.3 0.6 0.4 0.3 0.1 0.6 0.2 0.9 0.3 0.3 0.1 0.7 0.2 1 0.3 0.3 0.1 0.7 0.3 1 0.4s0.6 0.3 0.9 0.6c0.3 0.2 0.5 0.5 0.6 0.8C146.9 14.5 147 14.9 147 15.4z"/>

  </svg>

        <ul class="buttons">

            <li><a id="btnPlay" class="button" href="#">replay</a></li>

            <li><a id="btnSlowMo" class="button" href="#">slow motion</a></li>

            <li><a id="btnReverse" class="button" href="#">reverse</a></li>

        </ul>

    </div>

    <script src='jquery.js'></script>

    <script src='TweenMax.min.js'></script>

    <script>

        var tomato = $('#tomato'), bracketRight = $('.bracketRight'), bracketLeft = $('.bracketLeft'), tomatoLeft = $('.tomatoLeft'), tomatoRight = $('.tomatoRight'), tomatoLeaves = $('.tomatoLeaves'), letters = $('#ihtText path'), $btnPlay = $('#btnPlay'), $btnSlowMo = $('#btnSlowMo'), $btnReverse = $('#btnReverse'), tl;

        tl = new TimelineMax();

        tl.set([tomatoLeft], { xPercent: 23.6 });

        tl.set([tomatoLeaves], { xPercent: 41 });

        tl.set([tomato], {

            xPercent: 2,

            rotation: 13,

            transformOrigin: 'center center'

        });

        tl.set(tomato, { yPercent: -200 });

        tl.set(bracketRight, { xPercent: 200 });

        tl.set(bracketLeft, { xPercent: -200 });

        tl.to([

    bracketRight,

    bracketLeft

], 0.3, {

    xPercent: 0,

    ease: Power4.easeOut

}, 0.5).to(tomato, 0.5, {

    yPercent: 0,

    ease: Bounce.easeOut

}).to(tomato, 0.2, {

    rotation: 0,

    xPercent: -4

}).to([

    tomatoLeft,

    tomatoLeaves

], 0.2, { xPercent: 0 }, 'split').to(tomato, 0.2, {

    rotation: 0,

    xPercent: 0

}, 'split').to(tomatoRight, 0.2, { xPercent: 2 }, 'split').staggerFrom(letters, 0.01, { autoAlpha: 0 }, 0.03).add('end');

        $btnPlay.click(function () {

            tl.timeScale(1).seek(0);

        });

        $btnSlowMo.click(function () {

            tl.timeScale(0.2).seek(0.5);

        });

        $btnReverse.click(function () {

            tl.timeScale(1).seek('end').reverse();

        });

        //@ sourceURL=pen.js

    </script>

css代码:

 #intro

        {

            height: 100vh;

            width: 50%;

            margin: 0 auto;

            overflow: hidden;

        }

        #intro #ihtLogo

        {

            position: absolute;

            top: 50%;

            left: 50%;

            height: 100%;

            width: 50%;

            transform: translate(-50%, -70%);

        }

        #intro #ihtText

        {

            width: 100%;

            position: absolute;

            top: 50%;

            width: 40%;

            left: 50%;

            transform: translate(-50%, 80%);

        }

        .buttons

        {

            position: absolute;

            bottom: 20px;

            left: 20px;

            list-style: none;

            margin: 0;

            padding: 0;

            right: 20px;

        }

        .button

        {

            float: left;

            margin-right: 10px;

            padding: 10px 15px;

            border: 1px #ebebeb solid;

            text-decoration: none;

            color: #222222;

        }
Javascript 相关文章推荐
jquery如何实现锚点链接之间的平滑滚动
Dec 02 Javascript
AngularJS学习笔记(三)数据双向绑定的简单实例
Nov 08 Javascript
利用js+css+html实现固定table的列头不动
Dec 08 Javascript
js实现仿购物车加减效果
Mar 01 Javascript
ES6教程之for循环和Map,Set用法分析
Apr 10 Javascript
浅谈关于axios和session的一些事
Jul 13 Javascript
Vue单文件组件的如何使用方式介绍
Jul 28 Javascript
深入理解JS的事件绑定、事件流模型
May 13 Javascript
bootstrap select2插件用ajax来获取和显示数据的实例
Aug 09 Javascript
解决ng-repeat产生的ng-model中取不到值的问题
Oct 02 Javascript
vscode中eslint插件的配置(prettier配置无效)
Sep 10 Javascript
初学vue出现空格警告的原因及其解决方案
Oct 31 Javascript
Javascript实现禁止输入中文或英文的例子
Dec 09 #Javascript
JavaScript解析json格式数据简单示例
Dec 09 #Javascript
浅谈页面装载js及性能分析方法
Dec 09 #Javascript
深入分析jquery解析json数据
Dec 09 #Javascript
WEB前端设计师常用工具集锦
Dec 09 #Javascript
13 款最热门的 jQuery 图像 360 度旋转插件推荐
Dec 09 #Javascript
JQuery中使用on方法绑定hover事件实例
Dec 09 #Javascript
You might like
解析PHP SPL标准库的用法(遍历目录,查找固定条件的文件)
2013/06/18 PHP
PHP设计模式之观察者模式定义与用法示例
2018/08/04 PHP
jQuery操作Select选择的Text和Value(获取/设置/添加/删除)
2013/03/06 Javascript
Extjs4 GridPanel的主要配置参数详细介绍
2013/04/18 Javascript
在js文件中写el表达式取不到值的原因及解决方法
2013/12/23 Javascript
jquery滚动加载数据的方法
2015/03/09 Javascript
JavaScript jQuery 中定义数组与操作及jquery数组操作
2015/12/18 Javascript
js面向对象实现canvas制作彩虹球喷枪效果
2016/09/24 Javascript
Node.js中常规的文件操作总结
2016/10/13 Javascript
微信小程序  http请求封装详解及实例代码
2017/02/15 Javascript
干货!教大家如何选择Vue和React
2017/03/13 Javascript
Bootstrap实现基于carousel.js框架的轮播图效果
2017/05/02 Javascript
详解vuex的简单使用
2018/03/12 Javascript
javascript原生封装一个淡入淡出效果的函数测试实例代码
2018/03/19 Javascript
vue 本地服务不能被外部IP访问的完美解决方法
2018/10/29 Javascript
详解Vue 换肤方案验证
2019/08/28 Javascript
python中的__slots__使用示例
2015/02/26 Python
利用python实现命令行有道词典的方法示例
2017/01/31 Python
详解Python pygame安装过程笔记
2017/06/05 Python
python3.x上post发送json数据
2018/03/04 Python
Python下调用Linux的Shell命令的方法
2018/06/12 Python
不管你的Python报什么错,用这个模块就能正常运行
2018/09/14 Python
如何在django里上传csv文件并进行入库处理的方法
2019/01/02 Python
Python字符串通过'+'和join函数拼接新字符串的性能测试比较
2019/03/05 Python
python粘包问题及socket套接字编程详解
2019/06/29 Python
利用python、tensorflow、opencv、pyqt5实现人脸实时签到系统
2019/09/25 Python
windows环境中利用celery实现简单任务队列过程解析
2019/11/29 Python
keras做CNN的训练误差loss的下降操作
2020/06/22 Python
店长助理岗位职责
2013/12/13 职场文书
春风行动实施方案
2014/03/28 职场文书
2014年新生军训方案
2014/05/01 职场文书
小学竞选班长演讲稿
2014/09/09 职场文书
公司保洁员岗位职责
2015/02/13 职场文书
2015新学期校长寄语(3篇)
2015/03/25 职场文书
综合办公室主任岗位职责
2015/04/01 职场文书
golang 接口嵌套实现复用的操作
2021/04/29 Golang