Closed andrewchilds closed 7 years ago
And just for reference, to unbind bound elements, we do something similar to...
var LIBRARY_NAMESPACE = 'TSS';
var LIBRARY_CLASSNAME = '.theiaStickySidebar';
function destroy(boundElement) {
// Unbind scroll / resize event handlers:
$(window).off('resize.' + LIBRARY_NAMESPACE);
$(document).off('scroll.' + LIBRARY_NAMESPACE);
// Remove style tag:
$('#theia-sticky-sidebar-stylesheet-' + LIBRARY_NAMESPACE).remove();
// Remove wrapper element:
boundElement = $(boundElement);
boundElement.removeAttr('style').html(boundElement.find(LIBRARY_CLASSNAME).html());
}
function destroyAll() {
$(LIBRARY_CLASSNAME).parent().each(function (i, element) {
exports.destroy(element);
});
};
Thank you @andrewchilds and @webfella, very good points all around. 🍻 Not sure if the destroy logic should be built-in as well, but it's a great start. I'll merge this, re-compile the dist files, and finally bump the version number.
Great, thanks @liviucmg! The only thing remaining I think is for you to push the v1.7.0
tag to github and npm publish
.
Cheers, Andrew
Good catch @andrewchilds, all done now. Thanks!
thanx
Hello! This PR adds three things:
defaultPosition
option (useful if the bound element uses something other thanposition: relative
by default).namespace
option, to make it possible to unbind elements (this is useful if we want to re-render bound elements). This fixes issue https://github.com/WeCodePixels/theia-sticky-sidebar/issues/31.Let me know if you need anything further to get this merged.
Cheers! Andrew