TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Buttons with built-in loading indicators

409 点作者 Spiritus将近 12 年前

25 条评论

ultimatedelman将近 12 年前
This is very pretty, but there's no need for a larger, separate JS file. All of this can be handled with CSS and a simple JS command that adds/removes a CSS class on click.<p>Quick demo: <a href="http://codepen.io/ultimatedelman/pen/klDHy" rel="nofollow">http://codepen.io/ultimatedelman/pen/klDHy</a><p>Since you wouldn't obviously use all the effects in this article, just pick the one you would use and have the .loading class effect the correct change.<p>UPDATE: now with fewer elements. Only HTML element needed to achieve this effect is the button itself :)
评论 #5831882 未加载
评论 #5829738 未加载
lamby将近 12 年前
It's not known very well, but Bootstrap has similar functionality, albeit not as pretty:<p><a href="http://twitter.github.io/bootstrap/javascript.html#buttons" rel="nofollow">http://twitter.github.io/bootstrap/javascript.html#buttons</a>
评论 #5825623 未加载
评论 #5825727 未加载
评论 #5824777 未加载
评论 #5824493 未加载
评论 #5824482 未加载
yvoschaap2将近 12 年前
Hakim has more amazing experiments on his site (incl. Sinuous) worth checking out: <a href="http://lab.hakim.se" rel="nofollow">http://lab.hakim.se</a>.
评论 #5824513 未加载
评论 #5829490 未加载
评论 #5824640 未加载
scythe将近 12 年前
Hm, I was going to say it is slightly messed up in Opera -- the boxes don't move like they should -- but I guess it's not going to matter in the very near future. :(
emehrkay将近 12 年前
What impresses me the most is the JS. It is so clean, concise, and, the only other word that I can think of, professional. It puts the onus of capability on the browser and doesn't try to make up for those who lack. Sure you can shim addEventListener or setAttribut, but F IE (really), it has been adding complexity for far too long.
评论 #5826781 未加载
评论 #5826304 未加载
Filligree将近 12 年前
Nifty. I don't know how we missed the possibility - this looks really nice.<p>Oh, and <i>thank you</i> for adding a license. So often I see neat hacks posted, without any license at all...
mullr将近 12 年前
This is quite nice. All of the animations would be made better by removing the bounce at the end; it's a jarring way to end something that's otherwise very smooth.
pbobak将近 12 年前
Nice! Although the loading gif looks a bit dodgy on retina screen. I'd suggest playing with CSS and making that loading bit a pure css shape.
ericjust将近 12 年前
We did something similar on one of our office hack days.<p><a href="http://waitable.adstruc.com/" rel="nofollow">http://waitable.adstruc.com/</a><p><a href="https://github.com/ADstruc/waitable" rel="nofollow">https://github.com/ADstruc/waitable</a><p>We built a generic jQuery plugin which binds to jQuery promises, taking care of the waiting state and double-submit issues while firing off Ajax requests.
评论 #5826328 未加载
mrtbld将近 12 年前
On Firefox, a dotted line appears around the button's text when it has focus (after click for instance). IMO, it ruins the nice clear style of the buttons.<p>You can remove it with the non-standard `button::-moz-focus-inner{border:0}`. Then you could define some style for `button:focus{...}` to help keyboard navigation.
评论 #5826294 未加载
jumblesale将近 12 年前
This is really cool! The only thing that makes it a little ugly for me is that when I click on it, my browser puts an ugly grey box around the text like I'm selecting it. Could this be solved by immediately changing the focus of the input?
评论 #5825258 未加载
评论 #5824712 未加载
comex将近 12 年前
It's worth a note that these buttons are very laggy in MobileSafari, except for zoom-in and zoom-out, which use -webkit-transform and thus have hardware accelerated animation. While slide-* could be changed to use -webkit-transform, I'm somewhat surprised that the performance of the others is so bad, and I wonder if there's some not-completely-awful trick that would improve expand-*.
评论 #5825551 未加载
Achshar将近 12 年前
That looks cool. But in most of my projects, I use a "frame" structure. After submitting something, the frame changes to either left or right, completely moving the submit button out of sight. So while this is very cool, it doesn't work for popups and frame like designs which are supposed to "move" immediately and process ajax requests in background to give an illusion of speed.
jurre将近 12 年前
I actually did a similar thing for iOS, I'll try to extract it from that project and open source it when I find time :)
shaydoc将近 12 年前
This is also a nice solution<p><a href="http://fgnass.github.io/spin.js/" rel="nofollow">http://fgnass.github.io/spin.js/</a>
评论 #5840681 未加载
simonbarker87将近 12 年前
I saw this and just thought, "why isn't this the way we do buttons and loading" nice
SeoxyS将近 12 年前
A few years ago I built a button for an iPhone app that turned into a progress bar while loading:<p>Here's a CSS version of it (with image assets).<p><a href="http://codepen.io/kballenegger/pen/uJGCF" rel="nofollow">http://codepen.io/kballenegger/pen/uJGCF</a>
k__将近 12 年前
I like the slid.es examples. Are there some JavaScript based slides, which work on a server so that one user can navigate to new slides and the other users see the change in their browser?
dspillett将近 12 年前
Nice. I like the in-place-with-overlay option particularly, though I can still interact with the other buttons while the overlay is in place which I was not expecting.
评论 #5825244 未加载
评论 #5828028 未加载
Leszek将近 12 年前
Something like this, but with a progress bar instead of a generic loading thing, would also be very nice.
评论 #5829041 未加载
suyash将近 12 年前
Interesting use case, but not practical enough. All the times when you need to show a loading indicator do not occur after clicking on a button, loading indicator needs to come up when any amount of delay is anticipated. It can show up after clicking a link, image etc etc whereas this example implies as if loading indicator is only need when a button is clicked.
评论 #5827030 未加载
ozh将近 12 年前
very neat, and incidentally made me discover slid.es, what an extremely well made app that is.
评论 #5827569 未加载
braum将近 12 年前
this is great, thanks for sharing!
Aardwolf将近 12 年前
The slide right seems broken.
adityar将近 12 年前
very cool. progress bars next?