Wednesday, 30 May 2018

checkbox animation on multiple labels for one input

How do I get the label for .select-label to fire it's css animation when the label for .pick-select is selected?

Instead of having only one label effected by the input change, I want a second label to also react to a change in input and run the same animation for the .pick-select label as it does for the .select-label label.

$(document).ready(function() {
  $(".select-all").on("click", function() {
    $(this).is(":checked") ?
      $(".select-input")
      .prop("checked", true)
      .change() :
      $(".select-input")
      .prop("checked", false)
      .change();
  });
  $("input[name='select-check']:checkbox").change(function() {
    if ($(this).is(":checked")) {
      if ($("input[name='select-check']:checkbox:not(:checked)").length == 0) {
        $(".select-all").prop("checked", true);
      }
      $(this)
        .closest(".shrink")
        .addClass("active");
    } else {
      $(".select-all").prop("checked", false);
      $(this)
        .closest(".shrink")
        .removeClass("active");
    }
  });
});
.pick-select {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 999;
}
.shrink {
  height: 50px;
  width: 50px;
  border: 3px solid;
  position: relative;
  -webkit-transition: all 600ms cubic-bezier(0.19, 1, 0.22, 1);
  -o-transition: all 600ms cubic-bezier(0.19, 1, 0.22, 1);
  transition: all 600ms cubic-bezier(0.19, 1, 0.22, 1);
  -webkit-transform: scale(1);
  -ms-transform: scale(1);
  transform: scale(1);
}
.shrink.active {
  -webkit-transition: all 600ms cubic-bezier(0.19, 1, 0.22, 1);
  -o-transition: all 600ms cubic-bezier(0.19, 1, 0.22, 1);
  transition: all 600ms cubic-bezier(0.19, 1, 0.22, 1);
  -webkit-transform: scale(0.8);
  -ms-transform: scale(0.8);
  transform: scale(0.8);
  border: 2px solid red;
}
.select-label {
  display: inline-block;
  cursor: pointer;
  position: relative;
}
.select-label span {
  display: inline-block;
  position: relative;
  background-color: transparent;
  width: 15px;
  height: 15px;
  transform-origin: center;
  border: 2px solid silver;
  border-radius: 50%;
  vertical-align: -6px;
  margin-right: 10px;
  transition: background-color 150ms,
    transform 350ms cubic-bezier(0.78, -1.22, 0.17, 1.89);
}
input[name="select-check"] {
  display: none;
}
input[name="select-check"]:checked + label span {
  background-color: blue;
  border-color: blue;
  transform: scale(1.25);
}
input[name="select-check"]:checked + label span:after {
  width: 10px;
  background: #fff;
  transition: width 150ms ease 100ms;
}
input[name="select-check"]:checked + label span:before {
  width: 5px;
  background: #fff;
  transition: width 150ms ease 100ms;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="selectall-btn">
  <input type="checkbox" id="selectall" class="select-all" name="select-check" />
  <label class="select-label" for="selectall"><span></span>Select All
</label>
</div>
<div class="post-list">
  <div class="item">
    <div class="selectall-btn">
      <label class="select-label" for="post-select1"><span></span>
</label>
    </div>
    <div class="shrink">
      <div class="select-block">
        <label class="pick-select hidden">
<input id="post-select1" type="checkbox" class="select-input" name="select-check">
</label> 1
      </div>
    </div>
  </div>
  <div class="item">
    <div class="selectall-btn">
      <label class="select-label" for="post-select2"><span></span>
</label>
    </div>
    <div class="shrink">
      <div class="select-block">
        <label class="pick-select hidden">
<input id="post-select2" type="checkbox" class="select-input" name="select-check">
</label> 2
      </div>
    </div>
  </div>
</div>


from checkbox animation on multiple labels for one input

1 comment:

  1. https://www.wizweb.in

    Wizweb Technology is a leading software development company custom website design, software development, SMS Provider, Bulk sms, transactional sms, promotional sms, mobile app development, Hosting Solution, seo(search engine optimization) and Digital marketing etc.

    ReplyDelete