简体   繁体   English

材料设计和 Jquery

[英]Material Design and Jquery

http://codepen.io/alcoven/pen/XJeEQy http://codepen.io/alcoven/pen/XJeEQy

I'm trying to get each one of these circles to activate itself without changing the rest of the circles on click.我试图让这些圈子中的每一个都激活自己,而无需在点击时更改其余圈子。 I was using $(this)('button') and $this.children('blub') when clicked on $('button') Now not only are these not working, but the material circle growth from the center isn't working either.我在点击 $('button') 时使用了 $(this)('button') 和 $this.children('blub') 现在不仅这些不起作用,而且从中心开始的物质圈增长不是工作。 The script above the click function script that slides in content is supposed create a span that slowly fills the bg and fades out.在内容中滑动的点击功能脚本上方的脚本应该创建一个缓慢填充背景并淡出的跨度。

HTML HTML

<button class="blup active">Define<div class="button-text">This is test copy this is test copy this its test copy this is test copy this is test copy.This is test copy this is test copy this its test copy this is test copy this is test copy.</div></button>

<button class="blup active">Describe</button>
<button class="blup active">Discover</button>
<button class="blup active">Design</button>
<button class="blup active">Develop</button>
<button class="blup active">Deliver</button>

JS JS

var addRippleEffect = function (e) {
    var target = e.target;
    if (target.tagName.toLowerCase() !== 'button') return false;
    var rect = target.getBoundingClientRect();
    var ripple = target.querySelector('.ripple');
    if (!ripple) {
        ripple = document.createElement('span');
        ripple.className = 'ripple';
        ripple.style.height = ripple.style.width = Math.max(rect.width, rect.height) + 'px';
        target.appendChild(ripple);
    }
    ripple.classList.remove('show');
    var top = e.pageY - rect.top - ripple.offsetHeight / 4 - document.body.scrollTop;
    var left = e.pageX - rect.left - ripple.offsetWidth / 4 - document.body.scrollLeft;
    ripple.style.top = top + 'px';
    ripple.style.left = left + 'px';
    ripple.classList.add('show');
    ripple.classList.add('grow');
    return false;
}

document.addEventListener('click', addRippleEffect, false);

function morph(){
  var morphSniff = $('button').css('border-radius'); 
  if(morphSniff == "100%"){
    $('button').css('border-radius':'0%');
    $('.button-text').slideToggle();
  }
  else{
    $('button').css('border-radius':'100%');
    $('.button-text').slideToggle();
  }
};
$('button').click(function(){
    morph();
    return false; 
  });

Try to change only clicked circle by providing this context:尝试通过提供this上下文来更改仅单击的圆圈:

function morph() {
    var morphSniff = $(this).css('border-radius');
    if (morphSniff == "100%") {
        $(this).css('border-radius': '0%');
        $('.button-text').slideToggle();
    } else {
        $(this).css('border-radius': '100%');
        $('.button-text').slideToggle();
    }
};

$('button').click(morph);

Demo: http://codepen.io/anon/pen/myBLwm演示: http : //codepen.io/anon/pen/myBLwm

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM