当前位置: 首页 > news >正文

网站开发的可行性公司网站与营销网站区别

网站开发的可行性,公司网站与营销网站区别,根路径 网站,搜狐新闻手机网这是一款效果非常炫酷的HTML5 SVG汉堡包菜单按钮分段动画特效。该菜单按钮特效在用户点击汉堡包按钮时#xff0c;按钮会分割为多段#xff0c;并旋转变形为关闭按钮的状态。当再次点击该按钮时#xff0c;它会逆向变形为汉堡包图标。该特效是基于Segment.js插件(一款可以只…这是一款效果非常炫酷的HTML5 SVG汉堡包菜单按钮分段动画特效。该菜单按钮特效在用户点击汉堡包按钮时按钮会分割为多段并旋转变形为关闭按钮的状态。当再次点击该按钮时它会逆向变形为汉堡包图标。该特效是基于Segment.js插件(一款可以只绘制和动画某一段SVG路径的js插件)来制作的。使用方法绘制SVG路径这是一个非常复杂的路径动画过程如果我们一帧帧的来分析动画就可以分别绘制出每一条路径。路径动画像下图的样子根据上面的图我们可以得到类似下面的SVG代码。为了便于为菜单按钮添加样式及在JavaScript中调用可以给SVG一个包裹元素并设置其class和ID。CSS样式// The wrapper was defined with a fixed width and height// Note, that the pointer-events property is set to none.// We dont need any pointer events in the entire element..menu-icon-wrapper{position: relative;display: inline-block;width: 34px;height: 34px;pointer-events: none;transition: 0.1s;}// To perform the scaled transform for the second demo.menu-icon-wrapper.scaled{transform: scale(0.5);}// Adjusting the position of the SVG element.menu-icon-wrapper svg{position: absolute;top: -33px;left: -33px;}// Defining the styles for the path elements.menu-icon-wrapper svg path{stroke: #fff;stroke-width: 6px;stroke-linecap: round;fill: transparent;}// Setting the pointer-events property to auto,// and allowing only events for the trigger element.menu-icon-wrapper .menu-icon-trigger{position: relative;width: 100%;height: 100%;cursor: pointer;pointer-events: auto;background: none;border: none;margin: 0;padding: 0;}SVG动画为了使汉堡包图标的上下两条线产生动画效果首先需要初始化它的begin和end值。关于Segment.js的用法可以参考这里。var pathA document.getElementById(pathA),pathC document.getElementById(pathC),segmentA new Segment(pathA, 8, 32),segmentC new Segment(pathC, 8, 32);接下来是两个动画函数它们用于上下两条线条的动画。第一个以线性方式动画路径在其回调函数中调用第二个动画函数。// Linear section, with a callback to the nextfunction inAC(s) { s.draw(80% - 24, 80%, 0.3, {delay: 0.1, callback: function(){ inAC2(s) }}); }// Elastic section, using elastic-out easing functionfunction inAC2(s) { s.draw(100% - 54.5, 100% - 30.5, 0.6, {easing: ease.ease(elastic-out, 1, 0.3)}); }// Running the animationsinAC(segmentA); // top barinAC(segmentC); // bottom bar对于中间的线条只需要重复以上步骤。// Initializevar pathB document.getElementById(pathB),segmentB new Segment(pathB, 8, 32);// Expand the bar a bitfunction inB(s) { s.draw(8 - 6, 32 6, 0.1, {callback: function(){ inB2(s) }}); }// Reduce with a bounce effectfunction inB2(s) { s.draw(8 12, 32 - 12, 0.3, {easing: ease.ease(bounce-out, 1, 0.3)}); }// Run the animationinB(segmentB);以下是将按钮恢复到汉堡包状态的代码。function outAC(s) { s.draw(90% - 24, 90%, 0.1, {easing: ease.ease(elastic-in, 1, 0.3), callback: function(){ outAC2(s) }}); }function outAC2(s) { s.draw(20% - 24, 20%, 0.3, {callback: function(){ outAC3(s) }}); }function outAC3(s) { s.draw(8, 32, 0.7, {easing: ease.ease(elastic-out, 1, 0.3)}); }function outB(s) { s.draw(8, 32, 0.7, {delay: 0.1, easing: ease.ease(elastic-out, 2, 0.4)}); }// Run the animationsoutAC(segmentA);outB(segmentB);outAC(segmentC);最后为了在点击图标的时候开始执行动画可以向下面这样设置事件监听。var trigger document.getElementById(menu-icon-trigger),toCloseIcon true;trigger.onclick function() {if (toCloseIcon) {inAC(segmentA);inB(segmentB);inAC(segmentC);} else {outAC(segmentA);outB(segmentB);outAC(segmentC);}toCloseIcon !toCloseIcon;};浏览器兼容上面的代码可以非常好的完成SVG汉堡包图标的动画但是它们在各个浏览器中的表现有一些不一致。为了解决这个问题可以简单的将SVG放大10倍代码如下然后通过CSS来将SVG缩小10倍。.menu-icon-wrapper svg {transform: scale(0.1);transform-origin: 0 0;}
http://www.zqtcl.cn/news/867855/

相关文章:

  • 博客网站开发思维导图app网站制作公司
  • 池州网站建设有哪些公司兴义网站seo
  • seo优化网站模板网站建设的七大优缺点
  • 天猫国际采取的跨境电商网络营销方式关键词排名优化公司推荐
  • 亳州建设网站做网站文字怎么围绕图片
  • 网站开发 项目计划外链建设给网站起的作用
  • 你好南京网站网站开发实施步骤和说明
  • 文化共享工程网站建设情况wordpress菠菜插件
  • 网站大气是什么意思哈尔滨做网站电话
  • 公司网站站群是什么化妆品网站设计欣赏
  • 网站公司未来计划ppt怎么做平潭做网站
  • 做网站和推广工资多少招聘网站建设价格
  • 网站建设 响应式 北京网架公司十大排名榜
  • 网站推广目标关键词是什么意思网站推广软件工具
  • 哪里可以做免费的物流网站wordpress为什么放弃
  • 做网站需要多少钱 都包括什么高端大气的网站首页
  • 黄石做网站联系最近的国际新闻
  • 网站建设与运营的预算方案淘宝禁止了网站建设类
  • 做网站的顺序编写app的软件
  • 站长联盟个人网站不备案
  • 惠州建设工程交易网站网站服务器失去响应
  • 网站下拉广告iphone app wordpress
  • 网站图片怎样做seo优化如何重新安装wordpress
  • python做网站源码长沙建设网站制作
  • wordpress调用分类的所有子目录龙岩seo公司首荐3火星
  • 聊城市建设工程质量监督站网站wordpress 头部
  • 低价郑州网站建设wordpress是外网吗
  • 互联网门户网站有哪些win10优化大师是官方的吗
  • 深圳品牌做网站公司有哪些公司名称变更网站要重新备案吗
  • 网站网页建设实训心得体会二类电商平台都有哪些