javascript - Sliding a div from right > to left < -


i have been searching code snippet assumed out there somwhere. there many different variations have found none of best suited me. have attempted modify jsfiddles ive found , tweak other examples no avail.

as have little no prior experience javascript , jquery languages hoped on here help.

in current project have single page in content loaded. have 6 divs hidden off screen right. vertical navigation menu sitting on left. want when link assigned div clicked, targeted div slides on screen right left , stops next navigation menu.

the twist, when new link clicked content of previous div slide off screen allowing newely selected div replace it.

hopefully have explained myself enough.

the content divs want slided =

id="content-one"

id="content-two"

and on.

any solutions or pointers in right direction extreamly usefull many in advance.

this trying modify unsuccessful...

$(document).ready(function(){   $("#navigation li a").on("click", function(e){     e.preventdefault();`enter code here`     var hrefval = $(this).attr("href");      if(hrefval == "#content-one") {       var distance = $('#container').css('right');        if(distance == "auto" || distance == "0px") {         $(this).addclass("open");         activateslider();       } else {         deactivateslider();       }     }   }); // end click event handler   // $("#closebtn").on("click", function(e){ //    e.preventdefault(); //    closesidepage(); //  }); // end close button event handler    function activateslider() {     $('#container').animate({       right: '350px'     }, 400, 'easeoutback');    }    function deactivateslider(){     $("#navigation li a").removeclass("open");     $('#container').animate({       right: '0px'     }, 400, 'easeoutquint');     } }); 

try this,

html

<div id="panel" class="panel">          content </div> <!-- trigger --> <a id="trigger" class="trigger">click here </a> 

js

$(document).ready(function () {      var settings = {         objslidetrigger: '#triggerlink', // link button id         objslidepanel: 'your_slide_div' // slide div class or id     }      $(settings.objslidetrigger).bind('click' , function() {         //if panel isn't out         if(!$(settings.objslidepanel).hasclass('out')) {             slidepanelout();         } else if($(settings.objslidepanel).hasclass('out')) {             slidepanelin();         }      });      function slidepanelout() {         //animate left          $(settings.objslidepanel).animate({             'right' : '-67%'         });         //add out class         $(settings.objslidepanel).addclass('out');     }     function slidepanelin() {         //otherwise, animate in         $(settings.objslidepanel).animate({             'right' : '-89%'         });         //remove out class         $(settings.objslidepanel).removeclass('out');     }  }); 

css

 .panel {         width:85%;         padding:2%;         position:fixed;         right:-89%;         top:46px;         z-index:2;         background: #2f2f2f ;         -webkit-box-shadow: 1px 1px 5px 2px rgba(0, 0, 0, 0.2);         box-shadow: 1px 1px 5px 2px rgba(0, 0, 0, 0.2);         border-radius: 1% 1% 1% 1%;         border-radius: 5px;     }     .trigger {         width:8%;         text-align:center;         color:goldenrod;         position:absolute;         top:26px;         padding:0.5% 0%;         border-top-left-radius: 10px;         border-bottom-left-radius: 10px;         -moz-border-radius-bottomleft: 10px;         -moz-border-top-left-radius: 10px;         -webkit-border-bottom-left-radius: 10px;         -webkit-border-top-left-radius: 10px;         background:#2f2f2f ;         right:30%;     } 

here .panel sliding div class

js fiddle


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -