News for hackers. Stuff that matters.
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by remy_luisant on Wednesday March 15, 2017 @06:32AM (#13875122)
That's adorable.

I wonder how using such a toggle could change the user behavior. I had a bit of a hard time turning the face into a sad face. I really liked it much better at green. It would be easier to convince me to pay money with this toggle.

Then again, I'm a sucker for happy faces and cute things, so maybe I'm just weak to this kind of thing.

Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by Grangar on Wednesday March 15, 2017 @06:48AM (#13875177)
I already see it happening. In 5 years emotional-manipulation-driven design is going to be the next hot thing.
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by andai on Wednesday March 15, 2017 @07:01AM (#13875226)
When you buy a recording of one of Louis C.K.'s shows from his website, you are given the choice

(*) Yes, I'd like to receive further emails about louis C. K. things.

( ) No, leave me alone forever you fat bastard.

Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by manuelflara on Wednesday March 15, 2017 @07:49AM (#13875433)
This reminds me of Chuzzle[1], a cute puzzle game by PopCap (makers of Zuma, Pebble, Plants vs Zombies etc) that, when you tried to quit the game, it'd show you one of the furry creatures with googly eyes, asking you if you really wanted to quit[2]. I thought it was a nice touch at the time (maybe 10 years ago).

[1] https://www.youtube.com/watch?v=V3LJ9n43M-4 [2] http://www.mobygames.com/images/shots/l/112433-chuzzle-delux...

Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by s_kilk on Wednesday March 15, 2017 @09:39AM (#13875974)
Doom had a similar trick, the "Quit: Yes/No" prompt would say something like "I wouldn't quit if I were you, work is much worse".
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by wattengard on Friday March 17, 2017 @03:25AM (#13892207)
Yeah. They do that. When you try to quit Bookworm Adventures the bookworm cries "Don't leave me!"...
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by gpvos on Wednesday March 15, 2017 @10:36AM (#13876366)
...and when you select No, does the background fade to black, with crackling lightning and rolling thunder?
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by talmand on Wednesday March 15, 2017 @09:56AM (#13876090)
Five years? It's already happening. There's a large number of "shaming" dark patterns out there already. "No, I don't wish to save money.", as an example.
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by arthurfm on Wednesday March 15, 2017 @02:37PM (#13878582)
Kind of like in the "Nosedive" episode of Black Mirror? [1]

[1] http://www.imdb.com/title/tt5497778/

Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by sdrothrock on Wednesday March 15, 2017 @09:37AM (#13875955)
Isn't it already, with guilt-laden options like:

* Yes, I want to be a better person!

* No, I don't want to be a better person and am content to live a life of misery without this service.

Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by joshschreuder on Wednesday March 15, 2017 @06:35PM (#13880516)
It's pretty common actually, see here:

http://confirmshaming.tumblr.com/

Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by skocznymroczny on Wednesday March 15, 2017 @01:37PM (#13878055)
"We want users to understand that they’re pretty much cheating the system when they choose not to pay for software"
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by gpvos on Wednesday March 15, 2017 @10:35AM (#13876361)
You mean 5 years ago?
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by HalfwayToDice on Wednesday March 15, 2017 @06:40AM (#13875153)
Click delay is bad UI. When you click it, the face first blinks, then moves. So it appears to not be working. Would be better to move first, then blink upon completion.
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by clishem on Wednesday March 15, 2017 @06:44AM (#13875161)
A slider that doesn't slide when swiping on touch devices also is.
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by jessriedel on Wednesday March 15, 2017 @07:08AM (#13875251)
Yep, I tried sliding this slider 3 times and gave up. Had to come to the comments to figure out how to work it.
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by kolme on Wednesday March 15, 2017 @07:24AM (#13875324)
Now that we're at it: clickable things have the "hand" cursor.

All of the widget is actionable yet the cursor is not always pointy.

It's one of my pet peeves.

That being said, the animation is beautifully done and the widget very cute. This is just eye-candy.

Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by nsgi on Wednesday March 15, 2017 @11:36AM (#13876806)
Would you use a hand cursor for a button?
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by kolme on Wednesday March 22, 2017 @08:41PM (#13936522)
Super late answer but I hope you get it: yes, it is a good practice.

In "native apps" on desktops, all buttons look the same, so users know they're clickable because they've already learned it.

On the web however, every page looks different, so it is helpful to show the users you can click things by using the "hand" cursor.

Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by splitbrain on Wednesday March 15, 2017 @12:13PM (#13877131)
Yes, I would.
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by redshark1802 on Wednesday March 15, 2017 @08:26AM (#13875585)
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by chasingtheflow on Wednesday March 15, 2017 @10:17AM (#13876239)
Nice! Though it looks like in your version the blink is happening from top-to-bottom as opposed to collapsing in the middle. I like the blink after the toggle, but the actual blink animation in the original in preferable imo.
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by tbirrell on Wednesday March 15, 2017 @10:44AM (#13876422)
If you slow down the original, it does the same thing. Optical illusion I think.

Edit: only the second blink is funky. The first is how you recall.

Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by chrisgannon on Thursday March 16, 2017 @02:38AM (#13883026)
The first (happy) blink is fractionally slower than the sad blink on purpose. I'm obsessive about details.
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by neogodless on Wednesday March 15, 2017 @10:04AM (#13876145)
I think the blinking is actually much more effective this way, too!
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by chrisgannon on Thursday March 16, 2017 @02:36AM (#13883015)
Yes you messed up the transform origin.
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by cpfohl on Wednesday March 15, 2017 @07:10AM (#13875257)
Seriously? I agree it needs to respond faster, but this is impressive and cool. Start with a compliment, you'll go a lot further in life.
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by ominous on Wednesday March 15, 2017 @07:46AM (#13875421)
> I agree it needs to respond faster, but this is impressive and cool.

You did the same thing.

Nothing wrong with being objective.

Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by oneZergArmy on Wednesday March 15, 2017 @07:13AM (#13875270)
I see nothing wrong with constructive criticism.
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by Already__Taken on Wednesday March 15, 2017 @06:57AM (#13875211)
It handles a double-click nicely though so credit for that.
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by yev on Wednesday March 15, 2017 @08:39AM (#13875651)
You are free to improve it, if you "know" how is "better".
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by yev on Wednesday March 15, 2017 @08:42AM (#13875664)
The same author: http://codepen.io/chrisgannon/pen/VjWWZO Looks pretty great too!
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by szatkus on Wednesday March 15, 2017 @09:17AM (#13875836)
And now I want to learn SVG.
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by talmand on Wednesday March 15, 2017 @10:00AM (#13876111)
You should, working with SVG is interesting. It makes you think differently in how to handle UI design. I wish it were better supported across the board in browsers, it would help solve a great deal of UI issues.
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by 1niels on Wednesday March 15, 2017 @01:49PM (#13878187)
Any suggestions of how to get started? It's been a topic I have long been interested in but never found a good path to follow.
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by szatkus on Wednesday March 15, 2017 @02:15PM (#13878405)
I've just started, but this looks like a nice tutorial: http://tutorials.jenkov.com/svg/index.html

Also if you use Atom you should install this package: https://atom.io/packages/svg-preview

Overall it's quite simple especially if you have experience with HTML and Canvas. Much easier for me than Inkspace.

Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by talmand on Wednesday March 15, 2017 @02:27PM (#13878501)
It really kind of depends on what you want to do with the SVGs. They can cover topics such as icons, animations, UI, charts, reports, and so on. Just about anything you can imagine using a vector image instead of a raster applies. Many javascript libraries already exist to cover many of the usual situations. You can look into those and play with them to figure out where your interests lie.

And this isn't limited to web technologies and browsers.

Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by chrisgannon on Wednesday March 15, 2017 @05:34PM (#13880015)
I started learning SVG going through all the jenkov examples - really great resource. The SVGs I create now are designed to be easy to understand because I wanted to pay it forward. Have a pick through my other pens and maybe my channel http://YouTube.com/+framespark
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by graiz on Wednesday March 15, 2017 @10:31AM (#13876327)
This should really be an <input type="checkbox"> with bonus CSS/JS so that it's backward compatible and doesn't break the world of accessibility, tabs, focus, forms, etc.

I think it's fine for design to explore visual representations of an input but the HTML should try to stay clean.

Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by ino on Wednesday March 15, 2017 @11:16AM (#13876661)
I don't like the switch design for people using a mouse.

What is the behaviour? Should I click the switch? Where do I click it: where it is or where I want it to go? Or should I drag it?

And usually only one of those actions work and I seem to always miss toggling it on the first try.

Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by itchynosedev on Wednesday March 15, 2017 @06:25AM (#13875103)
Awesome transitions!

One minor annoyance is toggles is meant to respond instantly, and when I click it just accelerates tad slow as to make you think it's a bit lagged.

Looks very cool, though.

Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by retSava on Wednesday March 15, 2017 @07:32AM (#13875353)
You can change the line var toggleTl = new TimelineMax({paused:true}).timeScale(2);

to read eg var toggleTl = new TimelineMax({paused:true}).timeScale(5);

instead. (I'm not the author, just fiddling)

Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by zichy on Wednesday March 15, 2017 @05:32AM (#13874896)
Now try to use a valid checkbox input.
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by kuschkufan on Wednesday March 15, 2017 @05:58AM (#13875005)
That's left as an exercise for the inclined hn reader.
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by iheredia on Wednesday March 15, 2017 @10:21AM (#13876265)
The author has a lot of interesting pens http://codepen.io/chrisgannon/pens/popular/
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by gpvos on Wednesday March 15, 2017 @06:42AM (#13875155)
Nice. Trying to drag the button doesn't work though; I would add that.
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by philliphaydon on Wednesday March 15, 2017 @06:51AM (#13875192)
Why would you try drag it? Maybe I'm used to iOS I don't swipe those things I just touch them...
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by falsedan on Wednesday March 15, 2017 @06:53AM (#13875196)
Why wouldn't you? It looks like a slider toggle, not a checkbox.
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by catshirt on Wednesday March 15, 2017 @07:15AM (#13875278)
what is a "slider toggle"? sliders should be used for ranges of values. checkbox for toggling values.

we could argue it's unfortunate that iOS(?) decided to start making their "checkboxes" look a little like sliders, but they still only toggle values thus you don't slide them.

in any case, i get where you're coming from. using mousedown instead of click or up maybe kind of solves both use cases?

Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by extra88 on Wednesday March 15, 2017 @07:43AM (#13875412)
"Checkboxes" that look like little sliders usually are good UI because they avoid this confusion, "is the control showing me the current state or the option to change to the desired state?" For whatever reason, toggle switches like this better convey that they're displaying the current state before you touch them.
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by falsedan on Wednesday March 15, 2017 @08:13AM (#13875520)
The slide is so big on this one that it looks like multiple targets. The iOS ones are small enough that the only useful interaction is to mash with fingertip.

mousedown++ but also touch events

Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by OJFord on Wednesday March 15, 2017 @07:44AM (#13875415)
People do though, I often watch (and cringe as) my parents do it.
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by fuzzy2 on Wednesday March 15, 2017 @09:41AM (#13875987)
> Why would you try drag it?

Because it’s large and I want to see it wiggle? :D

Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by croon on Wednesday March 15, 2017 @08:23AM (#13875579)
I still intuitively (try to) slide toggles on my iPad. Just because Apple did it wrong doesn't mean everyone should adapt.
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by jimboj on Wednesday March 15, 2017 @12:07PM (#13877078)
Which version of iOS? As far as I can tell you can tap or swipe/slide the switches.
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by TomMarius on Wednesday March 15, 2017 @07:16AM (#13875279)
I don't see a button, it has a background that suggests it'll slide when dragged.
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by zltm on Wednesday March 15, 2017 @09:20AM (#13875854)
yup same here, i still love it tough
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by chrisgannon on Thursday March 16, 2017 @02:41AM (#13883038)
It's a toggle. Drag is a no no for something with just two options. UI basics 101.
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by baby on Wednesday March 15, 2017 @07:04AM (#13875235)
After flat UI, cute UI? I love this.

Btw this is a joke, but how far from reality is it? In Japan there is definitely a cute UI. I could even say that the Nintendo Switch UI is a cute UI.

Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by Klathmon on Wednesday March 15, 2017 @06:59AM (#13875216)
Can I use this under any kind of OSS license?

I'm not the most familiar with codepen so I apologise if it's on there somewhere already.

Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by ballenf on Wednesday March 15, 2017 @11:16AM (#13876657)
https://blog.codepen.io/legal/licensing/

Public pens are MIT licensed.

Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by chrisgannon on Thursday March 16, 2017 @02:44AM (#13883045)
No I don't grant permission sorry. I put stuff out to show off my skills and to help people learn.
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by Klathmon on Thursday March 16, 2017 @06:09AM (#13883832)
Well as another here has pointed out this is licensed under the MIT license on codepen and explicitly for this at [0] then click "license" below the pen

[0] http://codepen.io/chrisgannon/details/WpjXVr

Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by chrisgannon on Thursday March 16, 2017 @06:58AM (#13884015)
I'm just saying as the original designer/artist I don't give permission, regardless of the MIT license (which I disagree with on CodePen but that's another story).
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by Klathmon on Thursday March 16, 2017 @07:04AM (#13884040)
I get that from a "ethics" standpoint (and I won't be using it in our project like I wanted), but legally you are giving permission for anyone to use the software in any way they see fit within the MIT license.

It doesn't matter what you say here, the license is kind of final for the code it's referencing.

IIRC CodePen does allow you to license your code differently, but it requires a "pro" account.

Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by chrisgannon on Thursday March 16, 2017 @09:00AM (#13884606)
I am a Pro and to legally avoid this I could create pens that are private but then nobody would learn anything from them and I wouldn't get them featured anywhere. So people can use them as long as they include a license which, let me assure you from bitter experience, nobody ever does.

Judging by the fact you said you won't use it, you seem to have a working moral compass - unfortunately you are a minority.

Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by chasingtheflow on Wednesday March 15, 2017 @10:15AM (#13876221)
Really cool. Changing the timeScale value on JS line 33 to 1 slows everything down and makes the animation a little easier to see if you're interested in seeing how the effect works.
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by fagnerbrack on Wednesday March 15, 2017 @06:44AM (#13875165)
Ok, that's really funny xD
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by yev on Wednesday March 15, 2017 @08:39AM (#13875654)
Nice work, looks really great!
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by jlink on Wednesday March 15, 2017 @07:38AM (#13875385)
haha nice one!
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by ainiriand on Wednesday March 15, 2017 @07:07AM (#13875248)
Quite, but not yet.
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by sangupta on Wednesday March 15, 2017 @06:57AM (#13875212)
Cute!
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by fagnerbrack on Wednesday March 15, 2017 @06:45AM (#13875168)
You just found out an emoji HN forgot to remove in the title xD

I just wonder how long it's gonna last.

Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by laurent123456 on Wednesday March 15, 2017 @06:43AM (#13875159)
Looks like HN strips off emojis from titles and comments.
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by andai on Wednesday March 15, 2017 @07:03AM (#13875231)
On front page it's just <->
Re:Show HN: An HTML/CSS/JS toggle switch with happy and sad ... by dagenleg on Wednesday March 15, 2017 @08:08AM (#13875503)
Nice! Slow, unresponsive "cute" visual element. Perfect for modern web-developers.