javascript - Pop up doesn't feel responsive enough -


i've been following this guide make fold out pop-up , added following script make close when clicking anywhere else.

jsfiddle example without javascript

jsfiddle example javascript

$(document).ready( function(){      $('#linkie').click( function(event){          event.stoppropagation();          $('.box').toggle();      });      $(document).click( function(){          $('.box').hide();      });  }); 

but doesn't feel responsive original without script when triggering pop-up. takes 2 3 clicks trigger, wonder if there's needs tweaked in css make bit more responsive. appreciated.

css:

     label {      position: relative;      cursor: pointer;      }  .box {     position: absolute;     left: 0;     top: 100%;     z-index: 100;      /* prevent white flashing in safari 5.1 */     -webkit-backface-visibility: hidden;      background-color: #eeeeee;     background-image: -webkit-gradient(linear, left top, left bottom, from(#eeeeee), to(#999999));      background-image: -webkit-linear-gradient(top, #eeeeee, #999999);      background-image:    -moz-linear-gradient(top, #eeeeee, #999999);      background-image:     -ms-linear-gradient(top, #eeeeee, #999999);      background-image:      -o-linear-gradient(top, #eeeeee, #999999);       -moz-border-radius:    20px;      -webkit-border-radius: 20px;      border-radius:         20px;       -moz-background-clip:    padding;      -webkit-background-clip: padding-box;      background-clip:         padding-box;       width: 260px;      padding: 20px;     margin: 24px 0;     opacity: 0;      -webkit-transform: scale(0) skew(50deg);     -moz-transform:    scale(0) skew(50deg);     -ms-transform:     scale(0) skew(50deg);     -o-transform:      scale(0) skew(50deg);      -webkit-transform-origin: 0px -30px;     -moz-transform-origin:    0px -30px;     -ms-transform-origin:     0px -30px;     -o-transform-origin:      0px -30px;      -webkit-transition: -webkit-transform ease-out .35s, opacity ease-out .4s;     -moz-transition:    -moz-transform    ease-out .35s, opacity ease-out .4s;     -ms-transition:     -ms-transform     ease-out .35s, opacity ease-out .4s;     -o-transition:      -o-transform      ease-out .35s, opacity ease-out .4s; }          .box:after {     content: "";     position: absolute;     bottom: 100%;     left: 30px;     border-bottom: 20px solid #eee;     border-left:   14px solid transparent;     border-right:  14px solid transparent;     width:  0;     height: 0; }          .popupcontrol:checked ~ label > .box {     opacity: 1;     -webkit-transform: scale(1) skew(0deg);     -moz-transform:    scale(1) skew(0deg);     -ms-transform:     scale(1) skew(0deg);     -o-transform:      scale(1) skew(0deg); }         .popupcontrol {          display: none;  }          .button {     background: blue;     color: white;     padding: 5px;     border-radius: 5px; }                 /* link example */ .link { color: blue; text-decoration: underline; } .title { display: block; font-weight: bold; margin: 0 0 10px 0; color: black; font: bold 16px sans-serif; text-decoration: none; }     .copy { color: black; text-decoration: none;  } 

why don;t use first 1 , add javascript toggling. like

$(document).on("click", function(e) {     var elem = $(e.target);     if(elem.hasclass("link")) {           return;     }     $(".popupcontrol:checked").next("label").click(); }); 

example: http://jsfiddle.net/wp3vd/

now code above not close other element if there multiple. can fixed, instead of exiting, can excluded label matched set.

$(document).on("mousedown", function (e) {     var elem = $(e.target);     labelstoclick = $(".popupcontrol:checked").next("label").filter(function (i) {         return !$(this).find(elem).length;     }).click(); }); 

example: http://jsfiddle.net/wp3vd/1/


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -