Giter VIP home page Giter VIP logo

Comments (7)

brianmhunt avatar brianmhunt commented on May 18, 2024

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.

krnlde avatar krnlde commented on May 18, 2024

Look again :) no conflict, since the value for wheel is an object: wheel: {handler: handleWheel, passive: true}

from tko.

brianmhunt avatar brianmhunt commented on May 18, 2024

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.

krnlde avatar krnlde commented on May 18, 2024

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.

brianmhunt avatar brianmhunt commented on May 18, 2024

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.

krnlde avatar krnlde commented on May 18, 2024

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.

brianmhunt avatar brianmhunt commented on May 18, 2024

This will be in beta-1

from tko.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.