bespokejs / bespoke

DIY Presentation Micro-Framework

Home Page:http://markdalgleish.com/projects/bespoke.js/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Event type

ultimatedelman opened this issue · comments

When wiring up events, the action triggering the event would be awesome to have in the event object:

{
    slide: [some slide]
    , index: [number]
    , type: [keypress(left|right|spacebar)|slide|prev|next|whatever]
}

As it is, it's very hard to wire up things like history state when you can't discern between a popstate and a keypress. Maybe the option to pass in an additional param to the slide() method?

 deck.slide(index, myEventParams);

I know you're trying to keep byte size down, but I feel like the utility introduced by this would make this library exponentially more powerful. If nothing else, the ability to add custom values to the event object would be a huge improvement.

Sorry for the craziness. This is actually still an issue.

I think your second idea is the best tradeoff of utility and size. Keeping it under 1KB could be tricky, but I can see that this would be a worthwhile change to core.

This is something I think I'll have to implement, since it touches everything- core APIs, tests, docs, and potentially other code will need to be optimised to fit in the 1KB limit.

Awesome. I think you'll see my implementation in my pull request is pretty minimal and provides flexible functionality required by someone trying to discern by event type

Yeah, thanks for the pull request. It looks to be following your first suggestion, but I think allowing custom event payloads would solve your problem in a much more minimal and flexible way, since it would allow you to provide metadata around calls to next, prev and slide.

I've begun work on this already, and so far it's looking good.

Awesome! Glad I could help :)

I just pushed v0.2.0, which supports custom event data.

You can see an example of it in the readme: https://github.com/markdalgleish/bespoke.js#custom-event-data

Thanks for the feedback, I think this is a really useful feature :)

w00t!

I see the example for .next() and assume it works that way for .prev() too. What's the method signature for slide, since that takes a number for the slide index? Is it .slide(index, eventOpts)?

EDIT: a quick glance at the code shows me that this is, in fact, how you're handling it. Sweet!

yep, RTFM. oops