jquery点击button按钮触发css3动画弹出层特效代码

所属分类: 网页特效-动画效果    2023-07-27 04:30:57

jquery点击button按钮触发css3动画弹出层特效代码 ie兼容6
反馈问题  查看演示  登录后下载 温馨提示
登录会员即可享受免费下载
 我要建站

jquery点击button按钮触发css3动画弹出层特效代码(共6个文件)

    • script.js
    • index.html
    • style.css

使用方法

var button 			= $('.button');
var content 		= $('.button__content');
var win 				= $(window);

var expand = function() {
  if (button.hasClass('button--active')) {
    return false;
  } else {
    var W 					= win.width();
    var xc 					= W / 2;

    var that 				= $(this);
    var thatWidth 	= that.innerWidth() / 2;
    var thatOffset 	= that.offset();
    var thatIndex		= that.index();
    var other;

    if (!that.next().is('.button')) {
      other = that.prev();
    } else {
      other = that.next();
    }

    var otherWidth		= other.innerWidth() / 2;
    var otherOffset		= other.offset();

    // content box stuff
    var thatContent = $('.button__content').eq(thatIndex);
    var thatContentW = thatContent.innerWidth();
    var thatContentH = thatContent.innerHeight();

    // transform values for button
    var thatTransX 	= xc - thatOffset.left - thatWidth;
    var otherTransX	= xc - otherOffset.left - otherWidth;
    var thatScaleX	= thatContentW / that.innerWidth();
    var thatScaleY	= thatContentH / that.innerHeight();

    that.css({
      'z-index': '2',
      'transform': 'translateX(' + thatTransX + 'px)'
    });

    other.css({
      'z-index': '0',
      'opacity': '0',
      'transition-delay': '0.05s',
      'transform': 'translateX(' + otherTransX + 'px)'
    });

    that.on('transitionend webkitTransitionEnd', function() {
      that.css({
        'transform': 'translateX(' + thatTransX + 'px) scale(' + thatScaleX +',' + thatScaleY + ')',
      });

      that.addClass('button--active');
      thatContent.addClass('button__content--active');
      thatContent.css('transition', 'all 1s 0.1s cubic-bezier(0.23, 1, 0.32, 1)');
      that.off('transitionend webkitTransitionEnd');
    });

    return false;
  }
};

var hide = function(e) {
  var target= $(e.target);
  if (target.is(content)) {
    return;
  } else {
    button.removeAttr('style').removeClass('button--active');
    content.removeClass('button__content--active').css('transition', 'all 0.2s 0 cubic-bezier(0.23, 1, 0.32, 1)');
  }
};

var bindActions = function() {
  button.on('click', expand);
  win.on('click', hide);
};

var init = function() {
  bindActions();
};

init();

站长提示:
1. 平台上所有素材资源,需注册登录会员方能正常下载。
2. 会员用户积极反馈网站、素材资源BUG或错误问题,每次奖励20K币
3. PHP源码类素材,如需协助安装调试,或你有二次开发需求,可联系苦力吧客服。
4. 付费素材资源,需充值后方能下载,如有任何疑问可直接联系苦力吧客服
相关资源 / 动画效果

html5 canvas预期年化收益率圆环进度条效果

html5 canvas预期年化收益率圆环进度条效果
  动画效果
 244  

原生js创意骨头翻滚动画带下拉菜单特效

一款骨头下拉框特效,带表单美化的下拉菜单,很简单实用!
  动画效果
 182  

js+css3全屏2024新年快乐动画特效

一款纯javascript实现的文本文字动画特效,页面带有随机闪烁的星星背景动画,happy new year 2024漂浮上下移动。
  动画效果
 189  

CSS创建的无限循环的动画边框特效代码

一款DIV边框循环动画特效,DIV边框无限循环,类似于走马灯效果。
  动画效果
 205  

评论数(0) 回复有机会获得K币 用户协议

^_^ 还没有人评论,快来抢个沙发!
😀
  • 😀
  • 😊
  • 😂
  • 😍
  • 😑
  • 😷
  • 😵
  • 😛
  • 😣
  • 😱
  • 😋
  • 😎
  • 😵
  • 😕
  • 😶
  • 😚
  • 😜
  • 😭
发表评论