alvarotrigo / alvarotrigo/fullPage.js
Adding Custom Events for each of the current Callbacks
- Lenguaje dominante
- JavaScript
- Estrellas
- 35.4k
- Forks
- 7.1k
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
I noticed is that your callbacks can only be setup at initialization time. I think you could have a nice little enhancement by adding a custom event for each of the callbacks that you currently offer. This way other library designers and developers can listen for the events instead of having to be loaded and be part of your object initialization.
Here is an example of what I’m talking about. NOTE: The code isn’t optimized, but I think you’ll get the idea.
Please let me know if you need more explanation or want an actual full example…
``` javascript
/**
* Actions and callbacks to fire afterRender
*/
function afterRenderActions() {
var section = $(SECTION_ACTIVE_SEL);
solveBugSlimScroll(section);
lazyLoad(section);
playMedia(section);
$.isFunction(options.afterLoad) && options.afterLoad.call(section, section.data('anchor'), (section.index(SECTION_SEL) + 1));
$(section).trigger($.Event("afterLoad", {
anchorLink: section.data('anchor'),
index: (section.index(SECTION_SEL) + 1)
}));
$.isFunction(options.afterRender) && options.afterRender.call(container);
$(container).trigger('afterRender');
}
//Then….An external library or designer could then do things like...
$(document).on('afterLoad', function (event) {
console.log("Section: " + event.anchorLink);
console.log("Index: " + event.index);
});
```
Guía de contribución
Evaluación
Este issue todavía no se ha evaluado.