-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Labels
Description
Per discussion in Bitovi #general, it would be nice to allow the ability to export an events object if you need to do document-level events in cases where you do not have an app-level component.
Perhaps this would work by making a generic can-control on the document and utilizing the default export of whatever file we import using can-import[as="events"]
Example
In mobile, in order to get nice and responsive :hover interactions on buttons, you need to add and
remove a class on touchstart and touchend events, respectively. This might look like the following:
src/events.js
export default {
'button touchstart': function onTouchStart(el, ev) {
el.classList.add('hover');
},
'button touchend': function onTouchEnd(el, ev) {
el.classList.remove('hover');
}
}src/index.stache
<!DOCTYPE html>
<html>
<head></head>
<body>
<can-import from="./events.js" export-as="events"/>
<form>
<label>
Email
<input type="text">
</label>
<label>
Password
<input type="password">
</label>
<button type="submit">Login</button>
</form>
</body>
</html>kylegifford