Splitting icon indicating copy to clipboard operation
Splitting copied to clipboard

Reindexing

Open shshaw opened this issue 7 years ago • 10 comments

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.

shshaw avatar Aug 08 '18 17:08 shshaw

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) {
...

shshaw avatar Aug 08 '18 17:08 shshaw

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.

notoriousb1t avatar Aug 09 '18 00:08 notoriousb1t

One 🍌split ready for the next customer!

notoriousb1t avatar Aug 09 '18 02:08 notoriousb1t

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?

shshaw avatar Aug 10 '18 16:08 shshaw

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?

shshaw avatar Aug 17 '18 18:08 shshaw

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?

notoriousb1t avatar Aug 17 '18 20:08 notoriousb1t

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)

shshaw avatar Aug 17 '18 20:08 shshaw

maybe something a little shorter than allowReindexing?

notoriousb1t avatar Aug 18 '18 02:08 notoriousb1t

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 .

shshaw avatar Aug 18 '18 14:08 shshaw

I think this is 100% doable, just have to find the time budget to fix it 😄

notoriousb1t avatar Aug 23 '18 18:08 notoriousb1t