令人惊叹的HTML5动画及源码分析下载

HTML5非常酷,利用HTML5制作动画简直让我们忘记了这世界上还有flash的存在。今天我们要分享的一些HTML5动画都还不错,有些动画设计还是挺别出心裁的。另外,每一款HTML5动画都提供源代码下载,并且我们对源码作一些简单的分析。

HTML5可爱的404页面动画 很逗的机器人

利用HTML5绘制的机器人,还会动哦。你可以将它作为一个富有创意的404页面。

核心CSS3代码:

@-webkit-keyframes move {
  0%, 100% {
    -webkit-transform: rotate(0deg) translate3d(0px, 0px, 0px);
    transform: rotate(0deg) translate3d(0px, 0px, 0px);
  }

  25% {
    -webkit-transform: rotate(5deg) translate3d(5px, 5px, 0px);
    transform: rotate(5deg) translate3d(5px, 5px, 0px);
  }

  75% {
    -webkit-transform: rotate(-6deg) translate3d(-5px, 5px, 0px);
    transform: rotate(-6deg) translate3d(-5px, 5px, 0px);
  }
}

@keyframes move {
  0%, 100% {
    -webkit-transform: rotate(0deg) translate3d(0px, 0px, 0px);
    transform: rotate(0deg) translate3d(0px, 0px, 0px);
  }

  25% {
    -webkit-transform: rotate(5deg) translate3d(5px, 5px, 0px);
    transform: rotate(5deg) translate3d(5px, 5px, 0px);
  }

  75% {
    -webkit-transform: rotate(-6deg) translate3d(-5px, 5px, 0px);
    transform: rotate(-6deg) translate3d(-5px, 5px, 0px);
  }
}

在线演示        源码下载

HTML5画图特效 超酷的笔刷动画

这是一款基于HTML5的画笔动画,可以选择不同的笔刷形状,笔刷在画布上移动时就会播放非常绚丽的动画效果。

核心jQuery代码:

var H = 0;

$(‘.button‘).bind(‘mousedown touchstart‘,function(e) {
  $(‘.clicked‘).removeClass(‘clicked‘);
  $(this).addClass(‘clicked‘);
});

$(document).bind(‘mousemove touchmove‘,function(e) {
    e.preventDefault();
    var drawSize = 55;
    var drawType = $(‘.clicked‘).html();
    var floatTypes = Array(‘floatOne‘,‘floatTwo‘,‘floatThree‘,‘floatFour‘,‘floatFive‘);
    var floatType = floatTypes[Math.floor(Math.random()*floatTypes.length)];
    var xPos = e.originalEvent.pageX;
    var yPos = e.originalEvent.pageY;

    $(‘body‘).append(‘<div class="draw" style="font-size:‘+drawSize+‘px;left:‘+xPos+‘px;top:‘+yPos+‘px;-webkit-animation:‘+floatType+‘ .9s 1;-moz-animation:‘+floatType+‘ .9s 1;color:hsla(‘+H+‘,100%,70%,1)">‘+drawType+‘</div>‘);

    $(‘.draw‘).each(function() {
      var div = $(this);
      setTimeout(function() {$(div).remove();},800);
    });
});

setInterval(function() {
  if(H<=360) {H++;}
  else {H=0;}
},10);

在线演示        源码下载

HTML5/jQuery 3D焦点图插件 多种超酷切换动画

焦点图是很传统的jQuery插件,但是这款焦点图基于HTML5,动画特效更加丰富。

在线演示        源码下载

CSS3各大网站分享按钮 带网站Logo小图标

这些按钮样式非常丰富,而且还带有网站的Logo,这些超酷的按钮都是利用CSS3实现的。

核心CSS3代码:

