A while ago I had someone create a sliding bar effect for a website I was working on. If you check out the site linked below, you will see the sliding bar thingy that I am talking about where it says "Tona Boards" on a sort of green arrow, then it slides back and forth to reveal different text.
Now there is just one small problem with it. There is always this unnecessary amount of extra space after the text if the line of text is quite long. This is a result of a poor calculation for the width of the arrow. Currently this is how the width of the arrow is calculated:
var width = titles[title_id][0].length * 15;
Basically, he is just multiplying the number of characters by 15 to get a close (but not accurate) pixel width that will fit the text.
Is there a better way to work out the exact amount of pixels a line of text takes up? I did some googling and it seems possible but I am a javascript noob and can't figure out how to incorporate any of the examples in to my particular code.
Here is the full javascript for the sliding arrow.
Web search has been one of those crap ware that I try to get rid of asap. It's annoying and slow.
It was a cheap way for Microsoft to drive traffic to Bing.
All I can say is that think the USB G8 is better in many ways, and costs the same or slightly less. I wouldn't part with mine. It's even a big improvement over the G6 USB. (You can also use studio phones (up to 600 OHMs I think) with the G8, but I have to say that even relatively cheap 30-50 OHM phones sound absolutely great--far better than through most internal motherboard sound!) Considering the difference in these products I am surprised that Creative is still making the PCIe internal card versions.
https://www.headphoneer.com/cr...ve-sound-blaster-g8-review/
I missed this when you first posted it, but those are awesome icons!
I would normally prefer things to be uniform, but each of those icons seems to fit perfectly for the game! If I may ask though, what was your thought process on which icons are circular - MK makes sense - and which ones should be rectangular or square?
What I like about Paint is using it almost exclusively for cropping and resizing images I get elsewhere--it's quick, easy and cheap... I keep it glued to my taskbar, in fact. Also, the clipping tool comes in handy, as well (hit print scrn on the keyboard and it activates immediately.)
I still remember it fondly today. It was so cool to work in 64-color Half Bright mode and 4.096-color HAM mode (interlaced) when x86 was still in 4-color CGA or 16-color EGA low res. C= never realized what it had until it was far too late--the failure of C= was the failure of its top management. The C= Amiga was 20 years ahead of its time, I always thought. It didn't hurt that in only 512k of chip memory, the Amiga could preemptively multitask when Apple was still doing gray scale graphics on tiny screens and along with everyone else was doing cooperative multitasking (running more than one app at a time in resident memory, but you could only run one of them at a time--had to manually switch between them.) I had a ball with AREXX scripting running between programs that had AREXX ports so that when you sent other applications data and instructions, those running applications could process the same in real time to output! Memories...
Question
jordan.
Hi all,
A while ago I had someone create a sliding bar effect for a website I was working on. If you check out the site linked below, you will see the sliding bar thingy that I am talking about where it says "Tona Boards" on a sort of green arrow, then it slides back and forth to reveal different text.
http://www.tonaboards.com/
Now there is just one small problem with it. There is always this unnecessary amount of extra space after the text if the line of text is quite long. This is a result of a poor calculation for the width of the arrow. Currently this is how the width of the arrow is calculated:
var width = titles[title_id][0].length * 15;
Basically, he is just multiplying the number of characters by 15 to get a close (but not accurate) pixel width that will fit the text.
Is there a better way to work out the exact amount of pixels a line of text takes up? I did some googling and it seems possible but I am a javascript noob and can't figure out how to incorporate any of the examples in to my particular code.
Here is the full javascript for the sliding arrow.
http://www.tonaboards.com/wp-content/themes/TonaLife/arrow.js
Cheers for any help.
Jordan
Link to comment
https://www.neowin.net/forum/topic/935436-javascript-determine-length-of-text-in-pixels/Share on other sites
8 answers to this question
Recommended Posts