I follow your thoughts.. totally agree. Especially with css +
transitions + pseudo elements a lot can be done right.
Have to check benchmark.js!
With regard to the Behavior event arbitration method...I'm not getting
it.. or at least, not for my current case:
Behavior.addGlobalFilter('Grid', function(element, api){
var grid = new Grid(element, ...);
grid.addEvent('complete', function(){ api.fireEvent('gridRendered',
element); });
grid.make();
return grid;
});
Behavior.addGlobalFilter('Preview', function(element, api){
var preview = new Preview(element, ...);
api.addEvent('gridRendered', function(container){
console.log('gridRendered', container);
container.getElements('some-selector').preview();
});
return preview;
});
1)
The "gridRendered" event is not picked up (in Preview filter) when
there is no element in the dom with the data-behavior="Preview"
attribute. (when the filter hasn't run)
In assumed the filter Preview was registered and globally
"listening" (to catch the fired event) even if the Preview filter has
not been actively used yet (by some already declared element in the
dom).
So, to test it I added a dummy div to the dom (not associated to the
list that is turned into the grid) with the data-behavior="Preview"
attribute, which is silly of course...
What's wrong with my thinking process?
2)
The Preview class (and thus the Behavior filter) is setup for one 1
element basically. If I add data-behavior="Preview" to an element the
filter is called and the class is instantiated.
But in the code above I abuse the "gridRendered" event to call a
preview() method on an array of elements I select with a css selector
on the grid container (basically: all childs except empty cells).
(the preview method call does: return new Preview(this, options) -
pretty straightforward).
This is of course wrong: I should not call the Element method
preview() on multiple elements in a filter created to manage 1
element.
How should I "get this right"?
Should I just create a filter that is called PreviewMany which runs my
Element method preview() on a collection of elements? and
And then I should add this behavior to my list element also: <ul data-
behavior="Grid PreviewMany" ...>... </ul> else it's not listening to
my event firing........
It's starting to get confusing, no? ;)
anyway- tia... 1.48am here now.. time to zzz
> Also, you can *greatly* increase your startup time for filters that only