Closed anttih closed 9 years ago
@garyb Agreed. I pushed the change. Thanks!
I'm going to be a pain, and disagree here. I think toggle
should be reserved for the JS call toggle()
which switches the current state from shown to hidden and vice versa. I think toggle'
or something makes sense for this version, but I also think that show
and hide
would be useful, even if they are just aliases for toggle' true
and toggle' false
.
That said, I don't have a solution for the name collision problem.
That makes sense too. I think display is ok since what it really does is change the display
css property.
Fair enough, personally I don't ever use toggle
without passing the parameter, as the implicit state usually becomes a problem later on, but if you think it's better to stick the the "default" behaviour that does make sense.
I see what you're saying, but I think of the DOM
effect as encompassing a whole bunch of other effects, including state.
Maybe we use toggle
for the default and display(bool)
for the parameterised version? Although that doesn't help with the name collision thing again if we want show
/hide
equivalents.
toggle
does that in jquery: http://api.jquery.com/toggle/#toggle-showOrHide
Like most jquery stuff it has multiple different behaviors depending on what arguments are passed to it.
I added toggle
as toggle()
. I think either: keep show
as display()
or rename to something else like unhide
. But I do like having separate show/hide functions.
@anttih Thanks, this looks good.
Also, we always have import hiding
and import qualified
if we really want to use show
. Just saying, it's an option...
Can we get this in, or was there something still missing?
Could perhaps use
toggle
with a boolean parameter for this instead? Still avoids the unfortunateshow
name collision, and is just as easy to use thanks to currying:toggle true
instead ofdisplay
,toggle false
instead ofhide
.