Question

ShareThis is a social sharing widget for websites in which a 'sidebar' per say is created on the far edge of the page and when clicked it scrolls out and displays a menu of sharing options. I need to find a jQuery plugin or a javascript that will allow me to mock this feature.

An example of what I am trying to do can be found here: http://support.sharethis.com/customer/portal/articles/475260#sthash.iBn1ZGqT.dpbs on the far left side of the page.

Does anyone know of a jQuery plugin that will allow me to do this with a div of my choice? Of course I will have to add some styles to it myself but the library/script/plugin to start would be helpful.

EDIT: I have made a custom js solution but now I want to close the element when clicked again. Below is my JS to open the element on click:

jQuery(function() {
    jQuery('.contact-flyout').bind('click', function() {
        jQuery('.contact-flyout-menu').animate({ marginRight: '0px'}, 500);
        jQuery('.contact-flyout').animate({ marginRight: '150px'}, 500);
    });
});
Was it helpful?

Solution 2

I created a custom jQuery function to do this. Here is my final working result:

jQuery(function() {
    jQuery('.contact-flyout').bind('click', function() {

        if(jQuery('.contact-flyout-menu').css('margin-right') == "-152px") {
            jQuery('.contact-flyout-menu').animate({ marginRight: '0px'}, 500);
            jQuery('.contact-flyout').animate({ marginRight: '150px'}, 500);
        } else {
            jQuery('.contact-flyout-menu').animate({ marginRight: '-152px'}, 500);
            jQuery('.contact-flyout').animate({ marginRight: '0px'}, 500);
        }

    });
});

OTHER TIPS

You can do this with straight up css. Based on this article here: http://dbushell.github.io/Responsive-Off-Canvas-Menu/step2.html

With a bit of modification you can achieve this: http://jsfiddle.net/SrTH4/1/

<!-- I am collapsed by default -->
<nav id="main-navigation" class="navigation">
    <a href="#">Nav Links</a>
    <a href="#">Nav Links</a>
    <a href="#">Nav Links</a>
    <br><br>
    <a href="#">Close</a>
   <!-- more -->
</nav>

<!-- I am full width by default -->
<div class="page-wrap">
  <header>
    <a href="#main-navigation">Menu</a>
    <h1>Title</h1>

    <p>Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet.</p>

    <p>Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet.</p>

    <p>Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet.</p>
  </header>

  <!-- content -->
</div>

css:

.navigation {
  background: #ccc;
  width: 60px;
  overflow: hidden;
  position: fixed;
  top: 200px;
  left: -60px;
  height: auto;
  -webkit-transition: left 1s ease;
  transition: left 1s ease;
  z-index: 2;
}

.page-wrap {
  width: 100%;
  float: right;
}

.page-wrap a {
    background: black;
    color: white;
    padding: 5px;
    position: fixed;
    top: 210px;
    left: -10px;
    text-decoration: none;
    z-index: 1;

    -webkit-transform:rotate(90deg);
    transform:rotate(90deg);
}

#main-navigation:target {
  left: 0;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top