javascript - Snap.js right sidebar not showing -
i'm trying create 2 draggable sidebars snap.js. right sidebar isn't displayed, instead of there left sidebar.
codepen demo: http://codepen.io/anon/pen/pjrezg
var snapper = new snap({ element: document.getelementbyid('content'), hyperextensible: false }); var addevent = function addevent(element, eventname, func) { if (element.addeventlistener) { return element.addeventlistener(eventname, func, false); } else if (element.attachevent) { return element.attachevent("on" + eventname, func); } }; addevent(document.getelementbyid('open-left'), 'click', function(){ if( snapper.state().state=="left" ){ snapper.close('left'); }else { snapper.open('left'); } }); $('#open-right').click(function(){ if( snapper.state().state=="right" ){ snapper.close('right'); }else { snapper.open('right'); } }); /* prevent safari opening links when viewing mobile app */ (function (a, b, c) { if(c in b && b[c]) { var d, e = a.location, f = /^(a|html)$/i; a.addeventlistener("click", function (a) { d = a.target; while(!f.test(d.nodename)) d = d.parentnode; "href" in d && (d.href.indexof("http") || ~d.href.indexof(e.host)) && (a.preventdefault(), e.href = d.href) }, !1) } })(document, window.navigator, "standalone");
you trying call single sidebar both buttons.
you need create sidebar instance can control right button so:
var snapper2 = new snap({ element: document.getelementbyid('content'), hyperextensible: false }); $('#open-right').click(function(){ if( snapper2.state().state=="right" ){ snapper2.close('right'); }else { snapper2.open('right'); } });
Comments
Post a Comment