.zocial.icon {
    overflow: hidden;
    max-width: 2.4em;
    padding-left: 0;
    padding-right: 0;
    max-height: 2.15em;
    white-space: nowrap;
}
.zocial.icon:before {
    padding: 0;
    width: 2em;
    height: 2em;

    -webkit-box-shadow: none;

    box-shadow: none;
    border: none;
}
.zocial:active {
    background-image: -webkit-gradient(linear, left top, left bottom, from(rgba(255,255,255,.1)), color-stop(30%, rgba(255,255,255,0)), color-stop(50%, transparent), to(rgba(0,0,0,.1)));
    background-image: -webkit-linear-gradient(bottom, rgba(255,255,255,.1), rgba(255,255,255,0) 30%, transparent 50%, rgba(0,0,0,.1));
    background-image: -webkit-gradient(linear, left bottom, left top, from(rgba(255,255,255,.1)), color-stop(30%, rgba(255,255,255,0)), color-stop(50%, transparent), to(rgba(0,0,0,.1)));
    background-image: linear-gradient(bottom, rgba(255,255,255,.1), rgba(255,255,255,0) 30%, transparent 50%, rgba(0,0,0,.1));
}

在线演示        源码下载

HTML5 SVG环形图表应用 很酷的数据初始动画

很有创意的HTML5图表应用,图表是环形的,初始化时的动画效果也非常不错。

核心jQuery代码:

$(function(){
  $("#doughnutChart").drawDoughnutChart([
    { title: "Tokyo",         value : 120,  color: "#2C3E50" },
    { title: "San Francisco", value:  80,   color: "#FC4349" },
    { title: "New York",      value:  70,   color: "#6DBCDB" },
    { title: "London",        value : 50,   color: "#F7E248" },
    { title: "Sydney",        value : 40,   color: "#D7DADB" },
    { title: "Berlin",        value : 20,   color: "#FFF" }
  ]);
});
/*!
 * jquery.drawDoughnutChart.js
 * Version: 0.3(Beta)
 * Inspired by Chart.js(http://www.chartjs.org/)
 *
 * Copyright 2013 hiro
 * https://github.com/githiro/drawDoughnutChart
 * Released under the MIT license.
 *
 */
