Comments (7)
Good idea, thanks for suggesting.
I like the short hand (passiveEvent
binding handler) and
<div data-bind="event: {wheel: handleWheel, passive: true}"></div>
Of course we get a name collision of passive
... Will think about that. :)
from tko.
Look again :) no conflict, since the value for wheel
is an object: wheel: {handler: handleWheel, passive: true}
from tko.
I feel like there's too much room for spelling errors, too much typing, and too many brackets in the more generic version. I'd like to also include some sort of capture:true
option, and maybe stopPropagation
and preventDefault
.
Some suitable syntaxes might be (for passive + capture):
<div data-bind='event: {wheel+passive+capture: handleWheel}'></div>
<div data-bind='event.wheel+passive+capture: handleWheel}'></div>
<div data-bind='event.wheel: handleWheel+passive+capture}'></div>
<!-- or, adding all options -->
<div data-bind='event.wheel: handleWheel+passive+capture+preventDefault+stopPropagation}'></div>
How do they look / feel?
A new syntax, absent rewriting for KO3, will not be backwards compatible.
from tko.
This doesn't look like valid JS. For me the charme of knockout's data-bind
is the appearance of natural JS objects inside the attribute value, and I would want to keep that. Taking your answer into account, I would suggest eventPassive: ...
as a bindingHandler, since it doesn't provoke spelling errors (at least not more than the ordinary event
handler would do), and it is meaningful.
from tko.
Yeah, that's a good point.
The issue with passiveEvent
is that it doesn't work for a larger set of options e.g. passive + capture: eventPassiveCapture
?
It might be that the correct way is, as you suggested, the wheel: {handler: wheelHandler, passive: true, capture: false}
.
Mulling it. :)
from tko.
It might be that the correct way is, as you suggested, the wheel: {handler: wheelHandler, passive: true, capture: false}.
Probably :-/
Your only objection would be the error-prone-ness (e.g. typos)?
from tko.
This will be in beta-1
from tko.
Related Issues (20)
- Deprecate unused npm packages HOT 2
- Convert legacy documentation
- Replace hard-coded parser unicode identifier detection with RegExp HOT 3
- optionsText with a lambda value fails to resolve the function argument HOT 2
- Add preventDefault to event handler options HOT 5
- Incorrect tree with multiple 'or' operators in parser HOT 1
- Unable to load from an ES module HOT 1
- TypeError: Cannot set properties of undefined (setting 'ko') HOT 1
- Re-enable tests on builds/knockout HOT 2
- `options.bindingGlobals` can't be changed at runtime
- Revamp www.tko.io
- Fix typing of the Observable<boolean> HOT 5
- Change mappingHelpers `objectLookup` from an O(n) array to O(1) Map
- Fix the build / exports in package.json
- Build @tko/build.reference into the `tko` package
- Server side render SSR support
- How to build and import TKO-beta as a bundled library. HOT 3
- [beta1.3] ESM support HOT 3
- Writable computed out of sync
- If you have multiple || (ORs), you need parentheses, otherwise it fails silently HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tko.