Omitter.js is a small javascript plugin, it can omit a text content faster. this plugin thought about reduce reflow count. so probably this plugin is faster than some plugins that using Element.innerText or TextNode.data.
window.addEventListener("load", function (event){
// var doms = $(".omitter-target");
var doms = document.querySelectorAll(".omitter-target");
var omitter = new Omitter(doms, 3, "..."); // limit to 3 lines.
omitter.omit();
});
if you want disable omission, you can use omitter.unomit();
method.
it show all sentences.
Method | Description |
---|---|
Omitter.omit | enable omission mode and update nodes. |
Omitter.unomit | disable omission mode and update nodes if necessary. |
Omitter.update | update nodes if omission mode is enabled. |
Omitter.toggle | toggle omission mode and update nodes. |
- I should think whitespace character. the ellipsis ignore whitespace or not?
- append a option about optimization for performance. of an ".emitter-character" contain multiple characters, this plugin is able to reduce some calculations.
this plugin released under MIT license.