;(function($, undefined) {
  $.fn.drawDoughnutChart = function(data, options) {
    var $this = this,
      W = $this.width(),
      H = $this.height(),
      centerX = W/2,
      centerY = H/2,
      cos = Math.cos,
      sin = Math.sin,
      PI = Math.PI,
      settings = $.extend({
        segmentShowStroke : true,
        segmentStrokeColor : "#0C1013",
        segmentStrokeWidth : 1,
        baseColor: "rgba(0,0,0,0.5)",
        baseOffset: 4,
        edgeOffset : 10,//offset from edge of $this
        percentageInnerCutout : 75,
        animation : true,
        animationSteps : 90,
        animationEasing : "easeInOutExpo",
        animateRotate : true,
        tipOffsetX: -8,
        tipOffsetY: -45,
        tipClass: "doughnutTip",
        summaryClass: "doughnutSummary",
        summaryTitle: "TOTAL:",
        summaryTitleClass: "doughnutSummaryTitle",
        summaryNumberClass: "doughnutSummaryNumber",
        beforeDraw: function() {  },
        afterDrawed : function() {  },
        onPathEnter : function(e,data) {  },
        onPathLeave : function(e,data) {  }
      }, options),
      animationOptions = {
        linear : function (t) {
          return t;
        },
        easeInOutExpo: function (t) {
          var v = t<.5 ? 8*t*t*t*t : 1-8*(--t)*t*t*t;
          return (v>1) ? 1 : v;
        }
      },
      requestAnimFrame = function() {
        return window.requestAnimationFrame ||
          window.webkitRequestAnimationFrame ||
          window.mozRequestAnimationFrame ||
          window.oRequestAnimationFrame ||
          window.msRequestAnimationFrame ||
          function(callback) {
            window.setTimeout(callback, 1000 / 60);
          };
      }();

    settings.beforeDraw.call($this);

    var $svg = $(‘<svg width="‘ + W + ‘" height="‘ + H + ‘" viewBox="0 0 ‘ + W + ‘ ‘ + H + ‘" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"></svg>‘).appendTo($this),
        $paths = [],
        easingFunction = animationOptions[settings.animationEasing],
        doughnutRadius = Min([H / 2,W / 2]) - settings.edgeOffset,
        cutoutRadius = doughnutRadius * (settings.percentageInnerCutout / 100),
        segmentTotal = 0;

    //Draw base doughnut
    var baseDoughnutRadius = doughnutRadius + settings.baseOffset,
        baseCutoutRadius = cutoutRadius - settings.baseOffset;
    var drawBaseDoughnut = function() {
        //Calculate values for the path.
        //We needn‘t calculate startRadius, segmentAngle and endRadius, because base doughnut doesn‘t animate.
        var startRadius = -1.570,// -Math.PI/2
            segmentAngle = 6.2831,// 1 * ((99.9999/100) * (PI*2)),
            endRadius = 4.7131,// startRadius + segmentAngle
            startX = centerX + cos(startRadius) * baseDoughnutRadius,
            startY = centerY + sin(startRadius) * baseDoughnutRadius,
            endX2 = centerX + cos(startRadius) * baseCutoutRadius,
            endY2 = centerY + sin(startRadius) * baseCutoutRadius,
            endX = centerX + cos(endRadius) * baseDoughnutRadius,
            endY = centerY + sin(endRadius) * baseDoughnutRadius,
            startX2 = centerX + cos(endRadius) * baseCutoutRadius,
            startY2 = centerY + sin(endRadius) * baseCutoutRadius;
        var cmd = [
          ‘M‘, startX, startY,
          ‘A‘, baseDoughnutRadius, baseDoughnutRadius, 0, 1, 1, endX, endY,
          ‘L‘, startX2, startY2,
          ‘A‘, baseCutoutRadius, baseCutoutRadius, 0, 1, 0, endX2, endY2,//reverse
          ‘Z‘
        ];
        $(document.createElementNS(‘http://www.w3.org/2000/svg‘, ‘path‘))
          .attr({
            "d": cmd.join(‘ ‘),
            "fill": settings.baseColor
          })
          .appendTo($svg);
    }();

    //Set up pie segments wrapper
    var $pathGroup = $(document.createElementNS(‘http://www.w3.org/2000/svg‘, ‘g‘));
    $pathGroup.attr({opacity: 0}).appendTo($svg);

    //Set up tooltip
    var $tip = $(‘<div class="‘ + settings.tipClass + ‘" />‘).appendTo(‘body‘).hide(),
        tipW = $tip.width(),
        tipH = $tip.height();

    //Set up center text area
    var summarySize = (cutoutRadius - (doughnutRadius - cutoutRadius)) * 2,
        $summary = $(‘<div class="‘ + settings.summaryClass + ‘" />‘)
                   .appendTo($this)
                   .css({
                     width: summarySize + "px",
                     height: summarySize + "px",
                     "margin-left": -(summarySize / 2) + "px",
                     "margin-top": -(summarySize / 2) + "px"
                   });
    var $summaryTitle = $(‘<p class="‘ + settings.summaryTitleClass + ‘">‘ + settings.summaryTitle + ‘</p>‘).appendTo($summary);
    var $summaryNumber = $(‘<p class="‘ + settings.summaryNumberClass + ‘"></p>‘).appendTo($summary).css({opacity: 0});

    for (var i = 0, len = data.length; i < len; i++) {
      segmentTotal += data[i].value;
      $paths[i] = $(document.createElementNS(‘http://www.w3.org/2000/svg‘, ‘path‘))
        .attr({
          "stroke-width": settings.segmentStrokeWidth,
          "stroke": settings.segmentStrokeColor,
          "fill": data[i].color,
          "data-order": i
        })
        .appendTo($pathGroup)
        .on("mouseenter", pathMouseEnter)
        .on("mouseleave", pathMouseLeave)
        .on("mousemove", pathMouseMove);
    }

    //Animation start
    animationLoop(drawPieSegments);

    function pathMouseEnter(e) {
      var order = $(this).data().order;
      $tip.text(data[order].title + ": " + data[order].value)
          .fadeIn(200);
      settings.onPathEnter.apply($(this),[e,data]);
    }
    function pathMouseLeave(e) {
      $tip.hide();
      settings.onPathLeave.apply($(this),[e,data]);
    }
    function pathMouseMove(e) {
      $tip.css({
        top: e.pageY + settings.tipOffsetY,
        left: e.pageX - $tip.width() / 2 + settings.tipOffsetX
      });
    }
    function drawPieSegments (animationDecimal) {
      var startRadius = -PI / 2,//-90 degree
          rotateAnimation = 1;
      if (settings.animation && settings.animateRotate) rotateAnimation = animationDecimal;//count up between0~1

      drawDoughnutText(animationDecimal, segmentTotal);

      $pathGroup.attr("opacity", animationDecimal);

      //draw each path
      for (var i = 0, len = data.length; i < len; i++) {
        var segmentAngle = rotateAnimation * ((data[i].value / segmentTotal) * (PI * 2)),
            endRadius = startRadius + segmentAngle,
            largeArc = ((endRadius - startRadius) % (PI * 2)) > PI ? 1 : 0,
            startX = centerX + cos(startRadius) * doughnutRadius,
            startY = centerY + sin(startRadius) * doughnutRadius,
            endX2 = centerX + cos(startRadius) * cutoutRadius,
            endY2 = centerY + sin(startRadius) * cutoutRadius,
            endX = centerX + cos(endRadius) * doughnutRadius,
            endY = centerY + sin(endRadius) * doughnutRadius,
            startX2 = centerX + cos(endRadius) * cutoutRadius,
            startY2 = centerY + sin(endRadius) * cutoutRadius;
        var cmd = [
          ‘M‘, startX, startY,//Move pointer
          ‘A‘, doughnutRadius, doughnutRadius, 0, largeArc, 1, endX, endY,//Draw outer arc path
          ‘L‘, startX2, startY2,//Draw line path(this line connects outer and innner arc paths)
          ‘A‘, cutoutRadius, cutoutRadius, 0, largeArc, 0, endX2, endY2,//Draw inner arc path
          ‘Z‘//Cloth path
        ];
        $paths[i].attr("d", cmd.join(‘ ‘));
        startRadius += segmentAngle;
      }
    }

    function drawDoughnutText(animationDecimal, segmentTotal) {
      $summaryNumber
        .css({opacity: animationDecimal})
        .text((segmentTotal * animationDecimal).toFixed(1));
    }
    function animateFrame(cnt, drawData) {
      var easeAdjustedAnimationPercent =(settings.animation)? CapValue(easingFunction(cnt), null, 0) : 1;
      drawData(easeAdjustedAnimationPercent);
    }
    function animationLoop(drawData) {
      var animFrameAmount = (settings.animation)? 1 / CapValue(settings.animationSteps, Number.MAX_VALUE, 1) : 1,
          cnt =(settings.animation)? 0 : 1;
      requestAnimFrame(function() {
          cnt += animFrameAmount;
          animateFrame(cnt, drawData);
          if (cnt <= 1) {
            requestAnimFrame(arguments.callee);
          } else {
            settings.afterDrawed.call($this);
          }
      });
    }
    function Max(arr) {
      return Math.max.apply(null, arr);
    }
    function Min(arr) {
      return Math.min.apply(null, arr);
    }
    function isNumber(n) {
      return !isNaN(parseFloat(n)) && isFinite(n);
    }
    function CapValue(valueToCap, maxValue, minValue) {
      if (isNumber(maxValue) && valueToCap > maxValue) return maxValue;
      if (isNumber(minValue) && valueToCap < minValue) return minValue;
      return valueToCap;
    }
    return $this;
  };
})(jQuery);

在线演示        源码下载

HTML5迷你音乐播放器 3D翻转播放按钮

很有创意的HTML5音乐播放器,而且播放按钮还有3D的动画效果,整个播放器也是相当迷你。

核心jQuery代码:

// Most of this is all Dave Rupert
// See http://codepen.io/davatron5000/pen/uqktG

(function(){
  $(".play-pause").click(function() {

   if($(this).hasClass(‘pausing‘)){
      $(this).removeClass(‘pausing‘);
      $(this).addClass(‘playing‘);
      $(this).css("background-image", "url(http://dev.steelehouse.com/codepen/play-to-pause-faster.gif)");
      audio.play();
  }
  else if($(this).hasClass(‘playing‘)){
      $(this).removeClass(‘playing‘);
      $(this).addClass(‘pausing‘);
      $(this).css("background-image", "url(http://dev.steelehouse.com/codepen/pause-to-play-faster.gif)");
      audio.pause();
  }
  else {
    $(this).addClass(‘playing‘);
    $(this).css("background-image", "url(http://dev.steelehouse.com/codepen/play-to-pause-faster.gif)");
    audio.play();
  }

});

  var pcastPlayers = document.querySelectorAll(‘.player-container‘);
  var speeds = [ 1, 1.5, 2, 2.5, 3, 0.5 ]    

  for(i=0;i<pcastPlayers.length;i++) {
    var player = pcastPlayers[i];
    var audio = player.querySelector(‘audio‘);/*
    var play = player.querySelector(‘.play-pause.playing‘);
    var pause = player.querySelector(‘.play-pause.pausing‘);*/

    var progress = player.querySelector(‘.pcast-progress‘);

    var currentTime = player.querySelector(‘.pcast-currenttime‘);

    var currentSpeedIdx = 0;

    var toHHMMSS = function ( totalsecs ) {
        var sec_num = parseInt(totalsecs, 10); // don‘t forget the second param
        var hours   = Math.floor(sec_num / 3600);
        var minutes = Math.floor((sec_num - (hours * 3600)) / 60);
        var seconds = sec_num - (hours * 3600) - (minutes * 60);

        if (hours   < 10) {hours   = "0"+hours; }
        if (minutes < 10) {minutes = ""+minutes;}
        if (seconds < 10) {seconds = "0"+seconds;}

        var time = hours+‘:‘+minutes+‘:‘+seconds;
        if (hours   <= 1) { var time = minutes+‘:‘+seconds; }

        return time;
    }

    audio.addEventListener(‘loadedmetadata‘, function(){
      progress.setAttribute(‘max‘, Math.floor(audio.duration));
      duration.textContent  = toHHMMSS(audio.duration);
    });

    audio.addEventListener(‘timeupdate‘, function(){
      progress.setAttribute(‘value‘, audio.currentTime);
      currentTime.textContent  = toHHMMSS(audio.currentTime);
    });

/*    play.addEventListener(‘click‘, function(){
      this.style.display = ‘none‘;
      pause.style.display = ‘inline-block‘;
      pause.focus();
      audio.play();
    }, false);

    pause.addEventListener(‘click‘, function(){
      this.style.display = ‘none‘;
      play.style.display = ‘inline-block‘;
      play.focus();
      audio.pause();
    }, false);
*/

    progress.addEventListener(‘click‘, function(e){
      audio.currentTime = Math.floor(audio.duration) * (e.offsetX / e.target.offsetWidth);
    }, false);

  }
})(this);

在线演示        源码下载

HTML5/CSS3实现蝙蝠侠人物动画 蜘蛛侠变身

用CSS3实现的人物拼接动画,效果非常不错。

核心CSS3代码:

@-webkit-keyframes ani-head-1-0 {
    0% {
        -webkit-transform: translate3d(-322.74999999999994px, 121.99999999999994px, 0px);
        background-color: rgba(53,53,53,1);
    }

    98.912% {
        -webkit-transform: translate3d(67px, 123px, 0px);
        background-color: rgba(53,53,53,1);
    }

    100% {
        -webkit-transform: translate3d(67px, 123px, 0px);
        background-color: rgba(53,53,53,1);
    }
}

@keyframes ani-head-1-0 {
    0% {
        transform: translate3d(-322.74999999999994px, 121.99999999999994px, 0px);
        background-color: rgba(53,53,53,1);
    }

    98.912% {
        transform: translate3d(67px, 123px, 0px);
        background-color: rgba(53,53,53,1);
    }

    100% {
        transform: translate3d(67px, 123px, 0px);
        background-color: rgba(53,53,53,1);
    }
}

在线演示        源码下载

令人惊叹的HTML5动画及源码分析下载

时间: 2024-10-06 03:54:42

令人惊叹的HTML5动画及源码分析下载的相关文章

Hadoop源码分析下载、最新最全资料分享

apache_hadoop源码,下载: http://archive.apache.org/dist/ Hadoop 工具下载: http://hadoop.apache.org/ Hadoop大数据最新最全资料下载地址: http://download.csdn.net/album/detail/3047

cocos2dx骨骼动画Armature源码分析(三)

代码目录结构 cocos2dx里骨骼动画代码在cocos -> editor-support -> cocostudio文件夹中,win下通过筛选器,文件结构如下.(mac下没有分,是整个一坨) armature(目录): animation(目录):动画控制相关. CCProcessBase(文件): ProcessBase(类):CCTween和ArmatureAnimation的基类. CCTWeen(文件): Tween(类):控制flash里一个layer的动画. CCArmatur

html5 Sortable.js 源码分析

最近公司项目经常用到一个拖拽 Sortable.js插件,所以有空的时候看了 Sortable.js 源码,总共1300多行这样,写的挺完美的.拖拽的时候主要由这几个事件完成, ondragstart 事件:当拖拽元素开始被拖拽的时候触发的事件,此事件作用在被拖曳元素上    ondragenter 事件:当拖曳元素进入目标元素的时候触发的事件,此事件作用在目标元素上    ondragover 事件:拖拽元素在目标元素上移动的时候触发的事件,此事件作用在目标元素上    ondrop 事件:被

cocos2dx骨骼动画Armature源码分析(二)

flash中数据与xml中数据关系 上篇博文从总体上介绍了cocos2dx自带的骨骼动画,这篇介绍一下导出的配置数据各个字段的含义(也解释了DragonBone导出的xml数据每个字段的含义). skeleton节点 1 <skeleton name="Dragon" frameRate="24" version="2.2"> name:flash文件名字. frameRate:flash帧率. version:dragonbones

推荐!Html5精品效果源码分享

一直在看别人的汇总,看到了一些不错的关于 HTML5内容的源码,我也汇总下分享出来,好东西需要共享!希望可以帮到需要的朋友. 1.劲爆分享:HTML5动感的火焰燃烧动画特效 这又是一款基于HTML5的超炫动画特效,是一款动感的火焰燃烧动画效果.这款HTML5动画火焰燃烧非常逼真,之前我们也分享过一些其他的HTML5火焰燃烧动画,比如:HTML5 Canvas火焰燃烧动画和纯CSS3实现打火机火焰动画.一般像这样的HTML5动画都是基于Canvas的,今天的这款也不例外.源码下载地址:劲爆分享:H

分享一个很酷很炫的html5特效网站源码

原创整理不易,转载请注明出处:分享一个很酷很炫的html5特效网站源码 代码下载地址:http://www.zuidaima.com/share/1784027301841920.htm 在线演示:http://demo.zuidaima.com/html/1784027301841920/index.html 分享一个很酷很炫的html5特效网站源码

21款网页版html5小游戏源码

html5魅族创意的贪食蛇游戏源码下载 html5网页版打砖块小游戏源码下载 html5 3D立体魔方小游戏源码下载 html5网页版飞机躲避游戏源码下载 html5三国人物连连看游戏源码下载 js html5 2048数字游戏源码_2048网页版源码下载 html5盲打高手打飞字游戏下载_网页版英文打飞字游戏源码下载 jQuery flappy bird电脑版小游戏源码下载 网页版html5 3d俄罗斯方块游戏源码下载 jQuery html5迷宫游戏源码下载 html5网页游戏仿flappy

jQuery源码分析系列(39) : 动画队列

data函数在jQuery中只有短短的300行代码,非常不起点 ,剖析源码的时候你会发现jQuery只要在有需要保存数据的地方无时无刻不依赖这个基础设施 动画会调用队列,队列会调用data数据接口还保存队列里面的的动画数据 所以我们在自习回顾下关于数据缓存 //These may be used throughout the jQuery core codebase //存数据的 //用户使用 data_user = new Data(); //存储对象 //jQuery内部私有 //用来存事件

Android属性动画AnimatorSet源码简单分析

跟上之前的两篇文章 Android属性动画ValueAnimator源码简单分析 Android属性动画ObjectAnimator源码简单分析 继续看AnimatorSet源码的大概过程. AnimatorSet 提供了一种把多个动画放到一起,按照某种特定的顺序来播放,比如一个接一个的播放或者多个动画一起播放. AnimatorSet简单使用随便举一个最简单的例子 //AnimatorSet AnimatorSet animSet = new AnimatorSet(); ObjectAnim