jquery - Make a bootstrap affix draggable around the screen -


i have bootstrap affix sticky window. shows meta data information user hovering on right now. trying make sticky notification movable around screen user can move out of way if obstructs seeing. how do this?

you can use solution; have inserted button inside affix set on jquery ui draggable; same used toggle affix back.

html:

<div id="nav-wrapper">     <div id="nav" class="navbar">         <div class="navbar-inner">             <div class="container">                 <div class="span12"> <a class="brand" href="#">my brand</a>  <span class="navbar-text">                     navbar.                     </span>                      <button id="mover" class="btn-danger pull-right">move me!</button>                 </div>             </div>             <!-- container -->         </div>         <!-- navbar-inner -->     </div>     <!-- navbar --> </div> 

code:

$('#nav').affix(); $("#nav").data("left", $("#nav").position().left).data("top", $("#nav").position().top);  $('#mover').click(function () {     if ($('#nav').hasclass("movable")) {         $('#nav').draggable('destroy');         $("#nav").animate({             "left": $("#nav").data("left"),                 "top": $("#nav").data("top")         });         $(window).scrolltop(); $("#nav").removeattr("style")         $('#nav').removeclass("movable");         $(this).text("move me!")     } else {         $('#nav').draggable({cursor: "crosshair"});         $('#nav').addclass("movable");         $(this).text("affix me!")     } }) 

demo: http://jsfiddle.net/irvindominin/ya2kx/


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 -