Reindexing
Splitting currently re-splits an element continually: https://codepen.io/shshaw/pen/334718fe322a14f80e25f1d035b40d46?editors=0010
For something like lines, rows and children, it should re-run the indexing and update CSS vars.
But where a plugin creates elements, it should return those same elements. Perhaps we need a force option to re-split after removing created elements.
Part of this is putting the caching back in, but I think we need to evaluate the way that indexing happens.
Splitting.js
var ctx = el._splitting || { el: el };
var items = resolve(opts.by || getData(el, 'splitting') || CHARS);
var opts2 = copy({}, opts);
each(items, function(plugin) {
var pluginBy = plugin.by;
if ( !ctx[plugin.by] && plugin.split) {
...
The caching should definitely help, but if we allow a force re-index, it will have to largely be up to each plugin to determine how or if it should handle that.
One 🍌split ready for the next customer!
Thought about it more last night. I don't know that the Emoji will be great for browser support; might need to go with a standard string.
Also considering changing el into target in the splits. Thoughts?
I don't know that force is the right solution here. For instance, with lines, we don't want it to reindex words but we do want those words to have their --line-index updated.
Example: Example: https://codepen.io/shshaw/pen/d1daa677417bff05db4419c31c212ae5
Perhaps some kind of distinction between indexing plugins ( lines, items, grid, rows, cols ) versus element creating plugins ( cells, words, chars ).
Also, see comment here: https://github.com/shshaw/Splitting/commit/1a09e167613a6eda27d676213afa86818bdeb035#r30021166
Any thoughts on those?
Maybe the plugins can declare if they will are capably of being reindexed and if they aren't, they will be skipped with the same properties as they had prior?
Are you thinking we should remove force and have this implicit behavior?
Yes; I think that may be the better approach. Something like
{
by: 'chars',
depends: ['words'],
key: 'char',
split: function(){},
allowReindexing: false
}
(or the last parameter of the createPlugin function, then we only have to set true on the ones that can be reindexed)
maybe something a little shorter than allowReindexing?
Just reindex should be fine. Mostly for internal use anyway.
On Fri, Aug 17, 2018 at 9:27 PM Christopher Wallis [email protected]
wrote:
maybe something a little shorter than allowReindexing?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/shshaw/Splitting/issues/18#issuecomment-414026398, or mute the thread https://github.com/notifications/unsubscribe-auth/AAvbw8xBDq-cD_fDOfAPwVYCmPZ5L1spks5uR3uZgaJpZM4V0UMd .
I think this is 100% doable, just have to find the time budget to fix it 😄